highcharts - Highcharts:条形柱在x轴上以统一的方式对齐
问题描述
上图是由我使用下面给出的选项生成的:
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Browser market shares. January, 2018'
},
subtitle: {
text: 'Click the columns to view versions. Source: <a href="http://statcounter.com" target="_blank">statcounter.com</a>'
},
accessibility: {
announceNewData: {
enabled: true
}
},
xAxis: {
type: 'category'
},
yAxis: {
title: {
text: 'Total percent market share'
}
},
legend: {
enabled: false
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true,
format: '{point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [
{name: "Data A", data: [4], _colorIndex: 0},
{name: "Data B", data: [7], _colorIndex: 1},
{name: "Data C", data: [9], _colorIndex: 2},
{name: "Data D", data: [19], _colorIndex: 3}
]
});
目前,问题是生成的列自动堆叠在中间。我的要求是,它必须从头到尾沿 x 轴均匀分布。有什么可用的选项吗?任何帮助将不胜感激。
解决方案
您可以通过将所有列呈现为一个系列的数据(而不是将每个点作为单独的系列)来实现此效果。
series: [{
name: '',
data: [{
name: "Data A",
y: 4
}, {
name: "Data B",
y: 7
}, {
name: "Data C",
y: 9
}, {
name: "Data D",
y: 19
}],
colorByPoint: true
}]
推荐阅读
- npm - 等待 husky commit-msg hook 完全完成并运行 Enquirer
- ruby-on-rails - Amazon ECS docker 日志从一开始就将日志配置设置为默认值
- c# - Asp.Net(旧):不支持请求的安全协议
- javascript - 如何迭代循环并从重复中返回原始数据值
- node.js - Nodejs - 如何跟踪错误?
- colors - 暗模式下的颜色不如预期
- docker - Elasticsearch - 当我在 Mac 上使用 Docker 启动 Metricbeat 时,没有创建新索引
- mongodb - MongoDB 3.4 版字符串数字排序与聚合
- linux-kernel - 如何让 iptables 匹配“ipv4options”在 yocto sumo 中工作?
- ios - 如何在我的 iOS 应用程序中处理暗模式的黑色内容图像?