GoogleWebComponents / google-chart

Google Charts API web components
https://www.webcomponents.org/element/@google-web-components/google-chart/elements/google-chart
Apache License 2.0
358 stars 130 forks source link

How to add a % sign to Google Gauges with the polymer component #195

Closed kbischop closed 6 years ago

kbischop commented 7 years ago

I want to add a % sign to the google gauges. I found this example:

// Create and populate the data table.

var data = google.visualization.arrayToDataTable([ ['Label', 'Value'], ['Memory', 80], ['CPU', 55], ['Network', 68] ]);

var formatter = new google.visualization.NumberFormat( {suffix: '%',pattern:'#'} );

formatter.format(data,1);

// Create and draw the visualization. new google.visualization.Gauge(document.getElementById('chart_div')). draw(data);

How can I do this with the google-chart polymer component. How can I access the internal datatable to add the formater ?

wesalvaro commented 7 years ago

You'll want to create a DataTable yourself to do that. You can get one from the google-chart-loader element.