And*_*ura 0 tooltip google-visualization
我的图表非常简单,如下所示:
\n\nfunction drawVisualization() {\n\n var data = google.visualization.arrayToDataTable([\n [\'week\', \'rate\'],\n [\'1\', 0.156],\n [\'2\', 0.232],\n [\'3\', 0.446],\n [\'4\', 0.832],\n [\'5\', 0.702],\n [\'6\', 0.773],\n [\'7\', 0.842],\n [\'8\', 0.413],\n [\'9\', 0.278],\n [\'10\', 0.323],\n [\'11\', 0.312],\n [\'12\', 0.309],\n [\'13\', 0.134],\n [\'14\', 0.137]\n ]);\n\n new google.visualization.LineChart(document.getElementById(\'visualization\')).\n draw(data, {curveType: "function",\n width: 500, height: 400,\n vAxis: {maxValue: 1}}\n );\n}\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x80\x8b
\n\n但我不知道如何格式化数据列以在工具提示中显示为百分比。你们可以帮忙吗?
\n使用数字格式化程序:
var formatter = new google.visualization.NumberFormat({pattern: '#%'});
formatter.format(data, 1); // format column 1
Run Code Online (Sandbox Code Playgroud)
您可能还想设置 y 轴的格式:
vAxis: {
maxValue: 1,
format: '#%'
}
Run Code Online (Sandbox Code Playgroud)