【问题标题】:Google Charts - Dynamically rotate line pointsGoogle Charts - 动态旋转线点
【发布时间】:2015-06-24 21:04:29
【问题描述】:

可以使用 Google Charts (https://developers.google.com/chart/interactive/docs/points#rotations) 旋转折线图点。也可以自定义单个点 (https://developers.google.com/chart/interactive/docs/points#individual)。

我想根据传递给表格的数据旋转点。以下代码加载自定义点但不旋转三角形。这甚至可能吗?

google.setOnLoadCallback(drawChart);
  function drawChart() {
    var data = google.visualization.arrayToDataTable
        ([['X', 'Y', {'type': 'string', 'role': 'style'}],
          [1, 3, null],
          [2, 2.5, null],
          [6, 3, 'point {shape-type: triangle;  rotation: 180;}'],
          [7, 2.5, null],
          [8, 3, null]
    ]);

    var options = {
      legend: 'none',
      hAxis: { minValue: 0, maxValue: 9 },
      curveType: 'function',
      pointSize: 7
    };

    var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
    chart.draw(data, options);
}

在 jsfiddle - https://jsfiddle.net/7bc691kr/

谢谢

【问题讨论】:

    标签: javascript google-visualization


    【解决方案1】:

    在单个点选项中,看起来旋转选项被称为shape-rotation 而不仅仅是rotation。

    将您的rotation: 180 更改为shape-rotation: 180,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-28
      • 1970-01-01
      • 2014-03-04
      • 2015-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多