IT_Guy IT_Guy - 1 day ago 3
Javascript Question

Highcharts-Only 1 legend value for multiple entries on a category

I have a column chart that uses numbers on one axis (.001-10) and categories of dates on the other axis (2/23/2014,2/27/2014,etc). Each column represents and object's entry for that day. For example object 1 has .012 on 2/23/2014 and object 2 has .034 on 2/27/2014. Sometimes these objects can have multiple entries on the same date. As of now the only way I have found to incorporate multiple entries on the same date is to add another series and use the same color and modify the name so it reflect a multiple entry. This is an ugly way to do it though as sometimes the legend will have object 1, object 1 (2), object 1 (3), and so on. I want to make it so all are linked into a single legend value. Is there a way to do this? Here's a fiddle that illustrates what I currently have goin on: http://jsfiddle.net/Pudge/8r9WV/

-

Answer

Use simply linkedTo option for linked series, where value for it is id of another series:

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        id: 'id1',
        name:"object 1"       
    }, {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        id: 'id2',
        name:"object 2"   
    }, {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        id: 'id3',
        name:"object 3" ,
        color:'#8bbc21'
    }, {
        data: [35, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 70],
        linkedTo: 'id3',
        name:"object 3 (2)",
        color:'#8bbc21'
    }]

Demo: http://jsfiddle.net/8r9WV/2/

Comments