Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts set x-axis categories

Tags:

I am drawing my graph,

Data.chart.series[0].remove();
Data.chart.xAxis[0].axisTitle.attr({ text: xAxisTitle});
//Data.chart.xAxis[0].categories = xAxisCategories;
Data.chart.addSeries({
  name: yAxisTitle,
  data: formattedData,
  pointInterval: pointInterval
});
Data.chart.redraw();

I simply can't see anything in the documentation for changing the xAxis categories, is this possible? I couldn't see anything 4 changing the title, but managed to get a snippet online, I really need to avoid destroying & recreating the graph.

like image 501
williamsandonz Avatar asked Dec 05 '11 05:12

williamsandonz


2 Answers

You can do this with the setCategories method found on the Axis object. See the reference documentation for axis here: http://www.highcharts.com/ref/#axis-object

Example: http://jsfiddle.net/4tuvC/

like image 133
eolsson Avatar answered Sep 20 '22 12:09

eolsson


Since Highcharts 5.0.0 you can use the update() function to update the chart options after render time:

Data.chart.xAxis[0].update({categories: xAxisCategories});
like image 38
splash Avatar answered Sep 18 '22 12:09

splash