Add markLine to chart

This commit is contained in:
Yang Luo 2023-05-29 02:27:47 +08:00
parent ccd01ab604
commit 0fa141f972
2 changed files with 35 additions and 30 deletions

View File

@ -2,7 +2,7 @@ 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, nowTime) { drawPic(data, currentTime) {
const xAxisData = data.map(item => Number(item.time)); const xAxisData = data.map(item => Number(item.time));
const seriesData = data.map(item => ({ const seriesData = data.map(item => ({
value: Number(item.data), value: Number(item.data),
@ -43,33 +43,38 @@ class VideoDataChart extends Component {
{ {
name: 'Data', name: 'Data',
type: 'line', type: 'line',
data: seriesData data: seriesData,
} markLine: {
], data: [
markLine: { [
symbol: 'none', {
lineStyle: { symbol: 'none',
color: 'red' x: `${currentTime / 0.65 + 40}`,
}, y: '80%',
data: [ lineStyle: {
{ color: 'red'
xAxis: nowTime, },
yAxis: dataMin, // label: {
symbol: 'none', // position: 'start',
lineStyle: { // formatter: 'Max'
color: 'red' // },
} },
}, {
{ symbol: 'none',
xAxis: nowTime, x: `${currentTime / 0.65 + 40}`,
yAxis: dataMax, y: '0%',
symbol: 'none', // label: {
lineStyle: { // position: 'start',
color: 'red' // formatter: 'Max'
} // },
// type: 'max',
// name: 'Max Point',
}
],
]
} }
] }
} ]
}; };
return ( return (
@ -81,11 +86,11 @@ class VideoDataChart extends Component {
} }
render() { render() {
const nowTime = 285; const currentTime = this.props.currentTime;
return ( return (
<div> <div>
{this.drawPic(this.props.data, nowTime)} {this.drawPic(this.props.data.filter(item => item.time !== ""), currentTime)}
</div> </div>
); );
} }

View File

@ -224,7 +224,7 @@ class VideoEditPage extends React.Component {
</Row> </Row>
{ {
this.state.videoData === null ? null : ( this.state.videoData === null ? null : (
<VideoDataChart data={this.state.videoData} /> <VideoDataChart data={this.state.videoData} currentTime={this.state.currentTime} />
) )
} }
</Affix> </Affix>