Is it possible to get the x-axis names from a string in my series list? I'm building this series list on the backend and would like to use the "New York", "LA" and "Chicago" as my x-axis category values.
I would expect "New York", "LA" and "Chicago" as my x-axis labels, however, I'm getting -0.25 through 2.25.
Thanks.
http://jsfiddle.net/nicholasduffy/H7zgb/2/
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: false
}
}
},
series: [{
"data": [
["New York", 3570.5],
["LA", 50128.38],
["Chicago", 5281.22]
],
"name": "Stuff"
}, {
"data": [
["New York", 10140.84],
["LA", 21445.04],
["Chicago", 12957.77]
],
"name": "Junk"
}, {
"data": [
["New York", 65119.6],
["LA", 103118.6],
["Chicago", 78349.6]
],
"name": "Other Stuff"
}]
});
});
As of HighCharts 3 you can use xAxis.type and set it to "category" for your desired behavior without having to specify the category names.
http://api.highcharts.com/highcharts#xAxis.type
I've edited the jFiddle to have the following:
xAxis: {
type: "category"
}
http://jsfiddle.net/H7zgb/22/
I believe you are looking for this...
http://api.highcharts.com/highcharts#xAxis.categories
Take a look at this fiddle...I've added the following:
xAxis: {
categories: ["New York", "LA", "Chicago"]
},
http://jsfiddle.net/H7zgb/3/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With