|
@ -18,7 +18,7 @@ |
|
|
* |
|
|
* |
|
|
* <Chart |
|
|
* <Chart |
|
|
* data={data} |
|
|
* data={data} |
|
|
* interactive // Handle mouse events, display tooltip etc.
|
|
|
* isInteractive // Handle mouse events, display tooltip etc.
|
|
|
* color="#5f8ced" // Main color for line, gradient, etc.
|
|
|
* color="#5f8ced" // Main color for line, gradient, etc.
|
|
|
* height={300} // Fix height. Width is responsive to container.
|
|
|
* height={300} // Fix height. Width is responsive to container.
|
|
|
* /> |
|
|
* /> |
|
@ -37,7 +37,7 @@ import React, { PureComponent } from 'react' |
|
|
import * as d3 from 'd3' |
|
|
import * as d3 from 'd3' |
|
|
import noop from 'lodash/noop' |
|
|
import noop from 'lodash/noop' |
|
|
|
|
|
|
|
|
import type { Unit } from '@ledgerhq/live-common/lib/types' |
|
|
import type { Account } from '@ledgerhq/live-common/lib/types' |
|
|
|
|
|
|
|
|
import refreshNodes from './refreshNodes' |
|
|
import refreshNodes from './refreshNodes' |
|
|
import refreshDraw from './refreshDraw' |
|
|
import refreshDraw from './refreshDraw' |
|
@ -48,7 +48,7 @@ import type { Data } from './types' |
|
|
|
|
|
|
|
|
export type Props = { |
|
|
export type Props = { |
|
|
data: Data, // eslint-disable-line react/no-unused-prop-types
|
|
|
data: Data, // eslint-disable-line react/no-unused-prop-types
|
|
|
unit?: Unit, // eslint-disable-line react/no-unused-prop-types
|
|
|
account?: Account, // eslint-disable-line react/no-unused-prop-types
|
|
|
|
|
|
|
|
|
id?: string, // eslint-disable-line react/no-unused-prop-types
|
|
|
id?: string, // eslint-disable-line react/no-unused-prop-types
|
|
|
height?: number, |
|
|
height?: number, |
|
@ -56,7 +56,7 @@ export type Props = { |
|
|
color?: string, // eslint-disable-line react/no-unused-prop-types
|
|
|
color?: string, // eslint-disable-line react/no-unused-prop-types
|
|
|
hideAxis?: boolean, // eslint-disable-line react/no-unused-prop-types
|
|
|
hideAxis?: boolean, // eslint-disable-line react/no-unused-prop-types
|
|
|
dateFormat?: string, // eslint-disable-line react/no-unused-prop-types
|
|
|
dateFormat?: string, // eslint-disable-line react/no-unused-prop-types
|
|
|
interactive?: boolean, // eslint-disable-line react/no-unused-prop-types
|
|
|
isInteractive?: boolean, // eslint-disable-line react/no-unused-prop-types
|
|
|
renderTooltip?: Function, // eslint-disable-line react/no-unused-prop-types
|
|
|
renderTooltip?: Function, // eslint-disable-line react/no-unused-prop-types
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -67,9 +67,8 @@ class Chart extends PureComponent<Props> { |
|
|
height: 400, |
|
|
height: 400, |
|
|
hideAxis: false, |
|
|
hideAxis: false, |
|
|
id: 'chart', |
|
|
id: 'chart', |
|
|
interactive: true, |
|
|
isInteractive: true, |
|
|
tickXScale: 'month', |
|
|
tickXScale: 'month', |
|
|
unit: undefined, |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
componentDidMount() { |
|
@ -113,7 +112,7 @@ class Chart extends PureComponent<Props> { |
|
|
|
|
|
|
|
|
this.refreshChart = prevProps => { |
|
|
this.refreshChart = prevProps => { |
|
|
const { _node: node, props } = this |
|
|
const { _node: node, props } = this |
|
|
const { data: raw, color, height, hideAxis, interactive, renderTooltip } = props |
|
|
const { data: raw, color, height, hideAxis, isInteractive, renderTooltip } = props |
|
|
|
|
|
|
|
|
ctx.DATA = enrichData(raw) |
|
|
ctx.DATA = enrichData(raw) |
|
|
|
|
|
|
|
@ -157,7 +156,7 @@ class Chart extends PureComponent<Props> { |
|
|
|
|
|
|
|
|
// Mouse handler
|
|
|
// Mouse handler
|
|
|
mouseHandler && mouseHandler.remove() // eslint-disable-line no-unused-expressions
|
|
|
mouseHandler && mouseHandler.remove() // eslint-disable-line no-unused-expressions
|
|
|
if (interactive) { |
|
|
if (isInteractive) { |
|
|
mouseHandler = handleMouseEvents({ |
|
|
mouseHandler = handleMouseEvents({ |
|
|
ctx, |
|
|
ctx, |
|
|
props, |
|
|
props, |
|
|