gpt4 book ai didi

c# - MSChart插入、移动、删除点

转载 作者:太空宇宙 更新时间:2023-11-03 16:24:40 27 4
gpt4 key购买 nike

第一次在这里发帖但是已经来过 1000 次了,真的很喜欢其他成员的贡献。我知道你们中的许多人会翻白眼,但我没有太多可以开始的。我对 C#、MS C 的基础知识以及更多的 Microchip C 和 ASM 有一定的了解。尝试为 WinCE6 制作一个应用程序作为家庭自动化主 Controller ,让我的大部分模块正常工作,没有时间将各个部分放在一起,有一个包含 50 列和 1440 行的 SQLCE 数据库,即 50 台设备和 1440 分钟1 天,所有控件将每天重复其功能。数据库当前填充了用于测试的随机数据,现在我想创建一个可视化控件来创建数据,找不到 MSChart 控件的 CE 版本,所以我决定制作一个 x86 应用程序来创建我的数据。我的困难主要来自经验不足,我可以向系列添加或插入点,但它们不会按照我想要的顺序插入。

在这个示例中,您可以看到我想要实现的目标;1 没有数据点所有 1440 条记录将具有相同的值。2 加点到 200,400,600,800,1000,1100。3 将 Y 上 400 处的点从 270 移动到 350。4 个删除点在 200,400,600,800。

接受所有建议。无法上传图片,请点击链接。谢谢

imgur.com/zsBla.jpg
imgur.com/y4wsn.jpg
imgur.com/Yo4XH.jpg
imgur.com/7FgHn.jpg


private void chart1_MouseClick(object sender, MouseEventArgs e)
{
var pos = e.Location;
clickPosition = pos;
var results = chart1.HitTest(pos.X, pos.Y, false, ChartElementType.PlottingArea);
foreach (var result in results)
{
if (result.ChartElementType == ChartElementType.PlottingArea)
{
var xVal = result.ChartArea.AxisX.PixelPositionToValue(pos.X);
var yVal = result.ChartArea.AxisY.PixelPositionToValue(pos.Y);
//tooltip.Show("x=" + xVal + ", y=" + yVal, this.chart1, e.Location.X, e.Location.Y - 15);
tk++;
chart1.Series[0].Points.InsertXY (0,tk,yVal);
//chart1.Series[0].Sort(PointSortOrder.Ascending);//.Points.InsertXY(0,xVal, yVal);
Tick.Text = tk.ToString();
}

}
}

最佳答案

Elcast,查看你的问题看起来你真正的问题是你希望你的数据是“一对一”的,你几乎用你的排序数据得到它,但可能实际问题是你如何对数据进行排序。

我整理了一个快速演示,希望能帮助您解决问题:

 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Chart1.Series(0).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line
Chart1.Series(0).Points.AddXY(0, 10)
Chart1.Series(0).Points.AddXY(1440, 100)
Chart1.Series(0).Points.AddXY(600, 80)

Chart2.Series(0).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line
Chart2.Series(0).Points.AddXY(0, 10)
Chart2.Series(0).Points.AddXY(1440, 100)
Chart2.Series(0).Points.AddXY(600, 80)

Chart1.DataManipulator.Sort(System.Windows.Forms.DataVisualization.Charting.PointSortOrder.Descending, Chart1.Series(0))

End Sub

这给出了这个(左:已排序,右:未排序) enter image description here

关于c# - MSChart插入、移动、删除点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12948304/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com