c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.34k stars 1.39k forks source link

Hidden columns data are available to the plot, but not to the tooltip building function #2022

Open Muzietto opened 7 years ago

Muzietto commented 7 years ago

My charts (timeseries, to be precise) show two data series in the plot.

Actually the data series that are available to me are four, but two of them are non-numerical and therefore not plottable.

However, when the user moves the mouse in the plot I want the non-numeric values for the chosen day to show in the tooltip.

I have put the non-numerical data inside two columns and immediately set them as hidden:

columns: [
  ['x'].concat(simResult.xAxis),
  ['nominalValue'].concat(simResult.nominalValue),
  ['realValue'].concat(simResult.realValue),
  ['dataFlag'].concat(simResult.dataFlag),
  ['action'].concat(simResult.action)
],
hide: ['dataFlag', 'action']

My plot shows only two dataseries, but I can see that the hidden series are available as greyed out links at the bottom of the plot. So far, so good.

I have tried to modify the tooltip by overriding the usual function tooltip.contents(d, defaultTitleFormat, defaultValueFormat, color)

Problem is: when I debug the function, I see that the param d contains only the two displayed data series!!

I was expecting that d would contain ALL the data available to the plot, so to enable me to put dataFlag and action values inside the tooltip.

It looks like I will have to solve my problem by cracking the C3 code and retrieving the non-numerical values through some ugly global ad-hoc object.

--> Can anyone suggest a solution within the boundaries of C3 or D3?

wokuang commented 7 years ago

I also facing this problem. Is there any suggestion how to get ALL data available on tooltip contents.