我的页面上有两个图文。定期从源读取新的时间序列数据并将其写入局部变量,然后使用以下命令更新图表:
vm.graph1.updateOptions(
{ 'file': customData1, 'labels': vm.labels1 });
vm.graph2.updateOptions(
{ 'file': customData2, 'labels': vm.labels2 });
这工作得很好,图表显示了预期的实时趋势。 但是,当我尝试通过包含syncrhonizer.js 并使用以下命令来同步两个图时:
vm.graphSync = Dygraph.synchronize(vm.graph1, vm.graph2);
然后“实时更新”就会停止工作。换句话说,图表不显示任何新的传入值(它只显示相同的静态时间跨度)。无论是选择还是缩放,同步效果都很好。
数据仍在更新,但现在我必须双击图表(或手动平移)才能查看最新数据。
有人有任何使用 Dygraphs 同步实时趋势的想法或工作解决方案吗?
最佳答案
更新数据后,您需要显式设置dateWindow
:
vm.graph1.updateOptions(
{ 'file': customData1, 'labels': vm.labels1 });
vm.graph2.updateOptions(
{ 'file': customData2, 'labels': vm.labels2 });
vm.graph1.updateOptions({
dateWindow: vm.graph1.xAxisExtremes()
});
// ^^^ this will synchronize the other charts, too
您必须执行此操作的事实可能被视为同步器的错误。欢迎file an issue针对 dygraphs,最好通过 dygraphs.com/fiddle 提供复制链接。
关于javascript - Dygraphs 实时趋势和同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33774592/