plotbands target one of the two panes

房东的猫 提交于 2019-12-11 10:36:01

问题


hi i am using the two panes chart http://www.highcharts.com/stock/demo/candlestick-and-volume i then put a plodBands to that chart , what happened is the Band affect both yAxis like in here http://jsfiddle.net/6sqEd/ what i have noticed is this chart has only one xAxis .

How can i make this PlotBands arget only the first yAxis Not BOTH ???

here is the code :

    $(function() {
   $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-  ohlcv.json&callback=?', function(data) {

    // split the data set into ohlc and volume
    var ohlc = [],
        volume = [],
        dataLength = data.length;

    for (i = 0; i < dataLength; i++) {
        ohlc.push([
            data[i][0], // the date
            data[i][1], // open
            data[i][2], // high
            data[i][3], // low
            data[i][4] // close
        ]);

        volume.push([
            data[i][0], // the date
            data[i][5] // the volume
        ])
    }


    // create the chart
    chart = new Highcharts.StockChart({
        chart: {
            renderTo: 'container',
            alignTicks: false
        },

        rangeSelector: {
            selected: 5
        },

        title: {
            text: 'AAPL Historical'
        },
        xAxis:[{
            plotBands : [{
                from : 1115856000000,
                to : 1128384000000,
                color : 'rgba(68, 170, 213, 0.2)',
                label : {
                    text : 'Last quarter\'s value range'
                }
            }]


        }],

        yAxis: [{
            title: {
                text: 'OHLC'
            },
            height: 200,
            lineWidth: 2
        }, {
            title: {
                text: 'Volume'
            },
            top: 300,
            height: 100,
            offset: 0,
            lineWidth: 2
        }],

        series: [{
            type: 'candlestick',
            name: 'AAPL',
            data: ohlc,

        }, {
            type: 'column',
            name: 'Volume',
            data: volume,
            yAxis: 1,

          }]
       });
       });
     });​

回答1:


When you add a plotBand to the yAxis you can set just higger and lower points.
If you put the plotBand on the xAxis it will be displayed on all yAxis.
So if you want to plot just on the first axis probably you have to make a new serie with the same style of a plotBand an add to it.

First: You've to create an area serie from the start date to the end date wich all values will be the same of the maximum value of the pane. In my example it's 800.

Second: Make sure the maximum value is higher than the highest value of your serie. II didn't do it in my example, so you have to do it on your code.
Third: Remove the serie from the legend and from the tooltip setting the enableMouseTracking and showInLegend to false.

Example



来源:https://stackoverflow.com/questions/10421177/plotbands-target-one-of-the-two-panes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!