最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Material Charts: Stop Tooltip Rounding - Stack Overflow

programmeradmin2浏览0评论

I'm using the Google Visualisation Material Chart...

....and in my example...

/

...the Tooltips are rounding the bar values rather than just displaying the values as they are.

I've tried customising the tooltips as documented here : but still no joy.

The documentation does say...

"The Material Charts are in beta."

so maybe I'm fighting a lost cause.

My question:

Does anyone know how to stop the tooltips from rounding?

Any help appreciated.

HTML

<div id="chart_div" style="width: 900px; height: 500px;"></div>

JS Code:

google.load("visualization", "1.1", {
    packages: ["bar"]
});
google.setOnLoadCallback(drawChart);

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Task', 'Hours per Day'],
        ['Work', 8.5], // Tooltip says 8.5. CORRECT
        ['Eat', 11.5], // Tooltip says 12 - INCORRECT
        ['Commute', 2],// Tooltip says 2 - CORRECT
        ['Watch TV', 0.28],// Tooltip says 0.28 - CORRECT
        ['Sleep', 7.28] // Tooltip says 7.3 - INCORRECT
    ]);

    var options = {
        title: 'My Daily Activities'
    };

    var chart = new google.charts.Bar(document.getElementById('chart_div'));

    chart.draw(data, google.charts.Bar.convertOptions(options));
}

I'm using the Google Visualisation Material Chart...

https://google-developers.appspot./chart/interactive/docs/gallery/barchart#Material

....and in my example...

http://jsfiddle/ETFairfax/78595a3h/

...the Tooltips are rounding the bar values rather than just displaying the values as they are.

I've tried customising the tooltips as documented here : https://developers.google./chart/interactive/docs/customizing_tooltip_content#custom_html_content but still no joy.

The documentation does say...

"The Material Charts are in beta."

so maybe I'm fighting a lost cause.

My question:

Does anyone know how to stop the tooltips from rounding?

Any help appreciated.

HTML

<div id="chart_div" style="width: 900px; height: 500px;"></div>

JS Code:

google.load("visualization", "1.1", {
    packages: ["bar"]
});
google.setOnLoadCallback(drawChart);

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Task', 'Hours per Day'],
        ['Work', 8.5], // Tooltip says 8.5. CORRECT
        ['Eat', 11.5], // Tooltip says 12 - INCORRECT
        ['Commute', 2],// Tooltip says 2 - CORRECT
        ['Watch TV', 0.28],// Tooltip says 0.28 - CORRECT
        ['Sleep', 7.28] // Tooltip says 7.3 - INCORRECT
    ]);

    var options = {
        title: 'My Daily Activities'
    };

    var chart = new google.charts.Bar(document.getElementById('chart_div'));

    chart.draw(data, google.charts.Bar.convertOptions(options));
}
Share Improve this question asked Mar 20, 2015 at 15:22 ETFairfaxETFairfax 3,8148 gold badges42 silver badges62 bronze badges 2
  • So I explain what the problem is. Show an example of what I'm doing. I've read what I think I need to read in the documentation, and I've said what I've tried....I then get a -1! – ETFairfax Commented Mar 20, 2015 at 15:39
  • 1 People are way too cavalier when it es to downvoting. Just upvoted your question. – Alex W Commented Mar 20, 2015 at 18:22
Add a ment  | 

1 Answer 1

Reset to default 7

You must specify a different format:

    var options = {
      title: 'My Daily Activities',
      vAxis : {
        format: 'decimal'
      }
    }

Answer can be found in this link: here

发布评论

评论列表(0)

  1. 暂无评论