Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vueVersion为3的时候,k线图无法拖动和缩放 #153

Closed
LiuYuZhang opened this issue Apr 10, 2023 · 5 comments
Closed

vueVersion为3的时候,k线图无法拖动和缩放 #153

LiuYuZhang opened this issue Apr 10, 2023 · 5 comments

Comments

@LiuYuZhang
Copy link

作者您好,我在uni-app中新建项目,然后在插件市场https://ext.dcloud.net.cn/plugin?id=4591#rating 导入插件,将您测试项目中的hqchart2_test/index.vue文件复制到我所建的项目中,vueVersion:3,然后运行,能跑起来,但是无法缩放,和移动,
如果把vueVersion改成2就正常
a
b

@LiuYuZhang
Copy link
Author

为了方便您测试,以下是测试demo
testssss.zip

@jones2000
Copy link
Owner

vue2 和 vue3的touch事件的event.touches结构不一样。 需要你自己外部把vue3的event数据转成vue2的touch事件的event结构

@jones2000
Copy link
Owner

jones2000 commented Apr 11, 2023

//vue3 event 结构  
{
   .......
    "touches": {
        "0": {
            "x": 200.3883514404297,
            "y": 212.44757080078125
        }
    },
   ......
}

//vue2  event结构
{

    "touches": [
        {
            "x": 151.12344360351562,
            "identifier": 0,
            "y": 189.7986297607422
        }
    ],
}

touches, changedTouches 这2个都是转成数组才可以

@jones2000
Copy link
Owner

jones2000 commented Apr 11, 2023

//手势事件 app/小程序才有
//KLine事件
KLineTouchStart (event) 
{
	if (g_JSChart) 
	{
		var backup=this.ConvertTouchEventData(event);
		g_JSChart.OnTouchStart(event);
		this.RestoreTouchEventData(backup,event) //还原原来的event结构  
	}
},
		
KLineTouchMove (event) 
{
	if (g_JSChart) 
	{
		var backup=this.ConvertTouchEventData(event);
		g_JSChart.OnTouchMove(event);
                 this.RestoreTouchEventData(backup,event) //还原原来的event结构  
	}          
},
		
KLineTouchEnd (event) 
{
	if (g_JSChart) 
	{
		this.ConvertTouchEventData(event);
		g_JSChart.OnTouchEnd(event);
                this.RestoreTouchEventData(backup,event) //还原原来的event结构
	}
},
		
ConvertTouchEventData(event)
{
	if (Array.isArray(event.touches)) return null;  
	var touches=event.touches;	//备份下  
	var aryTouches=[];
	for(var i=0;i<10;++i)
	{
		var key=i.toString();
		var item=event.touches[key];
		if (!item) break;
		
		aryTouches[i]=item;
	}
	
	event.touches=aryTouches;
	
	var changedTouches=event.changedTouches;
	var aryChangedTouches=[];
	for(var i=0;i<10;++i)
	{
		var key=i.toString();
		var item=event.changedTouches[key];
		if (!item) break;
		
		aryChangedTouches[i]=item;
	}
	
	event.changedTouches=aryChangedTouches;
	
	console.log('ConvertTouchEventData' ,event )
	
	return {Touches:touches, ChangedTouches:changedTouches };
},
		
RestoreTouchEventData(backup, event)
{
	if (!backup) return;  
	
	event.touches=backup.Touches;	//还原原来的touches结构  
	event.changedTouches=backup.ChangedTouches
	
	console.log('RestoreTouchEventData' ,event )
},

@LiuYuZhang
Copy link
Author

感谢作者大大解答

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants