Chart Series Name Apostrophe Problem

6 posts, 0 answers
  1. Vlad
    Vlad avatar
    5 posts
    Member since:
    Oct 2011

    Posted 09 Oct 2012 Link to this post

    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
  2. Vlad
    Vlad avatar
    5 posts
    Member since:
    Oct 2011

    Posted 09 Oct 2012 Link to this post

    Escaping single quote  solved the issue for now.

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

    Thanks
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 10 Oct 2012 Link to this post

    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.
  5. Alex
    Alex avatar
    9 posts
    Member since:
    Oct 2013

    Posted 16 Apr 2014 Link to this post

    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.
  6. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 21 Apr 2014 Link to this post

    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.

     
  7. willk
    willk avatar
    17 posts
    Member since:
    May 2007

    Posted 21 Jul 2015 Link to this post

    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.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017