admin管理员组

文章数量:1390391

I'm using the HighStock stock charting library to generate a basic OHLC stock chart. I want to perform some action when the chart is generated (and after it's regenerated by changing the displayed time frame). I'm trying to do this using the plotOptions.ohlc.events.show event (documentation).

The problem I'm having is the even isn't firing at all. If I follow the example for the click event, the alert fires correctly when I click the series.

var chart = new Highcharts.StockChart({
    chart: {
        renderTo: 'divChart',
        height: 450
    },

    rangeSelector: {
        selected: 2
    },

    xAxis: {
        maxZoom: 14 * 24 * 3600000
    },

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

    title: {
        text: 'Stock Chart'
    },

    series: [{
        type: 'ohlc',
        name: 'Prices',
        id: 'prices',
        data: ohlc
    }, {
        type: 'column',
        name: 'Volume',
        data: volume,
        yAxis: 1
    }],

    // The event I am trying to bind to
    plotOptions: {
        series: {
            events: {
                show: function () {
                    alert("show");
                }
            }
        }
    }
});
  • Is this the correct way to fire an event when the chart is redrawn?
  • If so, why isn't the event firing, and how do I fix it?

I'm using the HighStock stock charting library to generate a basic OHLC stock chart. I want to perform some action when the chart is generated (and after it's regenerated by changing the displayed time frame). I'm trying to do this using the plotOptions.ohlc.events.show event (documentation).

The problem I'm having is the even isn't firing at all. If I follow the example for the click event, the alert fires correctly when I click the series.

var chart = new Highcharts.StockChart({
    chart: {
        renderTo: 'divChart',
        height: 450
    },

    rangeSelector: {
        selected: 2
    },

    xAxis: {
        maxZoom: 14 * 24 * 3600000
    },

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

    title: {
        text: 'Stock Chart'
    },

    series: [{
        type: 'ohlc',
        name: 'Prices',
        id: 'prices',
        data: ohlc
    }, {
        type: 'column',
        name: 'Volume',
        data: volume,
        yAxis: 1
    }],

    // The event I am trying to bind to
    plotOptions: {
        series: {
            events: {
                show: function () {
                    alert("show");
                }
            }
        }
    }
});
  • Is this the correct way to fire an event when the chart is redrawn?
  • If so, why isn't the event firing, and how do I fix it?
Share Improve this question edited Dec 2, 2011 at 23:21 Kyle Trauberman asked Dec 2, 2011 at 23:08 Kyle TraubermanKyle Trauberman 25.7k13 gold badges87 silver badges124 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 6

Change the chart part to something similar

chart: {
        renderTo: 'container',
        events: {
            redraw: function(){   // or load - refer to API documentation
             alert('Chart Loaded');   
            }
        }
    },

They've got a nice API browser - might e in handy http://www.highcharts./ref/#chart-events--load

本文标签: javascriptHighCharts Stock Chart fire event on chart redrawStack Overflow