javascript - highcharts 多列图表不显示
问题描述
我想显示我遵循此示例https://www.highcharts.com/demo/column-basic的 highcharts 类型列 ,在我的案例中,数据是从数据库中获取的
var id = $("input[id='id1']:checked").val();
getAjaxData(id);
//});
var opt = {
chart: {
renderTo: 'container4',
type: 'column'
},
title: {
text: 'abc',
x: -20 //center
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Millions'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>:<b>{point.y}</b> of total<br/>'
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y}'
}
}
},
legend: {
itemStyle: {
fontSize:'10px'
},
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
series: []
};
function getAjaxData(id) {
$.getJSON("file.php", {id: id},function(json) {
opt.xAxis.categories = json[0]['data'];
opt.series[0] = json[1];
opt.series[1] = json[2];
chart = new Highcharts.Chart(opt);
});
}
我想显示两列。但这里只显示一列。如果显示的列已关闭,则显示其他显示。显示或php文件有问题吗?如果是我也会提供
解决方案
推荐阅读
- svelte - 如何获得 Svelte 组件名称?
- mysql - 合并两个表列而不进行连接查询
- javascript - 多个组件状态的反应钩子没有更新
- cypress - 在柏树中编辑 html
- python - django 模型中的用户输入和文本选择
- svelte - 如何从 SvelteKit 中的端点获取主机名?
- kubernetes - 同一个 PersistentVolume 'pv' 可以绑定到不同命名空间中的多个 PersistentVolumeClaims 'pvc' 吗?
- mysql - mysql中2个表之间的减法
- laravel - Laravel artisan 迁移命令行和 Artisan::call 之间的差异
- react-native - Lottie Animation - 反应本机应用程序上未显示颜色