对于具有顶部设置的yAxis,Highstock标志位置不正确

时间:2013-11-04 03:46:30

标签: highcharts highstock

看来highstock并没有按预期工作

http://jsfiddle.net/gCuLJ/1/

我只是创建了一个带有固定顶部和高度的y轴的高压图表。

然后我添加了一个新的y轴,其顶部和高度设置为将图表堆叠在第一个下面。

现在我在第二个y轴系列上设置了一些标志。

标志显示在第一个y轴系列的某处。

添加按钮处理程序代码:

$('#button').click(function() {
    var chart = $('#container').highcharts();

    chart.addAxis({
        id:'secondY',            
        top:300,// making this 140 positions flags correctly
        height:150
    });

    chart.addSeries({
        id:'adbe',
        yAxis:'secondY',
        name: 'ADBE', 
        data: ADBE
    });
    $(this).attr('disabled', true);

    chart.addSeries(
    // the event marker flags
        {
            type : 'flags',
            data : [{
                x : Date.UTC(2011, 3, 25),
                title : 'H',
                text : 'Euro Contained by Channel Resistance'
            }, {
                x : Date.UTC(2011, 3, 28),
                title : 'G',
                text : 'EURUSD: Bulls Clear Path to 1.50 Figure'
            }],
            onSeries : 'adbe',
            shape : 'circlepin',
            width : 16
        });


});

1 个答案:

答案 0 :(得分:1)

答案在这里:http://jsfiddle.net/nmccready/wXZ4H/1/https://github.com/highslide-software/highcharts.com/issues/2425

您需要为您需要的任何yAx分配一个ID。

$(function() {
$('#container').highcharts('StockChart', {
    chart: {
            zoomType: 'x',
            marginTop: 100, //avoid overlapping with navigator
            spacingLeft: 0
        },
    scrollbar: {
        enabled: false
    },

    navigator: {
        enabled: true,
        top: 40
    },

    rangeSelector: {
        selected: 1
    },
    yAxis:[{
        id: 'firstY',
        top:140,
        height:150
    }],
    series: [{
        id:'msft',
        name: 'MSFT',            
        data: MSFT,
        yAxis: 'firstY'
    }]
});

$('#button').click(function() {
    var chart = $('#container').highcharts();

    chart.addAxis({
        title:'duh',
        id:'secondY',            
        top:300,
        height:150
    });

    chart.addSeries({
        id:'adbe',
        yAxis:'secondY',
        name: 'ADBE', 
        data: ADBE
    });
    $(this).attr('disabled', true);

    chart.addSeries(
    // the event marker flags
        {
        yAxis:'firstY',
            type : 'flags',
            data : [{
                x : Date.UTC(2011, 3, 25),
                title : 'H',
                text : 'Euro Contained by Channel Resistance'
            }, {
                x : Date.UTC(2011, 3, 28),
                title : 'G',
                text : 'EURUSD: Bulls Clear Path to 1.50 Figure'
            }],
            onSeries : 'msft',
            shape : 'circlepin',
            width : 16
        });



});

});