简体   繁体   English

AnyChart eventMarker() 导致股票图表出错

[英]AnyChart eventMarker() Causing Error on Stock Chart

I'm trying to add event markers to my stock chart, but as soon as I add them I get this error: anychart-stock.min.js:286 Uncaught TypeError: Cannot read properties of undefined (reading 'o')我正在尝试将事件标记添加到我的股票图表中,但是一旦添加它们,我就会收到此错误: anychart-stock.min.js:286 Uncaught TypeError: Cannot read properties of undefined (reading 'o')

I have added event markers on other pages of my application without an issue, and I have tried every single example I could find.我已经在我的应用程序的其他页面上添加了事件标记,没有任何问题,并且我已经尝试了我能找到的每一个示例。 Here is my current code to add the marker:这是我当前添加标记的代码:

 var eventMarkers = chart.plot(0).eventMarkers();
   console.log(eventMarkers);
  // set markers data
  eventMarkers.data([
    { date: quotes[1].date, description: '9-11 attacks' },
    { date: quotes[1].date, description: 'Iraq War' },
    { date: quotes[1].date, description: 'Global financial collapse' },
    {
      date: quotes[1].date,
      description: 'OPEC cuts production targets 4.2 mmbpd'
    },
    { date: quotes[1].date, description: 'Greece\'s debt crisis' },
    { date: quotes[1].date, description: 'Japan earthquake' },
    { date: quotes[1].date, description: 'Russian financial crisis' },
    {
      date: quotes[1].date,
      description: 'OPEC production quota unchanged'
    }
  ]);

Here is what I am currently including:这是我目前包括的内容:

 <script src='https://code.jquery.com/jquery-3.5.1.js'></script>
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js"></script>
      <script src='https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js'></script>
    <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js" charset="utf-8"></script>
 <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-base.min.js"></script>
     <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-core.min.js" type="text/javascript"></script>
      <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-stock.min.js"></script>
      <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-exports.min.js"></script>
      
      <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-data-adapter.min.js"></script>
      <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-annotations.min.js"></script>
      <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-ui.min.js"></script><!-- Data adapter -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.14.0-beta3/dist/js/bootstrap-select.min.js"></script>

This is driving me crazy, should be something simple that I have already done but something is going on and I can't figure it out.这让我发疯,应该是我已经完成的简单事情,但正在发生一些事情,我无法弄清楚。

Figured it out after hours of trial and error.经过数小时的反复试验后弄清楚了。 The code to create the event markers needed to be before I created the mapping.创建事件标记的代码需要在我创建映射之前。 No idea why this mattered here since that was not required on any other pages in which I created event markers.不知道为什么这在这里很重要,因为在我创建事件标记的任何其他页面上都不需要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM