This is a migrated thread and some comments may be shown as answers.

Chart Series Name Apostrophe Problem

5 Answers 198 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 09 Oct 2012, 03:27 PM
When trying to assign a string with apostrophe to chart series name will cause chart to break.

I get this error when I view firebug console
SyntaxError: missing } after property list
series: [{color: 'Red',name: 'Welch's 64 oz Juice 2012',tooltip :{visible :true}...
Teleri...85f9819 (line 7458, col 36)


Thanks

5 Answers, 1 is accepted

Sort by
0
Vlad
Top achievements
Rank 1
answered on 09 Oct 2012, 03:44 PM
Escaping single quote  solved the issue for now.

chartSeriesPromotion.Name = promoname.Replace("'","\\'");

Thanks
0
Marin Bratanov
Telerik team
answered on 10 Oct 2012, 11:37 AM
Hi Vlad,

RadHtmlChart renders through JavaScript and thus all strings you pass have to go through JavaScript. This causes the need to escape some symbols that are special for JavaScript (e.g. apostrophe and backslash). Nevertheless, I am logging this scenario for further research to see if we can improve this behavior without breaking the control or the displayed sting by including some form of automatic escaping. You can monitor the release notes to see if/when this becomes available.


Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Alex
Top achievements
Rank 1
answered on 16 Apr 2014, 03:02 PM
I'm also encountering this issue.

It's proving to be a real pain as we pull strings for different languages back from a resources file, as it's only this one control that is broken I can't change the language file with an escaped character.

`<TitleAppearance Position="Center" RotationAngle="270" Text="<% Resources:Common, PAGES %>" ></TitleAppearance>`

We substitute language files like this, so I cannot easily just escape it.
0
Ianko
Telerik team
answered on 21 Apr 2014, 07:34 AM
Hi Alex,

As Marin explained, this matter comes due to JavaScript behavior and this quotes should be escaped with the appropriate characters.

This is a general JS matter and we are unable to control this in the control.

I can suggest using regex expressions to handle this on saving the string fields or on loading them into the chart.

Regards,
Ianko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
willk
Top achievements
Rank 1
answered on 22 Jul 2015, 03:32 AM

For anyone having this issue, there is a simple .NET command to fix this:

Variable = "This doesn't have any problem \ with escape characters"

Variable = HttpUtility.JavaScriptStringEncode(Variable)

You can now assign Variable to names within any javascript element such as RadChart series names.

Tags
Chart (HTML5)
Asked by
Vlad
Top achievements
Rank 1
Answers by
Vlad
Top achievements
Rank 1
Marin Bratanov
Telerik team
Alex
Top achievements
Rank 1
Ianko
Telerik team
willk
Top achievements
Rank 1
Share this question
or