You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are deriving Serie.data for a Line from an array of richer objects. In a SliceTooltip, we want to resolve properties from the original richer objects. The Point fed to SliceTooltip in points contains the in-serie index of the point, and we can use this in-serie index to find the original richer object from the source array. This in-serie index is only available in Point.id, and only in a form where it is concatenated with serie.id
It seems a little unnecessarily tricky to recover the in-series index by parsing this identifier and we are a little worried this identifier format might change in future versions.
Suggested feature
It would be more convenient for us if Point included a property indexInSerie or something like that.
indexInSerie: i,
Alternative solution
I see there is a property data included in these points on line 50 but it is a little unclear to me whether we can pass a reference to our original richer objects via these data properties.
The serie.data mapped here seems to to be copied from an element of rawSeries:
Problem
We are deriving
Serie.data
for aLine
from an array of richer objects. In aSliceTooltip
, we want to resolve properties from the original richer objects. ThePoint
fed toSliceTooltip
inpoints
contains the in-serie index of the point, and we can use this in-serie index to find the original richer object from the source array. This in-serie index is only available inPoint.id
, and only in a form where it is concatenated withserie.id
nivo/packages/line/src/hooks.js
Line 41 in 0f5ac2f
It seems a little unnecessarily tricky to recover the in-series index by parsing this identifier and we are a little worried this identifier format might change in future versions.
Suggested feature
It would be more convenient for us if
Point
included a propertyindexInSerie
or something like that.Alternative solution
I see there is a property
data
included in these points on line 50 but it is a little unclear to me whether we can pass a reference to our original richer objects via thesedata
properties.The
serie.data
mapped here seems to to be copied from an element ofrawSeries
:nivo/packages/line/src/hooks.js
Lines 184 to 188 in 0f5ac2f
rawSeries
seems to come fromcomputeXYScalesForSeries
wheredata
is set to extended copies of the elements of aserie.data
.nivo/packages/scales/src/compute.ts
Lines 150 to 159 in 0f5ac2f
That
serie
seems to be like the originalserie
but with each object indata
, nested in a new object, under a new propertydata
.nivo/packages/scales/src/compute.ts
Lines 91 to 96 in 0f5ac2f
If I didn't read the source wrong, we could feed
Line
withdata
like:nestSerieData
would produce:computeXYScalesForSeries
would produce aseries
like:useLine
would produce adataWithColor
like:and a
series
like:usePoints
will take this and produce something like:and we could use
Point.data.original
to resolve properties from our original richer objects.If that is true, it would be nice to see it documented somewhere near
nivo/packages/line/index.d.ts
Lines 90 to 96 in 0f5ac2f
Documentation consulted before creating issue
I browsed https://nivo.rocks/ for documentation on tooltips but I only found: https://nivo.rocks/line/#interactivity-tooltip and https://nivo.rocks/line/#interactivity-sliceTooltip
Additional context
For additional context, our project and the changes sparking this issue can be found via zetkin/app.zetkin.org#2076 (comment)
The text was updated successfully, but these errors were encountered: