[英]How to add gridlines to an already generated chart in highcharts?
I have a bubble chart which is already generated.我有一个已经生成的气泡图。 I need to add/remove gridlines on the same chart based on a checkbox which user can select.
我需要根据用户可以 select 的复选框在同一个图表上添加/删除网格线。
I tried something like the following but it didn't work.我尝试了以下类似的方法,但没有奏效。
setTimeout(function () {
var chart = $('#bubble-chart-container').highcharts();
chart.options.xAxis[0].gridLineWidth = 1;
chart.options.yAxis[0].gridLineWidth = 1;
chart.reflow();
}, 500);
You will need to use the chart.update
( API link ) method like this:您将需要像这样使用
chart.update
( API 链接)方法:
HTML HTML
<div id="container"></div>
<button id="addButton">Add lines</button>
<button id="removeButton">Remove lines</button>
Javascript Javascript
var chart = Highcharts.chart('container', {
...
});
$('#addButton').click(function() {
chart.update({
xAxis:{
gridLineWidth: 1
},
yAxis:{
gridLineWidth: 1
}
});
});
$('#removeButton').click(function() {
chart.update({
xAxis:{
gridLineWidth: 0
},
yAxis:{
gridLineWidth: 0
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.