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

DataZoom组件导致 两个散点图会互相影响 #252

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

DataZoom组件导致 两个散点图会互相影响 #252

shangchengwen opened this issue Apr 10, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@shangchengwen
Copy link

          之前没仔细找,应该是DataZoom组件导致的

创建两个散点图,用下面的脚本
没有DataZoom组件的时候正常,一个图数据增,一个图数据减
两个散点图都添加DataZoom组件后会互相影响

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XCharts.Runtime;

public class XchartTest : MonoBehaviour
{
public GameObject obj_distance;
public GameObject obj_angle;

private ScatterChart chart_distance;
private ScatterChart chart_angle;

private Serie serie_distance;
private Serie serie_angle;

public int data_index = 0;
int data_index_max = 3000;

void Start()
{
    ChartInit();
}


int int_angle = 0;
int int_distance = 0;
int time_in = 0;
private void Update() {
    if(time_in++%100!=0){
        return;
    }
    int_angle+=5;
    int_distance-=3;
    if (data_index == 0)
        {
            if (serie_angle != null)
            {
                serie_angle.UpdateXYData(data_index, data_index, int_angle);
            }

            if (serie_distance != null)
            {
                serie_distance.UpdateXYData(data_index, data_index, int_distance);
            }

        }
        else if (data_index < data_index_max)
        {
            if (serie_angle != null)
                serie_angle.AddXYData(data_index, int_angle);
            if (serie_distance != null)
                serie_distance.AddXYData(data_index, int_distance);
        }
        else
        {
            if (serie_angle != null)
            {
                serie_angle.UpdateXYData(data_index % data_index_max, data_index, int_angle);
            }
            if (serie_distance != null)
            {
                serie_distance.UpdateXYData(data_index % data_index_max, data_index, int_distance);
            }

        }
        data_index++;
}

private void ChartInit()
{
    chart_distance = obj_distance.GetComponent<ScatterChart>();
    chart_angle = obj_angle.GetComponent<ScatterChart>();
    SetAxis(chart_distance);
    SetAxis(chart_angle);
    serie_angle = chart_angle.GetSerie("serie0");
    serie_distance = chart_distance.GetSerie("serie0");
    ClearData();
}

public void ClearData()
{
    serie_angle.ClearData();
    serie_distance.ClearData();
}

private void SetAxis(ScatterChart chart)
{
    XAxis xAxis = chart.GetOrAddChartComponent<XAxis>();
    xAxis.minMaxType = XAxis.AxisMinMaxType.MinMax;
    YAxis yAxis = chart.GetOrAddChartComponent<YAxis>();
    yAxis.minMaxType = YAxis.AxisMinMaxType.MinMax;
}

}
`

Originally posted by @shangchengwen in #239 (comment)

@monitor1394
Copy link
Collaborator

方便给一下异常的效果图或者视频吗

@monitor1394
Copy link
Collaborator

DataZoom是怎么设置的

@shangchengwen
Copy link
Author

Snipaste_2023-04-14_14-48-48
创建两个散点图
用我上面的脚本
把两个散点图拖入
此时运行是正常的
Snipaste_2023-04-14_14-50-52
两个散点图分别都加上Data Zoom组件
Snipaste_2023-04-14_14-51-10
就会相互影响了
Snipaste_2023-04-14_14-51-06
没有更改任何配置
用的是XCharts-3.6.0.unitypackage

@monitor1394
Copy link
Collaborator

确认了是有这个问题,谢谢反馈。

@monitor1394
Copy link
Collaborator

master已修复提交。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants