jQuery Highcharts 设置 x 轴类别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8381331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Highcharts set x-axis categories
提问by Baconbeastnz
Hi guys 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.
我在文档中根本看不到任何更改 xAxis 类别的内容,这可能吗?我看不到任何 4 更改标题,但设法在线获取了一个片段,我真的需要避免破坏和重新创建图表。
回答by eolsson
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
您可以使用setCategories
Axis 对象上的方法执行此操作。请参阅此处的轴参考文档:http: //www.highcharts.com/ref/#axis-object
Example: http://jsfiddle.net/4tuvC/
回答by splash
Since Highcharts 5.0.0you can use the update()function to update the chart options after render time:
从Highcharts 5.0.0 开始,您可以使用update()函数在渲染时间后更新图表选项:
Data.chart.xAxis[0].update({categories: xAxisCategories});