给折线图添加点击函数,我暂时先在html中修改了代码,iOS 版本
function configureChartTouchEvent(aaPlotOptions) {
var mouseOverFunc = function() {
var message = {
name: this.series.name,
y: this.y,
x: this.x,
category:this.category,
offset: {plotX: this.plotX, plotY: this.plotY},
index: this.index,
};
window.webkit.messageHandlers.mouseover.postMessage(message);
};
var clickedFunc = function(e){
var message = {
name: this.series.name,
y: this.y,
x: this.x,
category:this.category,
offset: {plotX: this.plotX, plotY: this.plotY},
index: this.index,
};
window.webkit.messageHandlers.customevent.postMessage(message);
};
if (aaPlotOptions.series.point) {// set property directlly for series point
aaPlotOptions.series.point.events.mouseOver = mouseOverFunc;
aaPlotOptions.series.point.events.click = clickedFunc;
} else {// creat a new series point object instance
var seriesPoint = {
events:{
mouseOver: mouseOverFunc,
click :clickedFunc,
}
};
aaPlotOptions.series.point = seriesPoint;
}
}
希望作者能
我怎么没有看懂
@silendir 这个是一些 js 的方法 首先了解一下 Highcharts 是如何添加 点击方法的 就好了。
```js function configureChartTouchEvent(aaPlotOptions) { var mouseOverFunc = function() { var message = { name: this.series.name, y: this.y, x: this.x, category:this.category, offset: {plotX: this.plotX, plotY: this.plotY}, index: this.index, }; window.webkit.messageHandlers.mouseover.postMessage(message); }; var clickedFunc = function(e){ var message = { name: this.series.name, y: this.y, x: this.x, category:this.category, offset: {plotX: this.plotX, plotY: this.plotY}, index: this.index, }; window.webkit.messageHandlers.customevent.postMessage(message); }; if (aaPlotOptions.series.point) {// set property directlly for series point aaPlotOptions.series.point.events.mouseOver = mouseOverFunc; aaPlotOptions.series.point.events.click = clickedFunc; } else {// creat a new series point object instance var seriesPoint = { events:{ mouseOver: mouseOverFunc, click :clickedFunc, } }; aaPlotOptions.series.point = seriesPoint; } }希望作者能
大大你好,我正好在寻找将回调方式从mouseOver切换成click的方法,不过我使用的是swift版本,想请问加入这段代码后,要如何设定成只监听用户的点击事件而不是拖动,非常感激!
这个需要实现两个协议方法,一个点击的还有一个是 移动的两者都实现后才能 知道点击的方法 @alex851209
或者是将 js 中本来是 滑动的方法改成点的方法 但是不推荐这样,有背以后使用 var clickedFunc = function(e) { var message = { name: this.series.name, y: this.y, x: this.x, category:this.category, offset: {plotX: this.plotX, plotY: this.plotY}, index: this.index, }; window.webkit.messageHandlers.mouseover.postMessage(message); }; qq : 17603115734 可以直接跟我沟通 @alex851209
@lanligang 了解!我现在需要的功能是只追踪点击事件以进入相关页面,原本mouseover的event会跟折线图的scrolling冲突(触發func而无法scroll),如果无需使用到追踪滑动的功能,是否就照上面的代码将滑动更改成点击就能达到呢?很感谢你的回复
@alex851209 这个是heightchart 的功能 不能滚动,确实会冲突,应该可以用双指缩放状态下可以拖动,我有时间看看heightchart 如何修改,如果真的有特殊情况你可以问一下你们公司的前端的使用eacharts 或者用其他手段,我们当时有一个特殊的地方,但是是不用滑动的当时我嵌入了eachars 从后端给的代码中扒出来js代码植入交互的 html文件 做了两端都能用的文件,可能名字我写的不太对,见谅。
@lanligang 好的,所以目前是可以透过修改代码将mouseover的追踪事件更改成点击,但是仍然会跟滚动冲突吗?本来以为将mouseover更改成click的话可以达到类似ios原生touchUpInside的效果,也就是在手指未离开屏幕的情况下就不会跟滚动冲突,可能是我想错了QQ如果还有什麽方法能达到的话希望能跟我分享,谢谢。
@lanligang 剛剛照你的code修改完,可以改成click了,也不會與scroll衝突!!真的太感謝你了