Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameter type of lineGenerator is weird #1604

Closed
hoi82 opened this issue Jun 20, 2021 · 4 comments · Fixed by #2238
Closed

parameter type of lineGenerator is weird #1604

hoi82 opened this issue Jun 20, 2021 · 4 comments · Fixed by #2238
Labels

Comments

@hoi82
Copy link

hoi82 commented Jun 20, 2021

When I make custom layer in ResponsiveLine, lineGenerator's parameter type is displayed,

'Iterable<{x: number, y: number}> | {x: number, y: number}[][]'

But, like below codes, pass the data like documents works well.

const CustomLine = (props: CustomLayerProps) => {
const { series, lineGenerator, xScale, yScale } = props;
return series.map((s : ComputedSerie) => {
const { id, data, color } = s;
return (
<path d={lineGenerator(data.map(d => ({ x: xScale(d.data.x), y: yScale(d.data.y) })))}
stroke={color} style={{strokeWidth: '1rem'}}/>
)
})
}

I'm using 0.70.1 version nivo/line, nivo/core, nivo/bar, nivo/tooltip.
Is there any missing of declares?

@wyze wyze added 📈 line @nivo/line package bug typescript labels Jun 20, 2021
@dardanos
Copy link

dardanos commented Jul 3, 2021

Here is what I'm doing in the meantime

interface FixedCustomLayerProps
  extends Omit<CustomLayerProps, 'xScale' | 'yScale'> {
  xScale: (x: DatumValue) => DatumValue;
  yScale: (y: DatumValue) => DatumValue;
}

@hoi82
Copy link
Author

hoi82 commented Aug 7, 2021

Here is what I'm doing in the meantime

interface FixedCustomLayerProps
  extends Omit<CustomLayerProps, 'xScale' | 'yScale'> {
  xScale: (x: DatumValue) => DatumValue;
  yScale: (y: DatumValue) => DatumValue;
}

My question is about lineGenerator. Not xScale or yScale.

@hoi82
Copy link
Author

hoi82 commented Aug 26, 2021

In @nivo/line/index.d.ts, there is a declation,

export interface CustomLayerProps extends Omit<LineSvgProps, 'xScale' | 'yScale'> {
innerHeight: number
innerWidth: number
lineGenerator: D3Line<Array<ComputedDatum['position']>>
points: Point[]
series: ComputedSerie[]
xScale: Scale<unknown, unknown>
yScale: Scale<unknown, unknown>
}

And I changed lineGenerator type to D3Line<ComputedDatum['position']> and it works well without any messages.
Will it affect other packages?

@akassaei
Copy link
Contributor

akassaei commented Mar 1, 2022

@hoi82 Any update on this issue ? I'm facing the same problem in my code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants