use highchart and highstock on the same page

2020-06-08 15:50发布

I have this page:

<script type="text/javascript" src="jQuery/Highcharts/highstock1.1.6.js"></script>
<script type="text/javascript" src="jQuery/Highcharts/highcharts2.1.4.js"></script>

and in the page I use

$.getJSON(
        "server/indice.server.php?row=" + row +"&item="+ item,
        null,
        function(data)
        {
            chartindice = new Highcharts.Chart(
            {
                chart:
                {
                    renderTo: 'graph',
                    defaultSeriesType: 'line',
                    zoomType: 'x'
                },
                        /////moore setting..
                series:
                [{
                    type: 'area',
                    name: titleindice,
                    data: indice,
                    showInLegend : false //disable the the show/hide icon
                }]


            });
        });

and an highstock graph

window.chart = new Highcharts.StockChart({
    chart: {
        renderTo: 'chartHistory'
    },

    rangeSelector: {
            selected: 2
    },


    series: [{
        data: history,
        type: 'spline',
        tooltip: {
            valueDecimals: 2
        }
    }]
});

and they can't work together, just one or the other.

What can I do?

8条回答
甜甜的少女心
2楼-- · 2020-06-08 16:27

Highcharts is included in highstock.js, so please take look at the example, how use highcharts with highstock.js.

http://jsfiddle.net/sbochan/PtXhB/

Secondly I advice to use the newest highstock.

查看更多
Juvenile、少年°
3楼-- · 2020-06-08 16:28

Use just highstock.js and delete highcharts.js And It's work well for me And Good luck

查看更多
登录 后发表回答