Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts display series.name on X Axis

I'm trying to display each series name on X-Axis http://jsfiddle.net/Jr79Y/9/ enter image description here

series: [{
            name: 'Test',
            data: [20]
        }, {
            name: 'Test',
            data: [20]
        }, {
            name: 'Test',
            data: [40]
        }]

Does somebody knows how to do this?

like image 947
Hiero Avatar asked Mar 17 '23 08:03

Hiero


2 Answers

This is a much simpler solution than anything I'm seeing for answers so far:

 xAxis: {
            categories:[]
        }

.

series: [{
            data: [{name:'Test 1',y:20,color:'red'},
                   {name:'Test 2',y:20,color:'blue'},
                   {name:'Test 3',y:40,color:'green'}]
        }]

Example:

  • http://jsfiddle.net/jlbriggs/Jr79Y/37/

Although unless you have a really good reason for having each bar be a different color, it usually just adds unnecessary visual clutter and you're better off leaving them a single color.

like image 61
jlbriggs Avatar answered Mar 18 '23 23:03

jlbriggs


http://jsfiddle.net/Jr79Y/35/

xAxis: {
            categories: ['Test1', 'Test2', 'Test3']
        }

For the series, this is quite dirty but it works:

series: [{
            name: 'Test1',
            data: [20, 0, 0]
        }, {
            name: 'Test2',
            data: [0, 20, 0]
        }, {
            name: 'Test3',
            data: [0, 0, 40]
        }
like image 30
couscousman Avatar answered Mar 18 '23 21:03

couscousman