Improve plot

This commit is contained in:
Thomas Nordquist
2019-01-20 13:27:29 +01:00
parent 435fb1f9b9
commit 71c4d1e04b
3 changed files with 30 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
const { XYPlot, XAxis, YAxis, HorizontalGridLines, LineSeries } = require('react-vis')
const { XYPlot, XAxis, LineMarkSeries, Hint, YAxis, HorizontalGridLines, LineSeries } = require('react-vis')
import { default as ReactResizeDetector } from 'react-resize-detector'
import * as React from 'react'
@@ -12,6 +12,7 @@ interface Props {
interface Stats {
width: number
value?: any
}
class PlotHistory extends React.Component<Props, Stats> {
@@ -36,13 +37,30 @@ class PlotHistory extends React.Component<Props, Stats> {
<div>
<XYPlot width={this.state.width} height={150}>
<HorizontalGridLines />
<LineSeries data={data} />
<YAxis />
<LineMarkSeries
onValueMouseOver={this._rememberValue}
onValueMouseOut={this._forgetValue}
size={3}
data={data}
curve="curveCardinal"
/>
{this.state.value ? <Hint value={this.state.value} /> : null}
</XYPlot>
<ReactResizeDetector handleWidth={true} onResize={this.resize} />
</div>
)
}
private _forgetValue = () => {
this.setState({
value: undefined,
})
}
private _rememberValue = (value: any) => {
this.setState({ value })
}
}
export default withStyles({}, { withTheme: true })(PlotHistory)