我正在用Highcharts库创建图表,我想知道是否可以添加一个按钮在图表和数据表之间切换。我实际上在使用这个图表。也许有人能帮我?
您只需要切换图表和表格容器的显示样式,例如:
document.getElementById('toggle').addEventListener('click', function() {
var chartContainer = chart.renderTo,
dataTable = document.getElementById('datatable');
if (chartContainer.style.display === "none") {
chartContainer.style.display = "block";
dataTable.style.display = "none";
} else {
chartContainer.style.display = "none";
dataTable.style.display = "block";
}
});
现场演示:https://jsfiddle.net/BlackLabel/xnr1uckd/
API参考:https://api.highcharts.com/highcharts/data.table