使用谷歌图表添加动态标记
我有用 Google 图表创建的折线图。我想添加一个动态标记来标记该图表上的特定点(稍后我想添加一条水平线)。这看起来应该可以使用 chm 参数,但我无法让它工作——绘制了图表,但没有标记。
我已经尝试使用 chm 参数进行各种排列,但均无济于事。看起来它应该是折线图的有效参数。我缺少什么?
这是我的代码:
function drawIterationHistory() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Iteration');
data.addColumn('number', 'Other');
data.addColumn('number', 'Fail');
data.addColumn('number', 'Not Run');
data.addColumn('number', 'Pass');
data.addRows([
['1', 0, 5, 90, 5],
['2', 1, 8, 82, 10],
['3', 2, 12, 60, 40],
['4', 2, 30, 20, 60],
['5', null, null, null, null],
['6', null, null, null, null]
]);
var options = {
width: 450, height: 240,
title: 'Test Plan Iteration History',
isStacked: 'true',
hAxis: {title: 'Iteration'},
vAxis: {title: 'Test Cases'},
chm: '@a,FF0000,1,2:20,1' // This line does not seem to have an effect
};
var chart = new google.visualization.LineChart(document.getElementById('iterationHistory'));
chart.draw(data, options);
}
I have line chart I have created with Google charts. I'd like to add a dynamic marker to mark a particular point on that chart (and later I'll want to add a horizontal line). This looks like it should be possible using the chm parameter, but I can't get it to work-- the chart draws, but no marker.
I've tried various permutations with the chm parameter to no avail. It looks like it should be a valid parameter for a line chart. What am I missing?
Here is my code:
function drawIterationHistory() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Iteration');
data.addColumn('number', 'Other');
data.addColumn('number', 'Fail');
data.addColumn('number', 'Not Run');
data.addColumn('number', 'Pass');
data.addRows([
['1', 0, 5, 90, 5],
['2', 1, 8, 82, 10],
['3', 2, 12, 60, 40],
['4', 2, 30, 20, 60],
['5', null, null, null, null],
['6', null, null, null, null]
]);
var options = {
width: 450, height: 240,
title: 'Test Plan Iteration History',
isStacked: 'true',
hAxis: {title: 'Iteration'},
vAxis: {title: 'Test Cases'},
chm: '@a,FF0000,1,2:20,1' // This line does not seem to have an effect
};
var chart = new google.visualization.LineChart(document.getElementById('iterationHistory'));
chart.draw(data, options);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论