【发布时间】:2020-10-16 10:11:49
【问题描述】:
Highcharts.chart('container', {
chart: {
type: 'arearange',
zoomType: 'x',
scrollablePlotArea: {
minWidth: 600,
scrollPositionX: 1
}
},
title: {
text: 'Temperature variation by day'
},
xAxis: {
//type: 'datetime',
accessibility: {
rangeDescription: 'Range: Jan 1st 2017 to Dec 31 2017.'
}
},
yAxis: {
title: {
text: null
},
labels: {
enabled:true
}
},
plotOptions: {
arearange: {
dataLabels: {
enabled: true,
yLow: 5,
verticalAlign: 'bottom',
inside: true,
color: 'black',
formatter: function(e) {
if((this.x==0) && (this.point.low==this.y))
return this.series.name
}
}
}
},
legend: {
enabled: false
},
series: [{
name: "AREA 1",
data: [
[0, 10],
[0, 10],
],
borderColor: 'black',
borderWidth: 0.2,
},
{
name: "AREA 2",
data: [
[20, 40],
[20, 40],
]
}]
});
以上是我使用 arearange 图表绘制的示例代码。正如我想要的那样,该图已成功绘制。但是好像有问题。我希望系列名称“AREA1”和“AREA2”显示在各自 y 轴值的中点。即“区域 1”应显示在 5(0 和 10 的中点),“区域 2”应显示在 30(20 和 40 的中点)。有没有办法做到这一点?我尝试在 plotOptions 中指定 yLow 值。但它对我不起作用,因为系列数据是动态的。
我使用的图表是 highcharts,版本是 4.1.5
请帮忙!!提前致谢
【问题讨论】:
标签: javascript php jquery charts highcharts