How to reverse a bar chart in highcharts?

ε祈祈猫儿з 提交于 2019-12-12 12:18:46

问题


Are there some highcharts pros out there?

What i want is, that value 6 (lowest score) starts left and on the right there is the highest score (1)

so the bars heading to 1 (showing the space to be mark 1)

like:

|------------------------(1.9)

|--------------------(2.3)

|----------------------------(1.4)

6..............3................1

http://jsfiddle.net/aCz2s/1/

Any help with that?


回答1:


You can set reversed to yAxis too, like you did on xAxis.

Like this:

xAxis: {
    reversed: true
},
yAxis: {
    reversed: true
}

Here is a demo




回答2:


I would do something like this. What is important here and is kind of clunky. Is to make your values be negative and then use the label formatter on the xAxis to have them appear positive (with adjusted min/max):

    yAxis: {
        min: -6,
        max: 0,
        title: {
            text: 'Marks from  6 (very bad) to 1 (yery good)',
            align: 'high'
        },
        labels: {
            overflow: 'justify',
            formatter: function() {
            return this.value * -1;
        }
        }
    }

Also set the Xaxis to be on the opposite side:

    xAxis: {
        reversed:true,
        categories: ['John', 'Sandy', 'Carl', 'Maria'],
        title: {
            text: null
        },
        opposite: true
    }


来源:https://stackoverflow.com/questions/13562452/how-to-reverse-a-bar-chart-in-highcharts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!