将数据从高图表点发布到服务器



我正在尝试发布来自高图表的数据。

  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
            });
        }
    }
}

我在单击按钮时调用了一个函数,我想向其发送数据。我们如何将this.y发送到函数posting()以便我们在函数中获取当前点值。这个小提琴手正在警戒地显示undefined。我怎样才能在那里实现this.y值。单击图表中的,然后单击发送报告按钮,您将遇到我的问题。

如果您使用

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

而不是

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

您必须将 this.y 值作为变量传递到字符串中。 在第 84 行的 this.y 的点击函数中检查我的修改

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>',

最新更新