SeeThePicture

Problems With Special Characters In Setxmlurl

Recommended Posts

Hi,

 

I am doing something like this (I have simplified for this discussion), but it is consistently resulting in "No data to display.":

 

$strang = "dataMaker.php?myvar=hereWeGo%2B";

<script type="text/javascript">                
FusionCharts.setCurrentRenderer("javascript");
var myChart = new FusionCharts("ZoomLine.swf", "myChartId", "100%", "100%", "0", "1");       
myChart.setXMLUrl("<?php echo $strang;?>");         
myChart.render("chartContainer");                   
</script>

 

The above is only problematic for me when trying to work with <, >, &, ", # and +. Of course when I get rid of the special characters, everything works fine. Also please note through the use of various things like

 

$mysqli->real_escape_string(htmlspecialchars(urlencode(" She's looking great! This is a slash /. "])))

 

I am able to successfully accommodate some special characters /, \ and ' with no problem. So what do you think of the bold characters above? Is it possible to accommodate those in setXMLUrl?

 

What are your thoughts?

 

Thank you,

SeeThePicture

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

With regard to your issue, please note that you can directly embed most of the special characters and punctuation marks in the XML/JSON data source of your chart.

 

However, &, <, >, ' (apostrophe) and "(quote) need to be specially encoded when providing the same as a part of the chart data. Apart from this, there is no need to encode any other special character.

 

So, could you please use "&" instead of &, "<" instead of <, ">" instead of >, """ instead of "(quote) and "'" instead of ' (apostrophe), in your XML data string and try once again?

 

For more information on "Using Special Punctuation on Chart", please follow the link below:

http://docs.fusioncharts.com/charts/contents/?advanced/special-chars/SpPunctuation.html

 

Hope this helps!

 

Share this post


Link to post
Share on other sites

Hi,

 

With regard to your issue, please note that you can directly embed most of the special characters and punctuation marks in the XML/JSON data source of your chart.

 

However, &, <, >, ' (apostrophe) and "(quote) need to be specially encoded when providing the same as a part of the chart data. Apart from this, there is no need to encode any other special character.

 

So, could you please use "&" instead of &, "<" instead of <, ">" instead of >, """ instead of "(quote) and "'" instead of ' (apostrophe), in your XML data string and try once again?

 

For more information on "Using Special Punctuation on Chart", please follow the link below:

http://docs.fusioncharts.com/charts/contents/?advanced/special-chars/SpPunctuation.html

 

Hope this helps!

Share this post


Link to post
Share on other sites

Hello,

 

Thank you for this reply. I will try that.

 

Please note that I also specifically asked about the plus sign "+". Do you know whether the plus sign can be directly embedded or needs to be specially encoded? Can you provide a very simple example demonstrating usage of the plus sign or its code in the XML of a very basic chart?

 

Thank you,

SeeThePicture

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

Apologies for missing out the explanation for '+' and '#' characters.

 

Please note that these two characters you can directly use in your chart XML (without any encoding).

 

Please find the screen shot of one simple chart (column2D), showing the special characters and the corresponding XML code, for your reference.

 

Ref. XML Code:

<chart caption='Total Sales <By Year>' subcaption='Product A & B' xAxisName='"Month' yAxisName=''Revenue' numberPrefix='#'>
  <set label='Jan+Feb' value='420000' /> 
  <set label='Mar+Apr' value='720000' />
  <set label='May+Jun' value='810000' />
  <set label='Jul+Aug' value='680000' />
  <set label='Sep+Oct' value='610000' />
  <set label='Nov+Dec' value='530000' />
</chart>

 

Hope this helps!

post-23588-0-85379100-1349334978_thumb.png

Share this post


Link to post
Share on other sites

Hi,

 

Apologies for missing out the explanation for '+' and '#' characters.

 

Please note that these two characters you can directly use in your chart XML (without any encoding).

 

Please find the screen shot of one simple chart (column2D), showing the special characters and the corresponding XML code, for your reference.

 

Ref. XML Code:

<chart caption='Total Sales <By Year>' subcaption='Product A & B' xAxisName='"Month' yAxisName=''Revenue' numberPrefix='#'>
  <set label='Jan+Feb' value='420000' /> 
  <set label='Mar+Apr' value='720000' />
  <set label='May+Jun' value='810000' />
  <set label='Jul+Aug' value='680000' />
  <set label='Sep+Oct' value='610000' />
  <set label='Nov+Dec' value='530000' />
</chart>

 

Hope this helps!

Share this post


Link to post
Share on other sites

Hi,

 

Thank you! Yes it does help. It demonstrates to me that + can be used directly in the body of the XML. Thank you.

 

However, I may have a slightly different problem related to using the function setxmlurl when the URL contains a variable with special characters.

 

From Documentation I am reading "Home > FusionCharts and JavaScript > Providing & updating data". I see "Using XML file as the chart's data source".

 

I am using my dataMaker.php page to generate my xml data. I pass a variable to my dataMaker.php page through the URL to that dataMaker.php. Sometimes the URL will therefore look like:

-- dataMaker.php?myvar=hereWeGo%3E where %3E can be anything to url encode characters like %3E for >, %3C for <, %40 for @, etc.

 

I assign the location of my dataMaker.php file (with my url encoded passed variable) in a string called strang as shown by $strang in my original post. Then I pass that $strang to the FusionCharts JavaScript class function setXMLUrl as shown in my original post.

 

Well, everything is working fine when characters get encoded as '%3E', '%3C', '%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%3D', '%24', '%2C', '%2F', '%3F', '%25', '%5B' and '%5D'.

 

However, I am stumbling on three cases. I get No data to display whenever characters in the URL are encoded as:

-- %23 for #

-- %2B for +

-- %26 for &

 

Any idea what these three might have in common, causing them not to work for me?

 

Thank You,

SeeThePicture

Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

Could you please try once by urlEncoding, before passing the special characters with the URL to the "setXMLUrl()" function?

 

Ref. Code:

$strang = "dataMaker.php?myvar=%23%2B%26";myChart.setXMLUrl("<?php echo urlEncode($strang);?>");

 

Hope this helps!

Share this post


Link to post
Share on other sites

Hi,

 

Could you please try once by urlEncoding, before passing the special characters with the URL to the "setXMLUrl()" function?

 

Ref. Code:

$strang = "dataMaker.php?myvar=%23%2B%26";myChart.setXMLUrl("<?php echo urlEncode($strang);?>");

 

Hope this helps!

 

Thank you! I don't understand why seemingly redundant URL encoding works but it is working for me. Thank You.

 

Regards,

SeeThePicture

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