Table of Contents
The Deprecation of getChartFromId Function
getChartFromId had to be deprecated.
var chartObj = new FusionCharts(...) and later write somewhere else
var myChart = getChartFromId(...), the values of the two variables
myChart are not the same.
Currently Recommended Ways to Access a Chart Using Its ID
As of FusionCharts 3.2 and above, the alternative to
getChartFromId is the
Whenever a new chart is created, a reference to it is kept within the
FusionCharts.items object. Consequently, if your original code was
var myChart = getChartFromId("my-chart-id"), it can now be achieved using
var myChart = FusionCharts.items["my-chart-id"].
Another alternate is to access the
FusionCharts() function itself:
var myChart = FusionCharts("my-chart-id"). Note the absence of the new keyword. While creating a new chart, we write
new FusionCharts(...), but for accessing an already created chart, we drop the new keyword and simply pass the chart’s id as parameter. Ain’t it cool!?
Providing JSON Data Format support proved to be more of a nomenclature challenge than a technological one!
setDataURL functions were conceived when JSON as a information exchange format was in its neonatal stage. Now when we were adding JSON support, what could we name the corresponding data-setting functions as? setJSONData could have been fine had the name setDataURL been a bit more accommodative. Imagine setDataURLJSON or setJSONDataURL!
Thus, we had to deprecate
setDataURL to give way for function names that would be format-independent. By format-independent we mean that the function names should have such a pattern that in case any new format comes up, naming it should not be challenging.
Setting Data For Various FusionCharts Data Formats
setDataURL functions got replaced using
setXMLUrl respectively. And from that, guessing the JSON functions as
setJSONUrl is apparently not challenging at all.
We also introduced a couple of more multi-tasking data-setting functions namely:
setChartDataUrl. These functions take up two parameters: first is the source data and second is the format specification of the source. Head over to the documentation to know more.
Getting back to the point: simply replacing
setXMLUrl is all you need to do to get going.
There Was Once an addVariable Function
Passing FlashVars To Charts The Correct Way
In FusionCharts 3.2, the basic chart configurations sent using FlashVars can be passed during construction of a new FusionCharts. However, extended FlashVars (like “Chart Messages”) can be passed using the
configure() function available since FusionCharts 3.2.0.
If your application already has
.addVariable(), simply replace it with
Summary of the Deprecated Methods
To quickly summarize, here is the list of deprecated methods discussed above.
|Deprecated Method||Alternative Implementation|
|addVariable(key, value)||configure(key, value)|
This is our story of how the fittest survived in this never-ending war to become more powerful, useful and, for this case, more programmable!