Pallav

FusionCharts Javascript bug

Recommended Posts

After a lot of debugging, I have found that FusionCharts needs some strings double escaped.

 

I am not sure if this is Javascript and/or Browser bug and/or Fusion Flash implementation.

 

 

 

As string like this:

 

http://helpdesk/Search/Chart.html?Order=DESC&Query=+Owner+

 

%3D+%27Nobody%27+AND+%28+Status+%3D+%27new%27+OR+

 

Status+%3D+%27open%27%29+AND+Queue+%3D+%27TSE%27&

 

Rows=20&OrderBy=Created&Format=%27%3Ca+href%3D%22%2FTicket

 

%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%

 

2FTITLE%3A%23%27%2C+%27%3Ca+href%3D%22%2FTicket%

 

2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa

 

%3E%2FTITLE%3ASubject%27%2C+QueueName%2C+ExtendedStatus

 

%2C+CreatedRelative%2C+%27%3CA+HREF%3D%22%2FTicket%

 

2FDisplay.html%3FAction%3DTake%26id%3D__id__%22%3ETake%

 

3C%2Fa%3E%2FTITLE%3A%26nbsp%3B%27+&PrimaryGroupBy=

 

Status&ChartStyle=bar

 

 

 

Needs to be escaped two times in the process of passing the string to FustionCharts.

 

 

 

 

 

 

function draw_chart(type,webpath,query,w,h,debug)

 

{

 

webpath = "http://helpdesk/Search/Chart.html?";

 

query="Order=DESC&Query=+Owner+%3D+%27Nobody%27+AND+%28+Status+%3D+%27new%27+OR+Status+%3D+%27open%27%29+AND+Queue+%3D+%27TSE%27&Rows=20&OrderBy=Created&Format=%27%3Ca+href%3D%22%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%2FTITLE%3A%23%27%2C+%27%3Ca+href%3D%22%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa%3E%2FTITLE%3ASubject%27%2C+QueueName%2C+ExtendedStatus%2C+CreatedRelative%2C+%27%3CA+HREF%3D%22%2FTicket%2FDisplay.html%3FAction%3DTake%26id%3D__id__%22%3ETake%3C%2Fa%3E%2FTITLE%3A%26nbsp%3B%27+&PrimaryGroupBy=Status&ChartStyle=bar

 

";

 

var width = 800, height = 560; //set default

 

if(w != undefined) {

 

width = w; //overide

 

}

 

if(h != undefined) {

 

height = h;

 

}

 

var chart1 = new FusionCharts(type, "RTDynamicChart", width, height, debug, "0");

 

chart1.setDataURL( webpath + escape(escape(query)) );

 

chart1.render("fusion_chart");

 

}

 

Share this post


Link to post
Share on other sites

I have posted the solution to complected string like the example above.

 

Escaping the string once gives invalid data error, something to point of try escaping the string.

Share this post


Link to post
Share on other sites

Not sure why the content would make any difference, the string when passing it to the Javascript is the problem.

 

 

 

 

 

[text]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[/text]

 

I can't get the text for the XML to printout, do we have a tag available like verbatim or code in the Forumns?

 

 

 

 

 

Here is my Javascript:

 

function draw_chart(type,webpath,query,w,h,debug)

 

{

 

var width = 800, height = 560;

 

try {

 

if(w != undefined) {

 

width = w;

 

}

 

if(h != undefined) {

 

height = h;

 

}

 

//var chart1 = new FusionCharts("/NoAuth/charts/Column3D.swf", "RTDynamicChart", width, height, debug, "0");

 

var chart1 = new FusionCharts(type, "RTDynamicChart", width, height, debug, "0");

 

chart1.setDataURL( webpath + escape(escape(query)) );

 

chart1.render("fusion_chart");

 

} catch(e) {

 

alert("ERROR: " + e);

 

}

 

}

Edited by Guest

Share this post


Link to post
Share on other sites

Here is the debug window when I only escape once:

 

 

 

Info: Chart loaded and initialized.

 

Initial Width: 800

 

Initial Height: 560

 

Scale Mode: noScale

 

Debug Mode: Yes

 

Application Message Language: EN

 

Version: 3.0.3

 

Chart Type: Multi Series 3D Column Chart

 

Chart Objects:

 

BACKGROUND

 

CANVAS

 

CAPTION

 

SUBCAPTION

 

YAXISNAME

 

XAXISNAME

 

DIVLINES

 

YAXISVALUES

 

DATALABELS

 

DATAVALUES

 

TRENDLINES

 

TRENDVALUES

 

DATAPLOT

 

TOOLTIP

 

VLINES

 

LEGEND

 

 

 

INFO: XML Data provided using dataURL method.

 

dataURL provided: /Search/ChartFusion.xml?Rows=50&SecondaryGroupBy=ResolvedMonthly&PrimaryGroupBy=CreatedMonthly&Format=%20%20%20%3Cb%3E%3Ca%20href%3D%22%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3A

 

dataURL invoked:

Share this post


Link to post
Share on other sites

Here is what works for all of our charts:

 

 

 

Info: Chart loaded and initialized.

 

Initial Width: 800

 

Initial Height: 560

 

Scale Mode: noScale

 

Debug Mode: Yes

 

Application Message Language: EN

 

Version: 3.0.3

 

Chart Type: Single Series 3D Column Chart

 

Chart Objects:

 

BACKGROUND

 

CANVAS

 

CAPTION

 

SUBCAPTION

 

YAXISNAME

 

XAXISNAME

 

DIVLINES

 

YAXISVALUES

 

DATALABELS

 

DATAVALUES

 

TRENDLINES

 

TRENDVALUES

 

DATAPLOT

 

TOOLTIP

 

VLINES

 

 

 

INFO: XML Data provided using dataURL method.

 

dataURL provided: /Search/ChartFusion.xml?Rows%3D50%26SecondaryGroupBy%3D%26PrimaryGroupBy%3DCreatedAnnually%26Format%3D%27%2520%2520%2520%253Cb%253E%253Ca%2520href%253D%2522%252FTicket%252FDisplay.html%253Fid%253D__id__%2522%253E__id__%253C%252Fa%253E%253C%252Fb%253E%252FTITLE%253A

 

dataURL invoked:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now