Gregor
Posts: 10
Joined: Wed Jul 13, 2011 1:02 pm
Contact: Website

creating a chart manipulates external options object

In Version 2.2.0 creating a "Chart" object manipulates the external options object!

Code: Select all

5120 function Chart(options, callback) {
5121
5122      // Handle regular options
5123	     var seriesOptions = options.series; // skip merging data points to increase performance
5124	     options.series = null;
5125	     options = merge(defaultOptions, options); // do the merge
5126     options.series = seriesOptions; // set back the series data
- line 5124 "deletes" the series information from the original options object
- line 5125 creates a new options object (merge creates a new object)
- line 5126 will set the series data at the new object

=> the series data from the original object is gone.....
hfrntt
Posts: 6393
Joined: Mon Aug 30, 2010 8:41 am
Contact: Website

Re: creating a chart manipulates external options object

It works in highstock for a bit of time now. If you take a look one line above (5123), you can read about the reason of this behavior - performance issue.
Slawek Kolodziej
Highcharts support team
Gregor
Posts: 10
Joined: Wed Jul 13, 2011 1:02 pm
Contact: Website

Re: creating a chart manipulates external options object

Yes, i understand the reason.
But (IMHO) manipulating the external objects is a very bad idea.

To work around this "performance fix" i have to clone my options object ...
=> I have a perfomance drop and not aperformance boost.
Gregor
Posts: 10
Joined: Wed Jul 13, 2011 1:02 pm
Contact: Website

Re: creating a chart manipulates external options object

Nice, in the current release this problem is fixed.

Thanks !!
juliek
Posts: 16
Joined: Tue Jun 26, 2012 1:08 am

Re: creating a chart manipulates external options object

I'm having this same problem using the latest version of highstocks. After I pass my options object to Highcharts.chart, the series information in the original object becomes null.
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: creating a chart manipulates external options object

If you need your data for future reference, pass copy of this data to the options object.
Paweł Fus
Highcharts Developer

Return to “Highcharts Stock”