Google Bar Chart custom tooltip does not work -


this code:

chart = new google.charts.bar(document.getelementbyid('chart')); var datatable = new google.visualization.datatable(); datatable.addcolumn('string', ''); datatable.addcolumn('number', 'value'); datatable.addcolumn({type: 'string', role: 'tooltip', p: {'html': true}}); var rows = [     ['u.s.', 2, "tool"],     ['france', 10, "tip"] ]; datatable.addrows(rows); chart.draw(datatable); 

does not result in custom tooltip.

strangely works other chart types.

do know why please?

[edit] apparently not possible. there other way put "%" symbol in tooltip, in screenshot?

enter image description here

the tooltip should show formatted value default.
using object notation values, can provide formatted value (f:)
along required value (v:)...

you can use datatable.setformattedvalue(...) after table loaded...

example...

google.charts.load('current', {    callback: drawchart,    packages: ['bar']  });    function drawchart() {    chart = new google.charts.bar(document.getelementbyid('chart'));    var datatable = new google.visualization.datatable();    datatable.addcolumn('string', '');    datatable.addcolumn('number', 'value');    var rows = [        ['u.s.', {v: 2, f: '2%'}],    // add %        ['france', {v: 10, f: '10%'}],  // add %        ['germany', {v: 15, f: 'whatever want'}]   // add whatever want     ];    datatable.addrows(rows);    chart.draw(datatable);  }
<script src="https://www.gstatic.com/charts/loader.js"></script>  <div id="chart"></div>


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -