Skip to content
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

bugfix/16135-drillup-category-axis #16796

Merged
merged 4 commits into from Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions samples/unit-tests/drilldown/drillup/demo.js
Expand Up @@ -362,3 +362,57 @@ QUnit.test('Multi-level drilldown gets mixed (#3579)', function (assert) {
'The legend is not showing right information'
);
});

QUnit.test(
'Drilldown on the chart with category axis and cropThreshold set, #16135.',
function (assert) {
const chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
xAxis: {
type: 'category'
},
series: [{
keys: ['name', 'y', 'drilldown'],
cropThreshold: 5,
data: [
['A-0', 0, 'DrillSeries'],
['A-1', 1, 'DrillSeries'],
['A-2', 2, 'DrillSeries'],
['A-3', 3, 'DrillSeries'],
['A-4', 4, 'DrillSeries'],
['A-5', 5, 'DrillSeries'],
['A-6', 6, 'DrillSeries'],
['A-7', 7, 'DrillSeries'],
['A-8', 8, 'DrillSeries'],
['A-9', 9, 'DrillSeries']
]
}],
drilldown: {
drilldown: {
breadcrumbs: {
showFullPath: false
},
series: [{
data: [
['x-0', 1],
['x-1', 2],
['x-2', 3]
],
name: 'DrillSeries',
id: 'DrillSeries'
}]
}
}
});

chart.series[0].points[1].doDrilldown();
chart.drillUp();
assert.strictEqual(
chart.series[0].xData[chart.series[0].xData.length - 1],
9,
`After drilling down and up on the chart with the category axis
the main series should go back to its original state.`
);
});
11 changes: 11 additions & 0 deletions ts/Extensions/Drilldown.ts
Expand Up @@ -988,6 +988,7 @@ Chart.prototype.drillUp = function (): void {
newSeries = addedSeries;
}
};
const drilldownLevelsNumber = (chart.drilldownLevels as any).length;

while (i--) {

Expand All @@ -1013,6 +1014,16 @@ Chart.prototype.drillUp = function (): void {
}
oldSeries.xData = []; // Overcome problems with minRange (#2898)

// Reset the names to start new series from the beginning.
// Do it once to preserve names when multiple
// series are added for the same axis, #16135.
if (oldSeries.xAxis &&
oldSeries.xAxis.names &&
(drilldownLevelsNumber === 0 || i === drilldownLevelsNumber)
) {
oldSeries.xAxis.names.length = 0;
}

level.levelSeriesOptions.forEach(addSeries);

fireEvent(chart, 'drillup', {
Expand Down