Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chart title and column name with special characters

The solution for what i am looking should be here. But, when i try to use ASCII character encodings, the ASCII code is actually printed. Any ideas why?

For example, i have the following code on Google Chart Option:

var optionsTotUsers = {
    'title': 'Transaçoes',
    'backgroundColor': 'transparent',
    'height': '300',
    'legend': 'bottom',
    'vAxis': { viewWindowMode: "explicit", viewWindow: { min: 0} }
};

This prints the actual &ccedil on the chart title. If i use the 'ç' it prints out �.

like image 382
Fonsini Avatar asked Jul 09 '13 16:07

Fonsini


People also ask

What is arrayToDataTable?

arrayToDataTable()This helper function creates and populates a DataTable using a single call. Advantages: Very simple and readable code executed in the browser.


2 Answers

I think this will help you.Using UNICODE you can add special characters to the title. The UNICODE for the special characters is available here.You need to use UNICODE as below.

var options = {
                'title': 'Transa\u00E7oes',
                'backgroundColor': 'transparent',
                'height': '300',
                'legend': 'bottom',
                'vAxis': { viewWindowMode: "explicit", viewWindow: { min: 0} }

            };

Click here to see the working sample. jqfaq.com

like image 182
Abinaya Selvaraju Avatar answered Jan 03 '23 18:01

Abinaya Selvaraju


if you are using jQuery, you can take advantage of the html() function

var options = {
   title: $('<div>Transa&ccedil;oes</div>').html()
   ...
};

enter image description here

Edit : Dont know why google charts is not able to parse a string with special HTML characters, or why there is not an option for declaring the title as HTML - even <em> and so on is rendered as text, but the above works.

like image 39
davidkonrad Avatar answered Jan 03 '23 17:01

davidkonrad