williamsandonz
williamsandonz

Reputation: 16440

Highcharts set x-axis categories

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.

Upvotes: 20

Views: 57758

Answers (3)

try this one

Data.chart.xAxis["categories"] = ['a','b','c']

Upvotes: -1

splash
splash

Reputation: 13327

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});

Upvotes: 3

eolsson
eolsson

Reputation: 12727

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/

Upvotes: 37

Related Questions