简体   繁体   中英

Google Charts - Dynamically rotate line points

It's possible to rotate line chart points using Google Charts ( https://developers.google.com/chart/interactive/docs/points#rotations ). It's also possible to customize individual points ( https://developers.google.com/chart/interactive/docs/points#individual ).

I want to rotate points based upon the data passed to the table. The following code loads the custom point but does not rotate the triangle. Is this even possible?

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);
}

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

Thanks

In the individual points options it looks like the rotation option is called shape-rotation instead of just rotation .

Change your rotation: 180 to shape-rotation: 180 and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM