首页 > 解决方案 > How to make Google Line Chart circle have border?

问题描述

I wondered if it was possible to make the circle, that appears once hovered across the Google line chart, have a coloured border?

标签: chartsgoogle-visualizationlinegraph

解决方案


您可以使用样式列角色来更改点的样式。

point {stroke-width: 2; stroke-color: red;}

请参阅以下工作片段,
悬停一点以查看样式...

google.charts.load('current', {
  packages: ['corechart']
}).then(function () {
  var data = new google.visualization.DataTable();
  data.addColumn('number', 'x');
  data.addColumn('number', 'y');
  data.addColumn({role: 'style', type: 'string'});
  data.addRows([
    [0, 1, 'point {stroke-width: 2; stroke-color: red;}'],
    [1, 2, 'point {stroke-width: 2; stroke-color: red;}'],
    [2, 3, 'point {stroke-width: 2; stroke-color: red;}'],
    [3, 4, 'point {stroke-width: 2; stroke-color: red;}'],
    [4, 5, 'point {stroke-width: 2; stroke-color: red;}'],
  ]);

  var options = {
    legend: 'none'
  };

  var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
  chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>


推荐阅读