Question

I'm converting existing code that displays a single line graph to display multiple line graphs at once. I would like each line graph to have tooltips. My code looks like this:

var line = new RGraph.Line('canvas', data).Set('tooltips', tips)

I can make multiple line graphs render by changing the data array from 1-dimension to 2-dimensions. But I have also converted the tips array to 2-dimensions, and no tooltips are appearing at all. Am I correct in assuming that the tips array is assumed to be 1-dimensional, and if so how do I specify tooltips for multiple line charts?

Was it helpful?

Solution

Give them as one big array. If you have them in multiple arrays you can use the JavaScript concat() function or you just add them together like below.

Here's an example without using the concat function:

new RGraph.Line({
    id: 'cvs',
    data: [
        [8,4,3],
        [9,8,1]
    ],
    options: {
        tooltips: ['A', 'B','C','D','E','F']
    }
}).draw();

And here's an example using concat():

tooltips_a     = ['A', 'B','C'];
tooltips_b     = ['D','E','F'];
tooltips_combo = tooltips_a.concat(tooltips_b);

new RGraph.Line({
    id: 'cvs',
    data: [
        [8,4,3],
        [9,8,1]
    ],
    options: {
        tooltips: tooltips_combo
    }
}).draw();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top