Open pthomasjoby opened 2 months ago
See the Highcharts definition:
`
this.chartOptions = {
chart: {
type: "column",
events: {
drilldown: function (e) {
componentContext.prepareDrilldownData(e.point.series.name);
componentContext.isDrilldown = true;
this.addAxis(componentContext.yearMonths);
componentContext.chartName = "Expense by Expenditure Type";
this.hideLoading();
for (let i = 0; i < componentContext.chartExpTypesCurrent.length; i++) {
// console.log(componentContext.chartExpTypesCurrent[i]);
// THIS IS WHERE THE ERROR HAPPENS
// ERROR WHEN THE SECOND TIME THE FOLLOWING CODE EXECUTES.
this.addSeriesAsDrilldown(e.point, componentContext.chartExpTypesCurrent[i]);
}
highChartContext = this;
this.setTitle({ text: componentContext.chartName });
},
drillup: function (e) {
componentContext.isDrilldown = false;
componentContext.chartName = "Monthly Expense by Expenditure Category";
this.setTitle({ text: componentContext.chartName });
}
},
zoomType: "x",
panKey: "shift",
},
title: {
text: "Expense Title",
},
xAxis: {
categories: this.yearMonths,
},
yAxis: {
title: {
text: "Dollars",
},
stackLabels: {
enabled: true,
style: {
fontWeight: "bold",
color:
(Highcharts.defaultOptions.title.style &&
Highcharts.defaultOptions.title.style.color) ||
"black",
},
formatter: function () {
return Math.round(this.total).toLocaleString();
},
},
},
legend: {
align: "center",
x: -30,
verticalAlign: "bottom",
y: 15,
floating: false,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || "white",
borderColor: "#CCC",
borderWidth: 1,
shadow: false,
},
tooltip: {
headerFormat: "{point.x}
",
pointFormat:
'● {series.name}: {point.y:,.0f}
● Total: {point.stackTotal:,.0f}',
style: {
color: "black",
},
valueDecimals: 0,
},
plotOptions: {
column: {
stacking: "normal",
events: {
legendItemClick: () => {
// console.log("Clicked...");
this.zone.run(() => {
this.selection = "Selection";
});
},
},
},
},
series: this.chartExpCats as Highcharts.SeriesOptionsType[],
};
`
Hi @pthomasjoby! There are a few things missing and I'm not able to recreate it. Could you please update the demo with your config so I can work on it?
@karolkolodziej I have tried to create the stackblitz based on my component with the stack that you had created for me (https://stackblitz.com/edit/highcharts-angular-line-u8rfrs):
Angular 16, "highcharts": "^11.2.0", "highcharts-angular": "^4.0.0". Please click on the Load Data button at the top of the page to load the data.
For some reason the drilldown does not work (click event is not registering). Also, error (Property 'addSeriesAsDrilldown' does not exist on type 'Chart'.) is shown when trying to add the following line within the drilldown event:
this.addSeriesAsDrilldown(e.point, componentContext.chartExpTypesCurrent[i]);
Please note, I am in the version
Angular 16 "highcharts": "^9.3.3", "highcharts-angular": "^3.1.2"
It worked like a charm in the following version:
Angular 13 "highcharts": "^6.2.0", "highcharts-angular": "^2.10.0"
I simplified your demo and it turned out that you are not using highcharts-angular
package.
Nevertheless, I cannot see any error when clicking the point.
See the demo.
@karolkolodziej Thank you for refactoring the code. I have updated the dataset to add one more sub series to the top series "54000 INTERDEPARTMENTAL". They are "54051 User Credits" and "54051 User Credits1". So, when you click on the top series "54000 INTERDEPARTMENTAL" the chart should drilldown to another stacked column with two series "54051 User Credits" and "54051 User Credits1". However the second series is failed to add. See the attached video and the code - https://stackblitz.com/edit/highcharts-angular-line-4m6yxp
@karolkolodziej This functionality worked like a charm in the following version:
@pthomasjoby I checked that with 6.2.0 and it works the same. Also there is a lot of custom code and it's difficult for me to go through it.
Please ensure you use the correct series in the addSeriesAsDrilldown
method.
If possible please simplify it and recreate without Angular, you can start from the demo.
@karolkolodziej I have recreated the issue based on your template: https://jsfiddle.net/jobythomas/Lwam849t/83/ When you click on 'Animals', it is only adding 'Elephant' series and does not add 'Horse Series'. Same with 'Birds' series.
Your data isn't declared properly, there should be only one series for each category (animals and fruits) and the data
inside it should contain all the points- see demo.
drilldowns = {
Animals: {
name: 'Animals',
data: [
['Cows', 2],
['Sheep', 3]
]
},
Fruits: {
name: 'Fruits',
data: [
['Apples', 5],
['Oranges', 7],
]
},
},
@karolkolodziej well, my need is to have multiple series in each category. Having the ability to call multiple times "addSeriesAsDrilldown()" enabled this functionality in version (Angular 13, highcharts: "^6.2.0", highcharts-angular: "^2.10.0"). When upgraded the ability to add multiple series was blocked thus causing this regression (functionally). I dont know what goes into the code, but I lost a key functionality with this upgrade (Angular 16 "highcharts": "^9.3.3", "highcharts-angular": "^3.1.2")
@karolkolodziej I am using this for timeseries chart (y-axis is time) with drilldown (Category [multiple] >> Types [multiple]). The application is broken after the upgrade.
I'm not sure if I follow your use case. Could you please create a working demo with the version of Highcharts that works? I'll check what has changed and if we can work around it.
Describe the bug
As part of the Angular tech stack upgrade, due to dependency to Ivy, I was forced to upgrade the Highcharts and Highcharts-Angular as follows: highcharts: 6.2.0 >> 9.3.3 highcharts-angular: 2.10.0 >> 3.1.2 This resulted in a bug which does not allow calling addSeriesAsDrilldown() multiple times in a look. It worked in the previous version.
Expected behavior
Expected the drill down continue to work with multiple series.
Demo
Please provide live demo of the problem or provide any other way to recreate the problem.
Steps required to recreate the problem in the demo:
Setup used