Highchart与多个Y轴崩溃

时间:2013-02-04 17:42:44

标签: javascript highcharts

当我添加第二个系列时,我的高保真崩溃了铬 无法看到Chrome控制台调试.. :(
有没有人有想法?

$(function () {
    var chart;
    $(document).ready(function() {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'line',
                margin: [40,10,60,80],
            },
            title: {
                text: 'Temperature Today'
            },
            xAxis: {
                type: 'datetime',    
                dateTimeLabelFormats: {
                    day: '%H:%M'
                },
                tickInterval: 3600 * 1000,
                labels: {
                    rotation: -45,
                    align: 'right',

                    style: {
                        fontSize: '10px',
                        fontFamily: 'Verdana, sans-serif'
                    }
                },
            }, 
            yAxis: {
                title: {
                    text: 'Temperature'
                },
                minorGridLineWidth: 0,
                /* gridLineWidth: 0, */
                /* alternateGridColor: null */
            },
            tooltip: {
                formatter: function() {
                        return ''+
                        Highcharts.dateFormat('%H:%M', this.x) +': '+ this.y;
                }
            },
            plotOptions: {
                spline: {
                    lineWidth: 4,
                    states: {
                        hover: {
                            lineWidth: 3
                        }
                    },
                    marker: {
                        enabled: false,
                        states: {
                            hover: {
                                enabled: true,
                                symbol: 'circle',
                                radius: 3,
                                lineWidth: 1
                            }
                        }
                    },
                }
            },
            series: [{
                    name: 'Temperature',
                    data: temp,
                    type: 'line',
                    showInLegend: false,
                    pointInterval: 60 * 1000,
                    pointStart: Date.UTC(2006, 0, 1),
                        marker: {
                            enabled: false
                        },
                    dashStyle: 'solid',
                    yAxis: 0,
                    xAxis: 0,
                    } , {
                    name: 'Humdity',
                    data: hum,
                    yAxis: 1,
                    xAxis: 0,
                    showInLegend: false,
                    type: 'line',
             }],
            navigation: {
                menuItemStyle: {
                    fontSize: '6px'
                }
            }
        });
    });

});

1 个答案:

答案 0 :(得分:1)

你只有一个yAxis,所以它会中断,因为你设置了第二个系列显示在第二个系列中(是的,这就是yAxis: 1的意思)。

删除它或创建第二个yAxis

<强>更新

  • 使用yAxis: 0第一个和1到第二个。
  • 在jsfiddle的第36行,之后遗失}
  • 之前存储数据。

Demo

相关问题