javascript - Highcharts - 强制区域步长系列在 x 轴的开头和结尾重叠列系列
问题描述
代码笔: https ://codepen.io/Lothain/pen/GRjBOyw
chart: {
type: 'column'
},
title: {
text: 'Job Billings By Month'
},
xAxis: {
categories: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec',]
},
yAxis: {
min: 0,
title: {
text: 'Cost in USD'
}
},
legend: {
reversed: true
},
plotOptions: {
series: {
stacking: 'normal'
},
area: {
marker: {
enabled: false
},
lineColor: 'rgb(205,70,43)',
fillColor: 'rgb(240,198,189)'
}
},
series: [{
name: 'T&M',
data: [5, 3, 4, 7, 2, 4, 2, 5, 2, 8, 11, 3],
color: 'rgb(208,224,227)'
}, {
name: 'Workorder',
data: [2, 2, 3, 2, 1, 3, 4, 4, 2, 5, 4, 2],
color: 'rgb(207,226,243)'
}, {
name: 'Change Order',
data: [3, 4, 4, 2, 5, 4, 2, 5, 2, 8, 8, 2],
color: 'rgb(201,218,248)'
}, {
name: 'Main Contract',
data: [3, 4, 4, 2, 5, 2, 8, 11, 3, 4, 8, 3],
color: 'rgb(164,194,244)'
}, {
name: 'Projected Billed',
type: 'line',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
color: 'rgb(255,109,1)'
}, {
name: 'Cost',
type: 'area',
step: 'center',
color: 'red',
opacity: .5,
data: [4,4, 5, 3, 1, 4, 7, 5, 3, 2, 5, 9]
}]
});
目标:https ://imgur.com/a/Vo7ORj7
我希望阶梯区域系列延伸到 x 轴的边缘,而不是在它们重叠的列的中间结束。我确信这是可能的,但我不知道如何;我尝试使用 series.type.area.step 选项(中心、左、右)无济于事。
解决方案
您可以再添加一个area
与当前数据具有相同数据的系列,但也可以使用以下选项:
series: [..., {
name: 'Cost',
type: 'area',
step: 'center',
color: 'red',
lineWidth: 0,
zIndex: -1,
data: [4000, 4000, 5000, 3000, 1000, 4000, 7000, 5000, 3000, 2000, 5000, 9000]
}, {
linkedTo: ':previous',
stacking: false,
type: 'area',
step: 'center',
color: 'red',
fillColor: 'transparent',
data: [4000, 4000, 5000, 3000, 1000, 4000, 7000, 5000, 3000, 2000, 5000, 9000]
}]
现场演示:http: //jsfiddle.net/BlackLabel/m6gsrn8o/
推荐阅读
- java - 如何设置像 WhatsApp 语音笔记(recyclerview)这样的媒体播放器?
- django - 如何配置 django 以使用 Google Cloud CDN 为媒体文件生成签名 url?
- mongodb - MongoDB中文档引用关系的Mongoose实现
- kendo-ui - 在剑道网格过滤器选项中加载大量数据
- javascript - 当只有一页时想要动态隐藏信息
- ios - 回复按钮导致崩溃
- android - DiffUtil.Callback 未按预期工作
- swift - UIAccessibilityTrait 可调整不输入 increment() 或 decrement() swift
- java - 将 Java 网站部署到 AWS Elastic Beanstalk
- node.js - 即使所有数据都通过 HTTPS 提供,AWS 证书也“不安全”