@@ -11,8 +11,9 @@ import { CustomLegend } from './CustomLegend'
1111import { getMaxChartValue , getMinChartValue } from './helpers'
1212import { LineChartTooltip } from './Tooltip'
1313
14- import type { DatumValue , Box as NivoBox , ValueFormat } from '@nivo/core'
15- import type { LineSvgProps , Point , Serie } from '@nivo/line'
14+ import type { Serie } from './helpers'
15+ import type { Box as NivoBox , ValueFormat } from '@nivo/core'
16+ import type { LineSvgProps , Point , LineSeries , AllowedValue } from '@nivo/line'
1617import type { ScaleSpec } from '@nivo/scales'
1718import type { theme as UVTheme } from '@ultraviolet/themes'
1819import type { ComponentProps , CSSProperties } from 'react'
@@ -25,7 +26,7 @@ type LineChartProps = {
2526 data ?: Serie [ ]
2627 withLegend ?: boolean
2728 tooltipFunction ?: ( props : {
28- point : Point
29+ point : Point < LineSeries >
2930 } ) => Partial <
3031 Pick < ComponentProps < typeof LineChartTooltip > , 'xFormatted' | 'yFormatted' >
3132 >
@@ -35,11 +36,11 @@ type LineChartProps = {
3536 ComponentProps < typeof CustomLegend > [ 'axisTransformer' ]
3637 >
3738 >
38- pointFormatters ?: Partial < Record < 'x' | 'y' , ValueFormat < DatumValue > > >
39+ pointFormatters ?: Partial < Record < 'x' | 'y' , ValueFormat < AllowedValue > > >
3940 tickValues ?: Partial <
4041 Record < 'bottom' | 'left' | 'right' | 'top' , number | string >
4142 >
42- chartProps ?: Partial < LineSvgProps >
43+ chartProps ?: Partial < LineSvgProps < LineSeries > >
4344 'data-testid' ?: string
4445 style ?: CSSProperties
4546}
@@ -56,7 +57,7 @@ const DEFAULT_CHARTPROPS = {}
5657
5758const createCustomTooltip =
5859 ( tooltipFunction ?: LineChartProps [ 'tooltipFunction' ] ) =>
59- ( props : { point : Point } ) => {
60+ ( props : { point : Point < LineSeries > } ) => {
6061 const customProps = tooltipFunction ? tooltipFunction ( props ) : { }
6162
6263 return (
@@ -151,15 +152,15 @@ export const LineChart = ({
151152 max : getMaxChartValue ( finalData ) ,
152153 min : getMinChartValue ( finalData ) ,
153154 ...yScale ,
154- } as LineSvgProps [ 'yScale' ]
155+ } as LineSvgProps < LineSeries > [ 'yScale' ]
155156 }
156157 { ...chartProps }
157158 />
158159 </ div >
159160 { withLegend && (
160161 < CustomLegend
161162 axisTransformer = { axisFormatters ?. left }
162- data = { dataset . datasets }
163+ data = { data }
163164 selected = { selected ?? [ ] }
164165 setSelected = { setSelected }
165166 />
0 commit comments