How to change tooltip text for google chart api?

后端 未结 2 1720
后悔当初
后悔当初 2020-12-15 17:52

http://code.google.com/apis/chart/




        
相关标签:
2条回答
  • 2020-12-15 18:09

    For custom tooltips, add the tooltip as an extra column:

    function drawVisualization() {
        data = new google.visualization.DataTable()
        data.addColumn('string', 'Date');
        data.addColumn('number');
        data.addColumn({type:'string',role:'tooltip'});
        data.addRow();
        base = 10;
        data.setValue(0, 0, 'Datapoint1');
        data.setValue(0, 1, base++);
        data.setValue(0, 2, " This is my tooltip1 ");
    
        data.addRow();
        data.setValue(1, 0, 'Datapoint2');
        data.setValue(1, 1, base++);
        data.setValue(1, 2, "This is my second tooltip2");
    
        // Draw the chart.
        var chart = new google.visualization.BarChart(document.getElementById('visualization'));
        chart.draw(data, {legend:'none', width:600, height:400});
    }
    
    0 讨论(0)
  • 2020-12-15 18:16

    @Adam; If you want to edit text then check this http://code.google.com/apis/ajax/playground/?type=visualization#pie_chart

    you can change your code from here

    function drawVisualization() {
      // Create and populate the data table.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Task');
      data.addColumn('number', 'Hours per Day');
      data.addRows(5);
      data.setValue(0, 0, 'Work');
      data.setValue(0, 1, 11);
      data.setValue(1, 0, 'Eat');
      data.setValue(1, 1, 2);
      data.setValue(2, 0, 'Commute');
      data.setValue(2, 1, 2);
      data.setValue(3, 0, 'Watch TV');
      data.setValue(3, 1, 2);
      data.setValue(4, 0, 'Sleep');
      data.setValue(4, 1, 7);
    

    and if you want your custom tooltip you have to use javascript for these

    http://code.google.com/p/gvtooltip/

    http://informationandvisualization.de/blog/tooltips-google-chart-api

    0 讨论(0)
提交回复
热议问题