highcharts drilldown problem

Hi
i need to make highcharts drilldown dynamic, so i am going by the example they give here .
got no problem with the first data: the data for the series, but getting stuck with the data for the drilldown.
i return the correct format like is hand codded in this example but when i try to pass it , it is empty.
so this is what i have:
        chart: {
            renderTo: 'containermain',
            type: 'column',
            events: {
                drilldown: function (e) {
                    if (!e.seriesOptions) {

                        var chart = this,
                        drilldowns = {},
                            series = drilldowns[e.point.name];

                            console.log(drilldowns);

                        // Show the loading label
                        chart.showLoading('Simulating Ajax ...');

                        //make an ajax call to get the drilldowns
                        $.getJSON("functions/madrashi.php?timespan=" + timespan + "&typespan=" + typespan + "&timespantext=" + timespantext + "&typespantext=" + typespantext + "&comparison=" + comparison + "&comparisontext=" + comparisontext, function(data) {
                            console.log(data[5]);
                            options1.chart.events.drilldown.drilldowns = data[5];

                        });

                        setTimeout(function () {
                            chart.hideLoading();
                            chart.addSeriesAsDrilldown(e.point, series);
                        }, 1000);
                    }

                }
            }
        },

Open in new window


but with the hard coded values for the drilldowns it does work:
                            drilldowns = {
                                'IE': {
                                    name: 'IE',
                                    data: [
                                        ['v.11', 25.13],
                                        ['v.8', 15.13],
                                        ['v.7', 45.13]
                                    ]
                                },
                                'Chrome': {
                                    name: 'Chrome',
                                    data: [
                                        ['v.11', 55.13],
                                        ['v.8', 5.13],
                                        ['v.7', 15.13]
                                    ]
                                },
                                'Firefox': {
                                    name: 'Firefox',
                                    data: [
                                        ['v.11', 25.13],
                                        ['v.8', 35.13],
                                        ['v.7', 15.13]
                                    ]
                                }
                            },

Open in new window


when i check the console, and compare the hard coded drilldowns and my data[5], they are the same.

any idea why i cannot pass the data[5] to the drilldowns?
LVL 1
derridaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
hard to reproduce but perhaps it is just a timing issue - hence the data takes longer than the timeout.

Could you try the following?
        chart: {
            renderTo: 'containermain',
            type: 'column',
            events: {
                drilldown: function (e) {
                    if (!e.seriesOptions) {

                        var chart = this,
                        drilldowns = {},
                            series = drilldowns[e.point.name];

                            console.log(drilldowns);

                        // Show the loading label
                        chart.showLoading('Simulating Ajax ...');

                        //make an ajax call to get the drilldowns
                        $.getJSON("functions/madrashi.php?timespan=" + timespan + "&typespan=" + typespan + "&timespantext=" + timespantext + "&typespantext=" + typespantext + "&comparison=" + comparison + "&comparisontext=" + comparisontext, function(data) {
                            console.log(data[5]);
                            options1.chart.events.drilldown.drilldowns = data[5];
							chart.hideLoading();	
                            chart.addSeriesAsDrilldown(e.point, series);
                        });

                    }
				}
            }
        },

Open in new window


Only change has been to eliminate the setTimeout function and placing the code into the getJSON call async handler.

HTH
Rainer
0
derridaAuthor Commented:
Hi
thanks for answering. the result is the same, when i check the drilldowns in the console it is empty, even though data[5] is not. it is bizzare i don't get why i can't pass the results to the drilldowns.
0
derridaAuthor Commented:
i have tried to even send the hard coded to the drilldowns from the ajax call and it comes up emoty. loosing my mind, have no idea what elst to try.

any other idea?
0
hieloCommented:
Within the callback function to $.getJSON, try re-initializing series.  Also, move the setTimeout so that it is within this callback:
        chart: {
            renderTo: 'containermain',
            type: 'column',
            events: {
                drilldown: function (e) {
                    if (!e.seriesOptions) {

                        var chart = this,
                        drilldowns = {},
                            series = drilldowns[e.point.name];

                            console.log(drilldowns);

                        // Show the loading label
                        chart.showLoading('Simulating Ajax ...');

                        //make an ajax call to get the drilldowns
                        $.getJSON("functions/madrashi.php?timespan=" + timespan + "&typespan=" + typespan + "&timespantext=" + timespantext + "&typespantext=" + typespantext + "&comparison=" + comparison + "&comparisontext=" + comparisontext, function(data) {
                            console.log(data[5]);
                            options1.chart.events.drilldown.drilldowns = data[5];
							
							series = data[5];
                            setTimeout(function () {
                                chart.hideLoading();
                                chart.addSeriesAsDrilldown(e.point, series);
                            }, 1000);
							
                        });

                    }

                }
            }
        },

Open in new window

0
derridaAuthor Commented:
well i fixed it and totally forget to bring it here.
so this what worked :
chart.addSeriesAsDrilldown(e.point, data[5][e.point.name]);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.