使用谷歌图表添加动态标记

发布于 2025-01-07 11:38:24 字数 1209 浏览 3 评论 0原文

我有用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文