在几分钟和几秒钟内使用AmCharts设置StockEvents

时间:2017-10-10 23:46:38

标签: jquery amcharts

我在AmCharts上为各种不同的项目取得了很大的成功。这很简单,但我已经相对轻松地将stockEvents添加到图表中。然而,这是以日期作为唯一值。现在我正在使用分钟和秒钟,我似乎无法正确插入stockEvent。这是我正在尝试做的事情:https://jsfiddle.net/punksgt/vshkv4xq/

相信问题出现在stockEvents

"stockEvents": [{
"date": new Date(2012, 0, 1, 0, 0, 3, 592),
"type": "sign",
"backgroundColor": "#85CDE6",
"graph": "g1",
"text": "S",
"description": "This is description of an event"
}],

我最终正在寻找类似的东西来调出图表上的事件。 https://www.amcharts.com/demos/stock-events/

1 个答案:

答案 0 :(得分:1)

需要在关联的dataSet内设置

stockEvents。你的小提琴是把它放在它之外。

  "dataSets": [{
    "color": "#b0de09",
    "fieldMappings": [{
      "fromField": "value",
      "toField": "value"
    }, {
      "fromField": "volume",
      "toField": "volume"
    }],

    "dataProvider": chartData,
    "categoryField": "date",
    "stockEvents": [{
      "date": new Date(2012, 0, 1, 0, 0, 3, 592),
      "type": "sign",
      "backgroundColor": "#85CDE6",
      "graph": "g1",
      "text": "S",
      "description": "This is description of an event"
    }],
  }],

该事件还需要在您的数据的日期范围内(您的小提琴设置日期在2012-01-01之前1000天,因此它不会显示)。

Updated fiddle