質問

I'm trying to alert/fetch the period value from SMA indicator series if the series is clicked.

series : [{
                name: 'AAPL Stock Price',
                type : 'line',
                id: 'primary',
                data : data
            }, {
                name: '15-day SMA',
                linkedTo: 'primary',
                showInLegend: true,
                type: 'trendline',
                algorithm: 'SMA',
                periods: 15
            }]

SMA technical indicators- http://jsfiddle.net/laff/WaEBc/

In the reference the period value is defined 15. just alert this value. Thanks in advance.

役に立ちましたか?

解決

You can set event click directly in series options:

        series : [{
            name: 'AAPL Stock Price',
            type : 'line',
            id: 'primary',
            data : data
        }, {
            name: '15-day SMA',
            linkedTo: 'primary',
            showInLegend: true,
            type: 'trendline',
            algorithm: 'SMA',
            periods: 15,
            events: {
                click: function() {
                    console.log(this.options.periods);
                }
            }
        }]

Demo: http://jsfiddle.net/WaEBc/32/

他のヒント

Try put into plot options block click handler like this:

    plotOptions: {
        series: {
            point: {
                events: {
                    click: function() {
                        var i = this.x;
                    }
                }
            }
        }
    },

Investigate in the debug properties of this object

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top