-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
centerInCategory leaves enough space for all of the x values, but does not take into consideration that the columns with the same x value are stacked #17610
Comments
Hi @vitaliy-kretsul, thank you for reporting the issue and the late reply. I agree, this is a bug. Simplified demo: https://jsfiddle.net/BlackLabel/mr32L9n6/ (with |
@raf18seb Thanks for your reply. Any hope for a temporary workaround? |
@vitaliy-kretsul, |
@raf18seb |
We decided to take a closer look at it. Can't promise anything, but there's a big chance a fix for this bug will be added to the core with the next release (10.2.2 or 10.3.0). |
Edit (the previous solution had a bug, thanks @hubertkozik!) (function(H) {
H.seriesTypes.column.prototype.adjustForMissingColumns = function(
x,
pointWidth,
point,
metrics
) {
const stacking = this.options.stacking;
if (!point.isNull && metrics.columnCount > 1) {
const reversedStacks = this.yAxis.options.reversedStacks;
let indexInCategory = 0,
totalInCategory = reversedStacks ? 0 : -metrics.columnCount;
// Loop over all the stacks on the Y axis. When stacking is enabled,
// these are real point stacks. When stacking is not enabled, but
// `centerInCategory` is true, there is one stack handling the
// grouping of points in each category. This is done in the
// `setGroupedPoints` function.
H.objectEach(
this.yAxis.stacking && this.yAxis.stacking.stacks,
(stack) => {
if (typeof point.x === 'number') {
const stackItem = stack[point.x.toString()];
if (stackItem) {
// In case of multiple points with the same X,
// get the first point
const key = [
this.index,
point.x,
0
].join(','),
pointValues = stackItem.points[key];
// If true `stacking` is enabled, count the total
// number of non-null stacks in the category, and
// note which index this point is within those
// stacks.
if (stacking) {
if (pointValues) {
indexInCategory = totalInCategory;
}
if (stackItem.hasValidPoints) {
reversedStacks ? // #16169
totalInCategory++ : totalInCategory--;
}
// If `stacking` is not enabled, look for the index
// and total of the `group` stack.
} else if (H.isArray(pointValues)) {
// If there are multiple stacks with the same X
// reduce position by previous series max value:
let seriesIndexes = Object
.keys(stackItem.points)
.filter((pointKey) =>
// Filter out duplicate X's
!pointKey.match(',') &&
// Filter out null points
stackItem.points[pointKey] &&
stackItem.points[pointKey].length > 1
)
.map(parseFloat)
.sort((a, b) => b - a);
console.log(
seriesIndexes,
seriesIndexes.indexOf(this.index)
);
indexInCategory = seriesIndexes.indexOf(this.index);
totalInCategory = seriesIndexes.length;
}
}
}
}
);
// Compute the adjusted x position
const boxWidth = (totalInCategory - 1) * metrics.paddedWidth +
pointWidth;
x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
indexInCategory * metrics.paddedWidth;
}
return x;
}
})(Highcharts); The same solution will be used in core. |
…ry-duplicate-xs Fixed #17610, centerInCategory and duplicated x's.
Prerequisites
Column chart with
grouping: true
andcenterInCategory: true
and series containing multiple points for same x value. Columns for repeated x values are displayed overlaying each other.Expected behaviour
Overlaying columns displayed with the same 'normal' distance to neighbouring columns as between any other regular columns.
Actual behaviour
Instead overlaying columns are rendered with empty space, enough for all repeating x values be displayed separately, without taking into account that the columns with the same x value are stacked.
Live demo with steps to reproduce
https://jsfiddle.net/Cortez/h85dgapz/
Product version
Highcharts 10.2.0
Affected browser(s)
Google Chrome 104.0.5112.79
Additional
Related forum discussion:
https://www.highcharts.com/forum/viewtopic.php?t=49260
The text was updated successfully, but these errors were encountered: