最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Highcharts display series.name on X Axis - Stack Overflow

programmeradmin0浏览0评论

I'm trying to display each series name on X-Axis /

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

Does somebody knows how to do this?

I'm trying to display each series name on X-Axis http://jsfiddle/Jr79Y/9/

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

Does somebody knows how to do this?

Share Improve this question asked Apr 21, 2015 at 11:53 HieroHiero 2,2057 gold badges29 silver badges48 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

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/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.

http://jsfiddle/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]
        }

Try this:

xAxis: {
  categories: ['Test', 'Test', 'Test'],
  title: {
    text: null,
  }
},

And in series part:

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

Reference.

EDITED:

You are using three group so you need to modify your data format. If you want the different color then try this:

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

Check this out

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        xAxis: {
            categories:['Test 1', 'Test 2', 'Test3']
        },
        plotOptions: {
            series: {
                dataLabels: {
                    enabled: true,
                }
                //colorByPoint: true
            },
             series: {
                colorByPoint: true
            }
        },
        legend: {
            layout: 'vertical',
            floating: true,
            backgroundColor: '#FFFFFF',
            align: 'right',
            verticalAlign: 'top',
            y: 60,
            x: -60
        },

        series: [{
            data: [40,20,20]
        }]
    });
});

http://jsfiddle/Jr79Y/36/

发布评论

评论列表(0)

  1. 暂无评论