gpt4 book ai didi

highcharts - 如何在具有多个系列的列 Highcharts 中隐藏空列

转载 作者:行者123 更新时间:2023-12-02 04:50:52 24 4
gpt4 key购买 nike

我有多个系列要在柱形图中呈现,但某些柱的值为零,并且图表为空柱留出了空间。在这个例子中,如何隐藏/删除空列,例如 Category 2 on 15 Jun:JSFILLDE

$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
type: 'datetime',
},
yAxis: {
min: 0,
title: {
text: 'Testing'
}
},
series: [{
name: 'Category I',
data: [
[Date.UTC(2014, 5, 14), 20],
[Date.UTC(2014, 5, 15), 30],
[Date.UTC(2014, 5, 16), 25],
[Date.UTC(2014, 5, 19), 10],
[Date.UTC(2014, 5, 20), 15]
]
}, {
name: 'Category II',
data: [
[Date.UTC(2014, 5, 14), 25],
//[Date.UTC(2014, 5, 15), 10],
[Date.UTC(2014, 5, 16), 35],
[Date.UTC(2014, 5, 19), 25],
[Date.UTC(2014, 5, 20), 5]
]
}, {
name: 'Category III',
data: [
[Date.UTC(2014, 5, 14), 10],
[Date.UTC(2014, 5, 15), 20],
[Date.UTC(2014, 5, 16), 35],
//[Date.UTC(2014, 5, 19), 25],
[Date.UTC(2014, 5, 20), 15]
]
}]
});

最佳答案

您可以尝试使用stacking 并在series 中使用stack 进行一些操作,但您的图 TableView 会发生变化。

$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked bar chart'
},
xAxis: {
type: 'datetime',
},
yAxis: {
min: 0,
title: {
text: 'Testing'
}
},
plotOptions : {
column: {
stacking: 'normal'
}
},
series: [{
name: 'Category I',
data: [
[Date.UTC(2014, 5, 14), 20],
[Date.UTC(2014, 5, 15), 30],
[Date.UTC(2014, 5, 16), 25],
[Date.UTC(2014, 5, 19), 10],
[Date.UTC(2014, 5, 20), 15]
],
stack : 0
}, {
name: 'Category II',
data: [
[Date.UTC(2014, 5, 14), 25],
//[Date.UTC(2014, 5, 15), 10],
[Date.UTC(2014, 5, 16), 35],
[Date.UTC(2014, 5, 19), 25],
[Date.UTC(2014, 5, 20), 5]
],
stack : 0
}, {
name: 'Category III',
data: [
[Date.UTC(2014, 5, 14), 10],
[Date.UTC(2014, 5, 15), 20],
[Date.UTC(2014, 5, 16), 35],
//[Date.UTC(2014, 5, 19), 25],
[Date.UTC(2014, 5, 20), 15]
],
stack : 2
}]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

关于highcharts - 如何在具有多个系列的列 Highcharts 中隐藏空列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28492624/

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