如何在不添加新值的情况下刷新图表 [英] How to refresh a chart without adding new values

查看:68
本文介绍了如何在不添加新值的情况下刷新图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张图表显示位置明智的员工圆环图...当我点击按钮时出现下一个公司位置...问题是当我改变公司图表加载成功但添加上一个公司的数据...我只想将下一个公司的位置数据添加到图表中...我只需要知道如何刷新图表..抱歉英文不好

谢谢!



我的尝试:



我使用此代码将数据添加到图表

I have a Chart Showing a "Location-Wise Active Employees" Doughnut chart...When I Click a Button The next Company Locations comes up...the problem is when i'm changing the company the chart loads successfully but Adding the Previous Company's Data too...i want to add just only the next company's location-wise data to the chart...I only need to know how to refresh the chart..Sorry for bad english
Thank you!

What I have tried:

I use this code to add data to the chart

Chart1.Series(0).Points.AddXY(Value1,Value2)

推荐答案

单击按钮后,清除 Points 添加新点之前的集合。
After the button is clicked, clear the Points collection before adding the new points.


我遇到了类似的问题。我想引入新数据并将其显示为已存在的数据。我正在替换现有积分的YValue [0]。我可以在调试器中看到点数据被替换,但图表在显示屏上保持不变。我在文档中找到了Chart.Refresh(),但它不在.NET 4.6.1中。我在Chart的对象浏览器中找到了Invalidate函数,令我惊讶的是它有效!我的代码是这样的:



I had a similar problem. I wanted to bring in new data and display it in place of the data that was already there. I was replacing the YValue[0] of existing Points. I could see, in the debugger, that the point data was being replaced, but the chart remained the same on the display. I found a Chart.Refresh() in the docs, but it wasn't in .NET 4.6.1. I found the Invalidate function in the object browser for Chart and to my surprise it worked! My code was like this:

chart2.Series[0].Points[ix].YValues[0] = newvalue;
chart2.Invalidate();





我试图在每个新数据点到达时更新图表。但是,您的情况可能会有所不同,您可以使用Chart.Invalidate();无论哪里最有意义。



I was trying to update the chart as each new data point arrived. However, your case might be different and you can use Chart.Invalidate(); wherever it make the most sense.


这篇关于如何在不添加新值的情况下刷新图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆