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

Fix tooltip when displaying multiple series #66

Merged
merged 1 commit into from
Mar 14, 2014

Commits on Mar 10, 2014

  1. Fix tooltip when displaying multiple series

    We replace the "%x" in the tooltip string with the corresponding item tick's
    label. We do so by looking at the item's index in the chart's data array
    (dataIndex), and getting the tick in the same index in the ticks' array.
    That works fine if you have a single series, but doesn't work with multiple
    ones.
    
    In that case, you have multiple data arrays, one for each series, but you still
    have a single ticks array. For example, if you have the plot's data as:
    
    [
      { data: [ ["Foo", 5] ] },
      { data: [ ["Bar", 10] ] }
    ]
    
    Both item's dataIndex will be 0, because each one is the first element on its
    series' data array. But the ticks array is something like:
    
    ["Foo", "Bar"]
    
    If you use only dataIndex, you'll get the tick "Foo" for both items. What we
    need is an offset which tells us which series the current item is in: that's
    seriesIndex. The ticks' index is then calculated as ```seriesIndex +
    dataIndex```.
    
    That solves our problem. In our example, even though the dataIndex for both
    items is 0, the seriesIndex for "Foo" is 0, and for "Bar" is 1. Everything
    works as expected.
    
    This fixes krzysu#65.
    vitorbaptista committed Mar 10, 2014
    Configuration menu
    Copy the full SHA
    d21ecc5 View commit details
    Browse the repository at this point in the history