pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Highcharts (9.0.1): drilldown problem after change chart type dynamically

I'm an highcharts beginner...and this is my problem:
I have a 3 level drilldown chart with the possibility to change graph using buttons.
How should I change the chart type while maintaining the drilldown level and ensuring the following drilldown / drillup functionality?
I have done this:

Code: Select all

chart.update ({
	chart:{
		type: ....
	}
})
https://jsfiddle.net/pcortona/m7rz6kxj/15/

this preserve the drilldown level, but alters the following drilldown / drillup behavior.

can you help me?
Thks
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi,
Thanks for the message.

I don't really understand what's wrong, can you specify or send a screenshot?
When I change chart types everything looks fine.

Here's another way to add a drilldown, asynchronously in the events chart, you might be interested in.
https://api.highcharts.com/highcharts/c ... .drilldown
https://jsfiddle.net/gh/get/library/pur ... own/async/

I'm waiting for news.
Best regards.
Sebastian Hajdus
Highcharts Developer
pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi sebastian,
Thanks for the reply.
I try to be more precise.
1) At level 0 of the drilldown, the serie "Nascite" is displayed with categories 2018 and 2019.
2) I drill down on the column corresponding to 2018
3) change type of chart to pie
4) I drill down on the "USA" slice
5) the graph displayed is not correct, I expected to see a pie only with slices: "Texas" and "California".
Instead, two overlapping pie charts are displayed.

thank you
pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

I am attaching screenshot of the wrong chart:
Attachments
errore_drilldown_dopo_cambio_tipo_chart.png
errore_drilldown_dopo_cambio_tipo_chart.png (37.79 KiB) Viewed 1332 times
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi,
Thanks for the detailed information, it was helpful.

Here is a demo where drilldown is inside chart.events and they have conditions if the options exist, it look useful in your case.
https://jsfiddle.net/cranes/2xop8Lgx/

Let me know how are you going with this.
Best regards.
Sebastian Hajdus
Highcharts Developer
pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi Sebastian,
Thanks for reply.

The problem with the example you are proposing is that when the chart type changes, the drilldown restarts from level 0.
I had already arrived at this solution by creating a "drillUpAll" method like this:

Code: Select all

Highcharts.Chart.prototype.drillUpAll = function () {
  while (this.drilldownLevels && this.drilldownLevels.length > 0) {
      this.drillUp();
  }
};
which I use before the chart.update

Code: Select all

chart.drillUpAll();
    chart.update({
      chart: {
        type: 'pie'
      }
    });
https://jsfiddle.net/pcortona/m7rz6kxj/19/
Resetting the drilldown level solves the wrong chart problem, but that's not what I want. When I change the chart type I would like to preserve the drilldown level.
help me please
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi,
Thanks for the message.

You can try to put drilldown and drillup in the event and give a condition that checks if the chart already exists when changing, then the problem should disappear.

Here's a similar example that you can use as template:
http://jsfiddle.net/1vvvtrv6/

API References:
https://api.highcharts.com/highcharts/c ... .drilldown
https://api.highcharts.com/highcharts/c ... ts.drillup

Best regards.
Sebastian Hajdus
Highcharts Developer
pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi sebastian,
thanks for your attention
I made the changes for the asynchronous validation of the drilldown series: http://jsfiddle.net/pcortona/m7rz6kxj/24/
but no improvements :(

Inserting a third chart type (bar) and performing the 5 test steps I listed last time, with the target type the bar, I see that the last drilldown, before the error, causes the insertion of a new series (as attached file) . How can I delete the pre-existing series?

Thank you very much
Attachments
errore_drilldown_dopo_cambio_tipo_chart_1.PNG
errore_drilldown_dopo_cambio_tipo_chart_1.PNG (18.74 KiB) Viewed 1315 times
pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

NOTE:
If after point 3 of the tests (ddlevel 1) I do a drillUp (ddlevel 0) and then return to ddlevel 1 everything then works fine.
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi pcortona,

I found coulprit, the data in drilldown was write in impropriate way.
They should look like similar to this, without extra title for object:
{
name: 'Nascite 2019',
id: 'Nascite 2019',
data: [{
name: 'USA',
y: 200,
drilldown: 'Nascite 2019 USA'
}]
},

To go deeper drilldown look at animals -> cats.

Demo:
http://jsfiddle.net/BlackLabel/p1dk8Lhy/

Best regards.
Let me know if that was what you were looking for.
Sebastian Hajdus
Highcharts Developer
pcortona
Posts: 10
Joined: Mon Apr 12, 2021 4:46 pm

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi Sebastian,
thanks for your reply,

the link to the previous fiddle refers to the case of asynchronous validation of the drilldown series, for this we need the keys of elements in the "drilldowns" object.
Testing the fiddle you posted I encounter the same problem I reported:
1) drilldown on 'animals'
2) change graphic type to 'pie'
3) drilldown on 'cats'
4) 2 charts are overlapped (see attachment)

:cry:
thanks
Attachments
errore_drilldown_dopo_cambio_tipo_chart_2.PNG
errore_drilldown_dopo_cambio_tipo_chart_2.PNG (23.39 KiB) Viewed 1301 times
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Highcharts (9.0.1): drilldown problem after change chart type dynamically

Hi,
You have right, I tested it and I have the same problem.

You can also try to implement such a solution with chart.options.chart.drilled control like in this example.

Demo:
https://stackblitz.com/edit/angular-khkm2o

Let me know how you are doing
Best regards.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Usage”