简体   繁体   English

不同页面上的多个HighCharts

[英]Multiple HighCharts on different pages

I have a coffeescript: 我有一个咖啡脚本:

chart = undefined
$ ->
chart = new Highcharts.Chart(
  chart:
    renderTo: "sales "
    type: "line"

...... ......

chart1 = undefined
$ ->
  chart1 = new Highcharts.Chart(
    chart:
      renderTo: "graph"
      type: "line"

..... .....

<div id="sales" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
<div id="graph" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

This works fine if both div's are on the same html-page, but not if I share each div on a different page. 如果两个div都在同一个html页面上,则效果很好,但是如果我在不同页面上共享每个div则不能。 I can't see a reason..why 我看不出原因..为什么

Tha basic idea is to show different line charts on different pages. 基本思想是在不同页面上显示不同的折线图。

Any idea? 任何想法?

If you are including the code for both charts on each page, you should be getting a javascript error - Highcharts Error 13 ( http://www.highcharts.com/errors/13 ). 如果在每页上都包含两个图表的代码,则应该会遇到JavaScript错误-Highcharts错误13( http://www.highcharts.com/errors/13 )。

This error happens when you tell Highcharts to build a chart in a div that does not exist. 当您告诉Highcharts在不存在的div中构建图表时,会发生此错误。

This error will often stop the other chart(s) from being displayed. 该错误通常会阻止其他图表的显示。

You need to call only the charts that you have containing elements for on each page, and no others. 您只需要调用每个页面上包含元素的图表,而无需调用其他图表。

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

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