[英]Google Charts - Custom Tooltip on Line Chart (Line Package) not Working
我正在使用谷歌图表(可视化,1.1,线包)创建一个简单的图表,包含 3 条线和月和成本轴。 一切正常,工具提示自定义除外:
这是我的代码
google.load('visualization', '1.1', {packages: ['line']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Month');
data.addColumn('number', "Line 1");
data.addColumn('number', "Line 2");
data.addColumn('number', "Line 3");
data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});
data.addRows([
[new Date(2015, 5), 1000, 980, 800, 'Custom Content 1'],
[new Date(2015, 6), 1100, 1000, 970, 'Custom Content 2'],
[new Date(2015, 7), 1550, 1420, 1200, 'Custom Content 3'],
[new Date(2015, 8), 1050, 1200, 930, 'Custom Content 4'],
[new Date(2015, 9), 1280, 1120, 1070, 'Custom Content 5'],
[new Date(2015, 10), 1100, 999, 880, 'Custom Content 6'],
]);
var options = {
chart: {
title: 'Custom ToolTips',
subtitle: 'not working!'
},
focusTarget: 'category',
tooltip: {isHtml: true},
width: 900,
height: 500
};
var chart = new google.charts.Line(document.getElementById('linechart_material'));
chart.draw(data, google.charts.Line.convertOptions(options));
}
您可以在JSFiddle上进行测试
这个有可能?
我已经尽我所能,在互联网上搜索并尝试其他代码,但看起来使用 th Line Package(而不是 CoreChart Package)是不可能的,对吗?
谁能帮我吗?
从这个答案复制: https : //stackoverflow.com/a/29148517/4966682
在深入研究了谷歌的材料图表信息后,我在他们的网站上找到了:
材料图表处于测试阶段。 外观和交互性在很大程度上是最终的,但声明选项的方式不是。
趋势线和工具提示属于创建图表的选项部分,因为它们需要选项结构来进一步定义它们。 同样,截至目前(2015 年 3 月),Google 材料图表不支持这些功能。 如果你想使用趋势线和工具提示之类的东西,你需要使用非材料图表(例如包 ['corechart'] 而不是包 ['scatter'])。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.