highcharts 多資料+切換

qingyezhu發表於2014-08-05

 

var highchartsOptions = {
        chart:{
            renderTo:'container'
        },
        title:{
            text:'指標資料'
        },
        tooltip:{
            pointFormat:'{series.name}:<b>{point.y}</b>'
        },
        xAxis:{
            categories:[]
        },
        yAxis:{
            title:{
                text:'數值'
            }
        },
        series:[]
};
    /**
    *categories:[]
    *series:[
    *         {
    *            name:''
    *              data:[]
    *          }
    *        ]
    */       
         function changeHighchartsOption(categories,series){
        highchartsOptions.xAxis.categories = categories;
        highchartsOptions.series = series;    
        newHighcharts('line');
    }
    
    function newHighcharts(type){
        highchartsOptions.chart.type = type;
        new Highcharts.Chart(highchartsOptions);
    }    

 

相關文章