highcharts 动态设置series

$.ajax({
    url: ctx + "/projectReport/report3",
    type: 'post',
    dataType: "json",
    async: false,
    cache: false,
    success: function (odata3) {
        if (odata3.result == 1) {
            var series=[];
            var projectNames=odata3.projectNames;
            var countRecordproject=odata3.countRecordproject;
            for(var i=0;i;i++){
                series.push({"name":projectNames[i],"data":eval("["+countRecordproject[i]+"]")});
            }
            $('#container3').highcharts({
                title: {
                    text: '公司未结款项目收款统计图',
                    x: -20 //center
                },
                subtitle: {
                    x: -20
                },
                chart: {
                    type: 'line',
                    width: 800,
                    height: 460
                },
                credits: {
                    enabled: false
                },//去除水印
                xAxis: {
                    title: {
                        text: '日期(//)'
                    },
                    categories: odata3.showXdate.split(","),
                    crosshair: true
                },
                yAxis: {
                    title: {
                        text: '金额(元)'
                    }
                },
                //绑定鼠标放上后显示的字段
                tooltip: {
                    pointFormat: '{series.name}: {point.percentage:.1f}%'
                },
                legend: {
                    layout: 'vertical',
                    align: 'right',
                    verticalAlign: 'middle',
                    borderWidth: 0
                },
                plotOptions: {
                    line: {
                        connectNulls:true,//该设置会连接空值点
                        // gapSize:1,//缺失点小于gapSize则连接
                        dataLabels: {
                            enabled: true
                        },
                        enableMouseTracking: false
                    }
                },
                series:series
            });
        }
    }
});

你可能感兴趣的:(js)