DYGRAPHS:同一日期散点图的注释

时间:2017-07-05 06:34:26

标签: annotations dygraphs

在我的散点图中,有相同日期的点,但我只想注释一个。如何在我的注释数据中指定? jsfiddle

g = new Dygraph(
document.getElementById("container"),
"Date,Temperature\n" +
"2008-05-07,75\n" +
"2008-05-08,70\n" +
"2008-05-08,20\n" +
"2008-05-09,80\n"
 );
g.ready(function() {
g.setAnnotations([
{
  series: "Temperature",
  x: "2008-05-08",
  shortText: "L",
  text: "Coldest Day"
}
]);
});

1 个答案:

答案 0 :(得分:0)

你可以这样做,在数据点上添加一秒,你不想被贴上标签。

https://jsfiddle.net/55ktaue1/3/

然后我会使用格式化功能从日期中删除时间戳。 ' legendFormatter'示例:http://dygraphs.com/tests/legend-formatter.html http://dygraphs.com/tests/labelsDateMilliseconds.html http://dygraphs.com/tests/labelsDateUTC.html

g = new Dygraph(
    document.getElementById("container"),
    "Date,Temperature\n" +
    "2008-05-07,75\n" +
    "2008-05-08,70\n" +
    "2008-05-08 00:00:01,20\n" +
    "2008-05-09,80\n"
  );

  g.ready(function() {
    g.setAnnotations([
    {
      series: "Temperature",
      x: "2008-05-08",
      shortText: "L",
      text: "Coldest Day"
    }
    ]);
  });