Add two charts
This commit is contained in:
parent
0fa141f972
commit
4dd50a2f57
|
@ -2,11 +2,11 @@ import React, { Component } from "react";
|
||||||
import ReactEcharts from 'echarts-for-react';
|
import ReactEcharts from 'echarts-for-react';
|
||||||
|
|
||||||
class VideoDataChart extends Component {
|
class VideoDataChart extends Component {
|
||||||
drawPic(data, currentTime) {
|
drawPic(data, currentTime, height) {
|
||||||
const xAxisData = data.map(item => Number(item.time));
|
const xAxisData = data.map(item => item.time);
|
||||||
const seriesData = data.map(item => ({
|
const seriesData = data.map(item => ({
|
||||||
value: Number(item.data),
|
value: item.data,
|
||||||
error: Number(item.confidence)
|
error: item.confidence,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let dataMax = -Infinity;
|
let dataMax = -Infinity;
|
||||||
|
@ -67,8 +67,6 @@ class VideoDataChart extends Component {
|
||||||
// position: 'start',
|
// position: 'start',
|
||||||
// formatter: 'Max'
|
// formatter: 'Max'
|
||||||
// },
|
// },
|
||||||
// type: 'max',
|
|
||||||
// name: 'Max Point',
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
@ -80,17 +78,28 @@ class VideoDataChart extends Component {
|
||||||
return (
|
return (
|
||||||
<ReactEcharts
|
<ReactEcharts
|
||||||
option={option}
|
option={option}
|
||||||
style={{ height: '200px' }}
|
style={{height: height}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let data = this.props.data;
|
||||||
const currentTime = this.props.currentTime;
|
const currentTime = this.props.currentTime;
|
||||||
|
const interval = this.props.interval;
|
||||||
|
let height = this.props.height;
|
||||||
|
|
||||||
|
if (interval !== undefined && interval !== null) {
|
||||||
|
data = data.filter(item => currentTime - interval < item.time && item.time < currentTime + interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (height === undefined || height === null) {
|
||||||
|
height = "200px";
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{this.drawPic(this.props.data.filter(item => item.time !== ""), currentTime)}
|
{this.drawPic(data, currentTime, height)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,12 @@ class VideoEditPage extends React.Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{marginTop: "10px"}}>
|
<div style={{marginTop: "10px"}}>
|
||||||
|
<div style={{fontSize: 16, marginTop: "10px"}}>
|
||||||
|
{i18next.t("video:Current time (second)")}: {" "}
|
||||||
|
{
|
||||||
|
this.state.currentTime
|
||||||
|
}
|
||||||
|
</div>
|
||||||
<div className="screen" style={{position: "absolute", zIndex: 100, pointerEvents: "none", width: '440px', height: '472px', marginLeft: '200px', marginRight: '200px', backgroundColor: "rgba(255,0,0,0)" }}></div>
|
<div className="screen" style={{position: "absolute", zIndex: 100, pointerEvents: "none", width: '440px', height: '472px', marginLeft: '200px', marginRight: '200px', backgroundColor: "rgba(255,0,0,0)" }}></div>
|
||||||
<Video task={task} labels={this.state.video.labels}
|
<Video task={task} labels={this.state.video.labels}
|
||||||
onUpdateTime={(time) => {this.setState({currentTime: time})}}
|
onUpdateTime={(time) => {this.setState({currentTime: time})}}
|
||||||
|
@ -100,12 +106,6 @@ class VideoEditPage extends React.Component {
|
||||||
onCreateVideo={(videoObj) => {this.setState({videoObj: videoObj})}}
|
onCreateVideo={(videoObj) => {this.setState({videoObj: videoObj})}}
|
||||||
onPause={() => {this.onPause()}}
|
onPause={() => {this.onPause()}}
|
||||||
/>
|
/>
|
||||||
<div style={{fontSize: 16, marginTop: "10px"}}>
|
|
||||||
{i18next.t("video:Current time (second)")}: {" "}
|
|
||||||
{
|
|
||||||
this.state.currentTime
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -115,9 +115,17 @@ class VideoEditPage extends React.Component {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}).then(res => res.text())
|
}).then(res => res.text())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const result = Papa.parse(res, { header: true });
|
const result = Papa.parse(res, { header: true });
|
||||||
|
let data = result.data;
|
||||||
|
data = data.filter(item => item.time !== "");
|
||||||
|
data = data.map(item => {
|
||||||
|
let res = {};
|
||||||
|
res.time = Number(item.time);
|
||||||
|
res.data = Number(item.data);
|
||||||
|
return res;
|
||||||
|
});
|
||||||
this.setState({
|
this.setState({
|
||||||
videoData: result.data,
|
videoData: data,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -203,7 +211,7 @@ class VideoEditPage extends React.Component {
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={11} style={(Setting.isMobile()) ? {maxWidth: "100%"} : {}}>
|
<Col span={11} style={(Setting.isMobile()) ? {maxWidth: "100%"} : {}}>
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Affix offsetTop={50}>
|
<Affix offsetTop={-100}>
|
||||||
{
|
{
|
||||||
this.state.video !== null ? this.renderVideoContent() : null
|
this.state.video !== null ? this.renderVideoContent() : null
|
||||||
}
|
}
|
||||||
|
@ -212,7 +220,7 @@ class VideoEditPage extends React.Component {
|
||||||
{i18next.t("general:Data")}:
|
{i18next.t("general:Data")}:
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22} >
|
<Col span={22} >
|
||||||
<Select virtual={false} style={{width: '100%'}} value={this.state.video.dataUrl} onChange={(value => {
|
<Select virtual={false} style={{width: '100%', marginBottom: "10px"}} value={this.state.video.dataUrl} onChange={(value => {
|
||||||
this.getDataAndParse(value);
|
this.getDataAndParse(value);
|
||||||
this.updateVideoField('dataUrl', value);
|
this.updateVideoField('dataUrl', value);
|
||||||
})}>
|
})}>
|
||||||
|
@ -224,7 +232,10 @@ class VideoEditPage extends React.Component {
|
||||||
</Row>
|
</Row>
|
||||||
{
|
{
|
||||||
this.state.videoData === null ? null : (
|
this.state.videoData === null ? null : (
|
||||||
<VideoDataChart data={this.state.videoData} currentTime={this.state.currentTime} />
|
<React.Fragment>
|
||||||
|
<VideoDataChart key={"VideoDataChart1"} data={this.state.videoData} currentTime={this.state.currentTime} height={"100px"} />
|
||||||
|
<VideoDataChart key={"VideoDataChart2"} data={this.state.videoData} currentTime={this.state.currentTime} interval={25} />
|
||||||
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</Affix>
|
</Affix>
|
||||||
|
|
Loading…
Reference in New Issue