[英]Highcharts columnrange remove spacing from data in other categories
How would I get rid of the 'invisible' spacing as indicated in the picture? 如何摆脱图片中所示的“不可见”间距?
I intend to use the chart in inverted mode (as a gantt chart), but this shows the gaps more obvious. 我打算在反向模式下使用该图表(作为甘特图),但这显示出差距更加明显。 To be able to play with it: http://jsfiddle.net/j03ceom5/ 为了能够玩它: http : //jsfiddle.net/j03ceom5/
I consired an 'xrange' type but it has the same issue: https://jsfiddle.net/agxu6ffc/ 我考虑了一个'xrange'类型,但是它有同样的问题: https ://jsfiddle.net/agxu6ffc/
-inserting some code snippet to get the jsfiddle links accepted, eventhough it's not necessarily needed to understand the question- -插入一些代码段以接受jsfiddle链接,尽管不一定需要理解该问题-
chart: {
renderTo: 'container',
type: 'columnrange',
inverted:false,
},
You can use workaround which justify columns redraw / load chart event. 您可以使用解决方法来证明列重绘/加载图表事件合理。
var justifyColumns = function (chart) {
var categoriesWidth = chart.plotSizeX / (1 + chart.xAxis[0].max - chart.xAxis[0].min),
distanceBetweenColumns = 0,
each = Highcharts.each,
sum, categories = chart.xAxis[0].categories,
number;
for (var i = 0; i < categories.length; i++) {
sum = 0;
each(chart.series, function (p, k) {
if (p.visible) {
each(p.data, function (ob, j) {
if (ob.category == categories[i]) {
sum++;
}
});
}
});
distanceBetweenColumns = categoriesWidth / (sum + 1);
number = 1;
each(chart.series, function (p, k) {
if (p.visible) {
each(p.data, function (ob, j) {
if (ob.category == categories[i]) {
ob.graphic.element.x.baseVal.value = i * categoriesWidth + distanceBetweenColumns * number - ob.pointWidth / 2;
number++;
}
});
}
});
}
};
http://jsfiddle.net/zmktekak/14/ http://jsfiddle.net/zmktekak/14/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.