最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using highcharts & highstock together on same page - Stack Overflow

programmeradmin7浏览0评论

Hope someone can help.. ? I'm trying to use both highcharts and highstock on a single page, loading from CDN, initially I set up various highcharts - gauge and bar chart with drilldown and using the following all is working fine:

<script src=".js"></script>
<script src=".js"></script>
<script src=".js"></script>
<script src=".js"></script>
<script src=".js"></script>

I now have a highstock chart but I can't get it to work together on the same page - I've tried just using highstock (without highcharts) and then adding highcharts-more and the modules, also tried using highcharts and then loading highstock as a module which didn't work either e.g

<script src=".js"></script> OR

<script src=".js"></script>

I assume the order of the CDN links is crucial to make it work too?

I'm also aware that when rendering the charts highcharts uses Highcharts.chart and highstock uses Highcharts.stockChart - so how would this work when using both?

Many thanks.

Hope someone can help.. ? I'm trying to use both highcharts and highstock on a single page, loading from CDN, initially I set up various highcharts - gauge and bar chart with drilldown and using the following all is working fine:

<script src="https://code.highcharts./highcharts.js"></script>
<script src="https://code.highcharts./highcharts-more.js"></script>
<script src="https://code.highcharts./modules/drilldown.js"></script>
<script src="https://code.highcharts./modules/exporting.js"></script>
<script src="https://code.highcharts./modules/solid-gauge.js"></script>

I now have a highstock chart but I can't get it to work together on the same page - I've tried just using highstock (without highcharts) and then adding highcharts-more and the modules, also tried using highcharts and then loading highstock as a module which didn't work either e.g

<script src="https://code.highcharts./modules/highstock.js"></script> OR

<script src="https://code.highcharts./modules/stock.js"></script>

I assume the order of the CDN links is crucial to make it work too?

I'm also aware that when rendering the charts highcharts uses Highcharts.chart and highstock uses Highcharts.stockChart - so how would this work when using both?

Many thanks.

Share Improve this question asked Sep 26, 2018 at 12:37 Dan ThoryDan Thory 2573 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

By using Highstock, you can create both stockChart and standard chart with additional modules:

Highcharts.chart('container', {
    series: [{
        type: 'solidgauge',
        data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
    }]
});

Highcharts.stockChart('container1', {
    series: [{
        type: 'line',
        data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
    }]
});

Live demo: http://jsfiddle/BlackLabel/54ezsbgr/

If you really need to use Highstock and Highcharts separately, you can do it in this way:

<script src="https://code.highcharts./stock/highstock.js"></script>
<script>
    var Highstock = Highcharts;
    Highcharts = null;
</script>
<script src="https://code.highcharts./highcharts.js"></script>

Live demo: http://jsfiddle/BlackLabel/0vshoqpa/

发布评论

评论列表(0)

  1. 暂无评论