如何将网格线添加到 highcharts 中已生成的图表?

我有一个已经生成的气泡图。我需要根据用户可以选择的复选框在同一图表上添加/删除网格线。


我尝试了类似以下的方法,但没有奏效。


setTimeout(function () {

    var chart = $('#bubble-chart-container').highcharts();

    chart.options.xAxis[0].gridLineWidth = 1;

    chart.options.yAxis[0].gridLineWidth = 1;

    chart.reflow();

}, 500);


明月笑刀无情
浏览 156回答 1
1回答

幕布斯6054654

您将需要像这样使用chart.update(API 链接)方法:HTML<div id="container"></div><button id="addButton">Add lines</button><button id="removeButton">Remove lines</button>Javascriptvar chart = Highcharts.chart('container', {&nbsp; ...});$('#addButton').click(function() {&nbsp; chart.update({&nbsp; &nbsp; xAxis:{&nbsp; &nbsp; &nbsp; &nbsp; gridLineWidth: 1&nbsp; &nbsp; },&nbsp; &nbsp; yAxis:{&nbsp; &nbsp; &nbsp; &nbsp; gridLineWidth: 1&nbsp; &nbsp; }&nbsp; });});$('#removeButton').click(function() {&nbsp; chart.update({&nbsp; &nbsp; xAxis:{&nbsp; &nbsp; &nbsp; &nbsp; gridLineWidth: 0&nbsp; &nbsp; },&nbsp; &nbsp; yAxis:{&nbsp; &nbsp; &nbsp; &nbsp; gridLineWidth: 0&nbsp; &nbsp; }&nbsp; });});
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript