Highchart只显示点数

时间:2014-01-04 13:43:01

标签: highcharts

我是html和javascript的新手。 我正在尝试使用csv数据文件制作样条图,但图表仅显示点。 谁能帮助我?提前致谢。 解析csv代码如下:

    jQuery.get(dataFilePath, null, function(csv, state, xhr) {
        var lines = [],
            date,

            // set up the two data series
            lightLevels = [];

        // inconsistency
        if (typeof csv !== 'string') {
            csv = xhr.responseText;
        }

        // split the data return into lines and parse them
        csv = csv.split(/\n/g);
        jQuery.each(csv, function(i, line) {

            // all data lines start with a double quote
            line = line.split(',');
            date = parseInt(line[0], 10)*1000;

            lightLevels.push([
                date,
                parseFloat(line[1], 10)
            ]);

        });

        options.series[0].data = lightLevels;

        chart = new Highcharts.Chart(options);
    });
});     
});

图表代码是:

chart: {
            type: 'spline',
            backgroundColor: '#464344',
            renderTo: 'container',
            zoomType: 'x',
            spacingRight: 20,
        },
        navigator: {
        enabled: true,
        height: 15
        },
        scrollbar: {
        enabled: true,
        height: 5
        },

        rangeSelector: {
            enabled: true,
            buttons: [{
            type: 'minute',
                count: 30,
                text: '30m'
            }, {
            type: 'minute',
                count: 60,
                text: '1h'
            }, {
            type: 'minute',
                count: 180,
                text: '3h'
            }, {
            type: 'day',
                count: 1,
                text: '1d'
            }, {
            type: 'day',
                count: 2,
                text: '2d'
            }, {
            type: 'all',
                text: 'All'
            }],

            inputDateFormat: '%b %e/%H:%M',
            inputEditDateFormat: '%b-%e/%H:%M',
            inputDateParser: function(value) {
            value = value.split(/[:\.]/);
            return Date.UTC(
                1970, 
                0, 
                1, 
                parseInt(value[0]),
                parseInt(value[1]),
                parseInt(value[2]),
                parseInt(value[3])
            );
        },
        }, 

        title: {
            text: 'Pistas Foam - Cloro Livre (mg/l)'
        },

        subtitle: {
            text: 'Clique e arraste na area do grafico para zoom'
        },

        xAxis: {
            type: 'datetime',
            maxZoom: 1 * 1800000
        },

        yAxis: {
            title: {
                text: 'Cloro Livre mg/l (0 - 5)'
            },
            min: 0,
            startOnTick: false,
            showFirstLabel: false
        },

        legend: {
            enabled: false
        },

        tooltip: {
            formatter: function() {
                    return '<b>'+ this.series.name +'</b><br/>'+
                    Highcharts.dateFormat('%H:%M - %b %e, %Y', this.x) +': '+ this.y;
            }
        },

        plotOptions: {
            series: {
                cursor: 'pointer',
                lineWidth: 1.0,
                point: {
                    events: {
                        click: function() {
                            hs.htmlExpand(null, {
                                pageOrigin: {
                                    x: this.pageX,
                                    y: this.pageY
                                },
                                headingText: this.series.name,
                                maincontentText: Highcharts.dateFormat('%H:%M - %b %e, %Y', this.x) +':<br/> '+
                                    this.y,
                                width: 200
                            });
                        }
                    }
                },
            }
        },

        series: [{
            name: 'Cloro Livre',
            marker: {
                radius: 2
            }
        }]
    };

0 个答案:

没有答案