Refactor
This commit is contained in:
@@ -8,7 +8,7 @@ const { XYPlot, LineMarkSeries, Hint, YAxis, HorizontalGridLines } = require('re
|
||||
const abbreviate = require('number-abbreviate')
|
||||
|
||||
interface Props {
|
||||
data: {x: number, y: number}[]
|
||||
data: Array<{x: number, y: number}>
|
||||
}
|
||||
|
||||
interface Stats {
|
||||
@@ -26,6 +26,23 @@ class PlotHistory extends React.Component<Props, Stats> {
|
||||
this.setState({ width: width - 12 })
|
||||
}
|
||||
|
||||
private hintFormatter = (point: any) => {
|
||||
return [
|
||||
{ title: <b>Time</b>, value: <DateFormatter date={new Date(point.x)} /> },
|
||||
{ title: <b>Value</b>, value: point.y },
|
||||
]
|
||||
}
|
||||
|
||||
private _forgetValue = () => {
|
||||
this.setState({
|
||||
value: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
private _rememberValue = (value: any) => {
|
||||
this.setState({ value })
|
||||
}
|
||||
|
||||
public render() {
|
||||
const data = this.props.data
|
||||
|
||||
@@ -50,23 +67,6 @@ class PlotHistory extends React.Component<Props, Stats> {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private hintFormatter = (point: any) => {
|
||||
return [
|
||||
{ title: <b>Time</b>, value: <DateFormatter date={new Date(point.x)} /> },
|
||||
{ title: <b>Value</b>, value: point.y },
|
||||
]
|
||||
}
|
||||
|
||||
private _forgetValue = () => {
|
||||
this.setState({
|
||||
value: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
private _rememberValue = (value: any) => {
|
||||
this.setState({ value })
|
||||
}
|
||||
}
|
||||
|
||||
export default PlotHistory
|
||||
|
||||
Reference in New Issue
Block a user