Posting data to the server from highchart points

73 views Asked by At

I am trying to post data from highcharts.

  point: {
    events: {
        click: function (e) {
            hs.htmlExpand(null, {
                pageOrigin: {
                    x: e.pageX || e.clientX,
                    y: e.pageY || e.clientY
                },
                headingText: this.series.name,
                maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) + ':<br/> ' +
                    this.y + ' visits ' + '<div>'+'<button onclick="posting(this.y)">'+'send report' +'</button>'+'</div>',
                width: 200
            });
        }
    }
}

I am calling a function on clicking the button and I want to send data to it. How can we send this.y to posting() function so that we get current point value in the function. This fiddler is showing the undefined in alert. How can I achieve the this.y value there. Click on the points in the chart then click the send report button and you will get my problem.

2

There are 2 answers

0
szinter On BEST ANSWER

It will solve the problem if you use

<button onclick="posting('+this.y+')">'+'send report' +'</button>'+'</div>'

instead of

<button onclick="posting(this.y)">'+'send report' +'</button>'+'</div>'
0
JimboSlice On

You have to pass the this.y value into the string as a variable. check my modification inside the click function at this.y on line 84

http://jsfiddle.net/8zsyg26a/2

maincontentText: Highcharts.dateFormat('%A, %b %e, %Y', this.x) + ':<br/> ' +
                                        this.y + ' visits ' + '<div>'+'<button onclick="posting(' + this.y + ')">'+'send report' +'</button>'+'</div>',