Highcharts:多轴上的未对齐日期

时间:2014-01-17 16:55:14

标签: highcharts

我正在使用两个Y和两个X轴的Stockchart图。当我将selected上的rangeSelector设置为高位时,它可以正常工作。但如果它需要削减一些月份,则两个x轴会变得不对齐。上面的两个折线图似乎从图表之外开始。

小提琴:http://jsfiddle.net/gn393/5/selected设置为高,对齐)

小提琴:http://jsfiddle.net/gn393/6/selected设置为低,未对齐)

在放大上述示例时,x轴下方的折线图不会改变。我使用afterSetExtremes。但这个问题在上述小提琴中仍然可以重现。

yAxis: [{
    height: 420,
    lineWidth: 2,
}, {
    top: 500,
    height: 210,
    lineWidth: 2,
}],
xAxis: [{
    type: 'datetime',
    opposite: true,
    offset: -700,
},{
    type: 'datetime',

    offset: -200,
}],

1 个答案:

答案 0 :(得分:1)

如果你有两个xAxis,你需要渲染按钮并在两个动作上调用setExtremes函数。因为按钮仅适用于第一个xAxis。第二个解决方案是使用afterSetExtremes并在第二个xAxis上调用setExtremes。

编辑: http://jsfiddle.net/gn393/8/

xAxis: [{
                    type: 'datetime',
                    opposite: true,
                    offset: -700,
                    events:{
                        afterSetExtremes:function(){
                            var min = this.min,
                                max = this.max,
                                chart = this.chart;

                            chart.xAxis[1].setExtremes(min,max);

                        }
                    },
                },{
                    type: 'datetime',

                    offset: -200,
                }],