【问题标题】:Synchronizing Dygraphs using Vue使用 Vue 同步 Dygraph
【发布时间】:2018-04-17 17:07:04
【问题描述】:

我正在尝试使用 'extras/synchronizer.js' 同步两个 dygraphs,因为它在此处完成 http://dygraphs.com/tests/synchronize.html 。我同时导入了插件和 dygraph 库本身,但收到模块错误 enter image description here

我可以做些什么来完成这项工作?

【问题讨论】:

  • 你解决过这个问题吗?在这里面临同样的问题。

标签: javascript vue.js vuejs2 dygraphs


【解决方案1】:

已解决,但不是特别漂亮。在 .vue 文件中,您要在以下位置构建图表:

// imports main dygraph class from /node_modules and adds it to window scope
import _DygraphRoot from 'dygraphs'
window.Dygraph = _DygraphRoot

// tacks on .synchronizer to the window scoped Dygraph
require('dygraphs/src/extras/synchronizer')

然后,您可以像这样从窗口访问 .vue 文件中的 Dygraphs:

let graph = new window.Dygraph(...)

【讨论】:

  • 还有比这更好的解决方案吗?
猜你喜欢
  • 1970-01-01
  • 2018-08-19
  • 2019-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-28
  • 2015-07-22
相关资源
最近更新 更多