在可视化API中使用Google的注释时间轴,您可以插入注释不管数据集吗?

StackOverflow https://stackoverflow.com/questions/1904167

  •  19-09-2019
  •  | 
  •  

我可以在图表上的特定数据集上插入注释,但是我希望在图表上有多个行,而不将注释与特定行相关联,而是与日期相关。

这是一个 例子 我想做的。注意附加到X轴而不是图表上的特定线的气泡。

我已经阅读了API,看不到这样的选项,但是想知道是否有人知道方法。

谢谢。

有帮助吗?

解决方案

没有经验,但是我的即时反应是,您可以尝试使用所有零作为数据附带的注释,并将其排除在传奇之外?

其他提示

如果您不介意使用SVG 线图注释 您也可以以更高的灵活性来重新创建它。如果将注释列设置为立即遵循X轴值,则注释将出现在图表的最底部(在轴上),而不会附加到任何类别。这是一个示例:

function drawVisualization() {
  // Create and populate the data table.
  var data = new google.visualization.DataTable();
  data.addColumn('number','Day');
  data.addColumn({type: 'string', role: 'annotation'});
  data.addColumn({type: 'string', role: 'annotationText'});
  data.addColumn('number', '.DJI');
  data.addColumn('number', '.INX');
  data.addColumn('number', '.INIC');
  data.addRows([
    [1, null, null, 1000, 400, 300],
    [2, 'A', 'did stuff', 1170, 460, 400],
    [3, 'B', 'did more stuff', 660, 1120, 540],
    [4, null, null, 1030, 540, 620],
    [5, 'C', 'stopped stuff', 1070, 600, 700]
  ]);

  // Create and draw the visualization.
  new google.visualization.LineChart(document.getElementById('visualization')).
    draw(data, {focusTarget: 'category',
                  width: 500, height: 400,
                  vAxis: {maxValue: 10},}
          );
}

最终看起来像这样:

enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top