gpt4 book ai didi

javascript - Highcharts : How to add or remove "chart context menu" from chart container?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:08:38 26 4
gpt4 key购买 nike

this 中是否有我可以用来删除图表上下文菜单(右侧看起来像汉堡菜单)的任何属性?使用 javascript 的柱形图?

highchart默认有这个选项吗?我也有一个折线图,但默认情况下没有图表上下文菜单。另外,如果我想向该折线图添加图表上下文菜单,我该怎么做?

Highcharts.chart('container', {
chart: {
type: 'column',
events: {
load: function() {
var series = this.series[0];
setInterval(function() {
newValue = Math.random() * 100;
series.update({
data: [newValue],
}, true)
}, 1000);
}
}
},
title: {
text: 'Monthly Average Rainfall'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Jan'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Rainfall (mm)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Tokyo',
data: [49.9]

}, {
name: 'New York',
data: [83.6]

}, {
name: 'London',
data: [48.9]

}, {
name: 'Berlin',
data: [42.4]

}]
});

最佳答案

只包含 <script src="https://code.highcharts.com/modules/exporting.js"></script>

您可以通过添加 buttonOptions 来启用或禁用它.默认为 true

Highcharts.chart('container', {
navigation: {
buttonOptions: {
enabled: true
}
}
});

Highcharts.chart('container', {
chart: {
type: 'column',
events: {
load: function() {
var series = this.series[0];
setInterval(function() {
newValue = Math.random() * 100;
series.update({
data: [newValue],
}, true)
}, 1000);
}
}
},
title: {
text: 'Monthly Average Rainfall'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Jan'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Rainfall (mm)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Tokyo',
data: [49.9]

}, {
name: 'New York',
data: [83.6]

}, {
name: 'London',
data: [48.9]

}, {
name: 'Berlin',
data: [42.4]

}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="height: 400px; margin-top: 1em"></div>

关于javascript - Highcharts : How to add or remove "chart context menu" from chart container?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55197592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com