如何在Google Chart中的工具提示中自定义内容

如何在Google Chart中的工具提示中自定义内容

对于以上图表,我具有以下var size = 4; document.write( "<center>" + Array.apply(0,new Array(size)).map(function(_,i) { return new Array((i + 1) * 2).join(" * "); }).join("<br>") + "</center>" );模型。

data

当我将鼠标悬停在进度条上时,第一行始终是var data = google.visualization.arrayToDataTable([ ["","goal Achieved",{role: 'style'},target_goal_annotation,{role: 'annotation'}],[1,achieved_goal,"opacity: .75;",target_goal,"opacity: 0;","" ] ]); ,因为我在上面的数据块中的第一位是1

如果我再放其他任何东西,基线就会消失,这是可以理解的。我需要替换工具提示中的1并放入其他内容,例如收集的点

在可见的基线下如何实现?

按照基线,我的意思是底部的水平线。

luopeng188020 回答:如何在Google Chart中的工具提示中自定义内容

默认情况下,工具提示将使用数据表单元格的格式值。

使用对象表示法,我们可以提供值(v:)和格式化值(f:

因此,要显示1以外的内容,请使用以下内容...

{v: 1,f: 'Points collected'}

例如

var data = google.visualization.arrayToDataTable([
    ["","Goal Achieved",{role: 'style'},target_goal_annotation,{role: 'annotation'}],[{v: 1,f: 'Points collected'},achieved_goal,"opacity: .75;",target_goal,"opacity: 0;","" ]
]);
本文链接:https://www.f2er.com/3167014.html

大家都在问