How to add trend line to high charts

后端 未结 2 887
梦谈多话
梦谈多话 2021-01-23 22:33

This is the high chart graph code.



    
        

        
2条回答
  •  礼貌的吻别
    2021-01-23 23:00

    You can use this Plugin that I believe will do what you want to.

    $(function() {
    
        $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
            $('#container').highcharts('StockChart', {
    
                title : {
                    text : 'AAPL Stock Price'
                },
    
                subtitle: {
                    text: 'From may 15, 2006 to May 10, 2013'
                },
                
                xAxis: {
                    ordinal: false
                },
    
                yAxis: {
                    title : {
                        text : 'Price'
                    }
                },
    
                legend: {
                    enabled: true,
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                
                series : [{
                    name: 'Stock Price',
                    type : 'line',
                    id: 'primary',
                    data : data
                }, {
                    name: 'Linear Trendline',
                    linkedTo: 'primary',
                    showInLegend: true,
                    enableMouseTracking: false,
                    type: 'trendline',
                    algorithm: 'linear'
                }]
            });
        });
    
    });
    
    
    
    
    

    Source: http://www.highcharts.com/plugin-registry/single/16/technical-indicators

提交回复
热议问题