【发布时间】:2018-11-16 10:10:25
【问题描述】:
我已经创建了一个 highcharts 堆积条形图,但是当数据倾斜时,条形不可见或数字重叠,如下图所示。
我看过很多帖子,但没有现成的解决方案,所以我正在制作我的自定义解决方案。
如果 y 值小于 150,我将默认高度设置为 150。
此解决方案有效,但现在显示的条形总数为 300,而不是实际的原始值。如何自行更改总堆栈标签值?我找不到这样做的方法。
这是将高度更改为默认值的代码。我将实际值存储在点对象的 realValue 变量中。
chartOptions = {
type: CHARTING.CHART_OPTIONS.TYPE.COLUMN,
// On chart load, apply custom logic
events : {
load: function () {
var chart = this,
minColHeightVal = 150;
chart.series.forEach(function (s) {
s.points.forEach(function (p) {
if (p.y < minColHeightVal) {
p.update({
y: minColHeightVal,
realValue: p.y
}, false);
}
});
});
// How to iterate over the bars here and sum the actual value? i.e. point.realValue and set the stacklabel?
chart.redraw();
}
}
}
【问题讨论】:
标签: javascript charts highcharts bar-chart