javascript - 在 highCharts 中,当对数据使用索引时,每个类别都留有很多空间
问题描述
我是 HighCharts 的新手;在我们的项目中,我们使用下面的代码,我们在其中给出索引值和数据(我将无法发布实际代码)
data.push([indx,getRandomInt(50)]);
splitSeries[i].push({
"name" : optionData.series[m].name,
"data" : data
});
但是我们面临两个问题
如何解决这些问题,请帮忙。
解决方案
我不确定我是否正确理解了您的问题,但@ppotaczek 的上述回答对我来说似乎没问题。
请在fiddle上参考这个工作示例演示。
在这里,我添加gridLineWidth: 1
并tickmarkPlacement: "between"
证明滴答声实际上是从中间传递的。
正如@ppotaczek 所说:您可以通过更改pointPadding
和groupPadding
属性来更改点之间的距离。
请让我知道,如果这对你有用!:)
由于指向 fiddle.net 的链接必须附有代码,因此我将其包括在此处:
$(function() {
$('#container').highcharts({
chart: {
type: 'column',
inverted: true,
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['2018-06', '2018-07', '2018-08', '2018-09', '2018-10'],
tickWidth: 1,
tickmarkPlacement: "between",
gridLineWidth: 1
},
yAxis: {
min: -10,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold'
}
}
},
legend: {
enabled :false,
align: 'right',
x: -70,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
series: {
groupPadding: 0.99,
pointPadding: 0.99
}
},
series: [{
name: 'Q1',
data: [
[0, -5],
[1, 3],
[2, 4],
[3, 7],
[4, -2]
]
}, {
name: 'Q2',
data: [
[0, 5],
[1, -3],
[2, 4],
[3, -7],
[4, 2]
]
}, {
name: 'Q3',
data: [
[1, 3],
[1, -4],
[2, 7],
[4, 2]
]
}]
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/broken-axis.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
推荐阅读
- javascript - 如何在特定位置用破折号分割字符串 JavaScript
- python - 在画布上擦笔
- haskell - 在特定的 stack.yaml 文件上调用 stack 命令
- android - Google Cloud Vision 在 android studio 中生成重复文件
- c# - 实体框架 5.0 与 vs 13
- javascript - ng-repeat track by $index 如果相似的键在 angularjs 中多次存在,则仅显示一次该项目
- c# - 将数据库上下文注入 Hangfire Recurring 作业的正确方法是什么?
- python - 使用 Python 从 xml 文件中提取数据并写入 xlsxwriter
- c# - c#脚本Sharepoint API在远程服务器上给出401错误
- laravel - Laravel Nova – 从观察者类手动发送错误警报