chenxuuu / llcom

🛠功能强大的串口工具。支持Lua自动化处理、串口调试、WinUSB、串口曲线、TCP测试、MQTT测试、编码转换、乱码恢复等功能
https://llcom.papapoi.com/
Apache License 2.0
823 stars 201 forks source link

关于Chart曲线界面的代码设计 #157

Open mt6595 opened 7 months ago

mt6595 commented 7 months ago

您的功能请求是否与解决某些问题有关?请描述一下。/ Is your feature request related to a problem? Please describe.

优化

描述您想要的解决方案 / Describe the solution you'd like

优化

描述您想要的详细使用步骤描述 / Describe the solution you'd like to use in what way

使用

            for (int i = 0; i < DataY.Length; i++)
            {
                if (DataY[i] == null)
                    DataY[i] = new double[MaxPoints];
                Plot.Plot.AddSignal(DataY[i]);
            }

替代

            DataX = new double[MaxPoints];
            for (int i = 0; i < MaxPoints; i++)
                DataX[i] = i - MaxPoints + 1;
            for (int i = 0; i < Data.Length; i++)
            {
                if(Data[i] == null)
                    Data[i] = new double[MaxPoints];
                Plot.Plot.AddSignalXY(DataX, Data[i]);
            }

--------------------------------------------------分割线------------------------------------------------- 使用

            Plot.Plot.AxisAuto();

替代

            Plot.Plot.SetAxisLimitsX(-MaxPoints, 0);
            //防止最大值最小值错误
            var min = Data.Min(x => x.Min());
            var max = Data.Max(x => x.Max());
            if(min < max)
                Plot.Plot.SetAxisLimitsY(min, max);

--------------------------------------------------分割线------------------------------------------------- 使用

            Array.Copy(DataY[line], 1, DataY[line], 0, DataY[line].Length - 1);

替代

            for(int i = 0;i < MaxPoints - 1;i++)
                Data[line][i] = Data[line][i + 1];

--------------------------------------------------分割线------------------------------------------------- 十字光标掉帧严重,建议提高刷新率或者移除十字光标

其他备注信息或截图 / Add any other context or screenshots about the feature request here

No response

chenxuuu commented 6 months ago

DataY是什么

AxisAuto里面的代码,比我写的还复杂好多,而且会擅自调整可视范围,用户会被不停地强制缩放到自适应尺寸

Array.Copy确实快