Highcharts:如何将数据从javascript变量加载到xAxis.categories和series.data?

时间:2016-08-25 04:54:35

标签: javascript highcharts

对不起初学者的问题。

这是我的javascript变量看起来像

['08/25','08/26','08/27','08/28','08/29','08/30','08/31','09/01','09/02','09/03','09/04','09/05','09/06','09/07','09/08','09/09','09/10','09/11','09/12','09/13','09/14','09/15','09/16','09/17','09/18','09/19','09/20','09/21','09/22','09/23','09/24','09/25','09/26','09/27','09/28','09/29','09/30','10/01','10/02','10/03','10/04','10/05','10/06','10/07','10/08','10/09','10/10','10/11','10/12','10/13','10/14','10/15','10/16','10/17','10/18','10/19','10/20','10/21','10/22','10/23','10/24','10/25','10/26','10/27','10/28','10/29','10/30','10/31','11/01','11/02','11/03','11/04','11/05','11/06','11/07','11/08','11/09','11/10','11/11','11/12','11/13','11/14','11/15','11/16','11/17','11/18','11/19','11/20','11/21','11/22']

这是我的Javascript,

function changeGraph(rate, currency, site_id, room_code, keyword_mst){

var graph_categories = getPeriod(new Date());

$('#hotelByGraph').highcharts(
            {
            title:
                {
                    text: 'Plan Detail',
                    x: -20 //center
                },
            xAxis:
                {
                    categories: graph_categories
                },
            }
}
function getPeriod(date){
var periodReturn = '[';
var tmp = 1;

for(var i = 0 ; i < 90 ; i++){
    if(i !== 0)
        date.setDate(date.getDate()+tmp);
    else
        date.setDate(date.getDate());

    if(i != 89)
        periodReturn += "'"+toDoubleDigits(date.getMonth()+1)+"/"+toDoubleDigits(date.getDate())+"',";
    else
        periodReturn += "'"+toDoubleDigits(date.getMonth()+1)+"/"+toDoubleDigits(date.getDate())+"']";
}

return periodReturn;
}

你能指出我哪里出错吗?

0 个答案:

没有答案