ZedGraph如何動態的加載曲線


ZedGraph的在線文檔

http://zedgraph.sourceforge.net/documentation/default.html

 官網的源代碼 http://sourceforge.net/projects/zedgraph/?source=directory

 

 zedgraph的demo在線范例

 http://zedgraph.sourceforge.net/samples.html

 

這里介紹了如何實現動態加載數據,並且提供了demo

http://goorman.free.fr/ZedGraph/zedgraph.org/wiki/index3061.html?title=Display_Dynamic_or_Real-Time_Data

 

The ZedGraphControl can display dynamic or static data. For dynamic displays, each time you want to add data to a graph, you will need to do the following:

ZedGraph可以顯示動態或者靜態的數據,對於動態展示,每當你想要把數據加載到graph上的時候,你需要按照以下的步驟來做

1.Find the CurveItem of interest within the GraphPane.CurveList collection

第一步,先找到GraphPane.CurveList 中的相關曲線
2.Access the PointPairList (or other IPointListEdit type) for the CurveItem, and add the new data or modify the existing data as required

第二步,找到曲線中的PointPairList ,然后根據需要加載新數據或者修改已經存在的數據
3.Call ZedGraphControl.AxisChange() to update the auto-scaled axis ranges

第三步,調用ZedGraphControl的AxisChange()函數來更新坐標軸范圍的比例
4.Call Form.Invalidate() to update the graph

第四步,調用Form.Invalidate() 來更新graph------------[貌似我沒有找到這個方法,winform支持?]

 

The data points are stored with each CurveItem as a reference to an IPointList interface in CurveItem.Points. Note that this point list reference can be any class that implements IPointList. If it also implements IPointListEdit, thenIPointListEdit.Add() and IPointListEdit.RemoveAt() methods will be available.

The code sample is for a form that implements a ZedGraphControl with a Timer event to show dynamically updated data. You can download the complete project from the links below:

 

 

 

 

 

 

ZedGraph控件隨機生成曲線的顏色,以及X軸坐標文字豎着顯示==========mypane.XAxis.Scale.FontSpec.Angle = 270;//X軸的時間垂直顯示

http://blog.csdn.net/happy09li/article/details/7535388

 

ZedGraph使用大全http://www.cnblogs.com/peterzb/archive/2009/07/19/1526726.html

 

 

 

//zedgraph一些屬性的介紹

http://blog.chinaunix.net/uid-20776117-id-1847015.html

 

 

 

 

ZedGraph刷新數據的方法

zedGraphControl1.AxisChange();//此方法   調整坐標軸的范圍

 

Invalidate()//使控件的特定區域無效並向控件發送繪制消息。

//調用 Invalidate 方法並不強制同步繪制;若要強制同步繪制,請在調用 Invalidate 方法之后調用 Update 方法。 在不帶參數的情況下調用此方法時,會將整個工作區添加到更新區域。

zedGraphControl1.Invalidate();
zedGraphControl1.Update();

或者

zedGraphControl1.Refresh();//強制控件使其工作區無效並立即重繪自己和任何子控件。

 

 

//讓坐標軸不不顯示10^x;[這樣做會導致比例尺失調]

zedGraphControl1.GraphPane.XAxis.Type = AxisType.Log;

zedGraphControl1.GraphPane.XAxis.Scale.IsUseTenPower = false;

IsUseTenPower ->> 是否為10次冪表示,scale為LogScale時有效。 The powers-of-ten notation is just the text "10" followed by a superscripted value indicating the magnitude. This mode is only valid for log scales. boolean value; true to show the title as a power of ten, false to show a regular numeric value (e.g., "0.01", "10", "1000")

 

zedGraphControl1.GraphPane.XAxis.Title.IsOmitMag

true to show the magnitude value, false to hide it .   //IsOmitMag為true的時候,顯示數量級,為false的時候,不顯示
For large scale values, a "magnitude" value (power of 10) is automatically used for scaling the graph. This magnitude value is automatically appended to the end of the Axis Title (e.g., "(10^4)") to indicate that a magnitude is in use. This property controls whether or not the magnitude is included in the title. Note that it only affects the axis title; a magnitude value may still be used even if it is not shown in the title. 
對於大數量級,10冪,會自動顯示;數量級會自動加載坐標的Title后面,無論IsOmitMag是true還是false;它僅僅是影響Title,數量級還是正常的影響坐標系的。
 
 
以加載100萬數據為例子,說明上面幾個的屬性
默認狀態下的加載界面
 zedGraphControl1.GraphPane.XAxis.Title.IsOmitMag 此屬性默認為false,X軸的標題顯示10的冪
將zedGraphControl1.GraphPane.XAxis.Title.IsOmitMag 設置為true的時候,就不顯示10的冪了
 
 
 
zedGraphControl1.GraphPane.XAxis.Type = AxisType.Log;//橫軸按照10的冪為步長//默認橫軸是按照10的冪來顯示的
 

zedGraphControl1.GraphPane.XAxis.Type = AxisType.Log;
zedGraphControl1.GraphPane.XAxis.Scale.IsUseTenPower = false;//橫軸不顯示成10的冪

 

 

 

給某一個曲線加載100萬點,希望橫軸顯示100000,200000,300000

直接設定好,坐標軸

zedGraphControl1.GraphPane.XAxis.Scale.Max = number;//設定X軸的最大值
zedGraphControl1.GraphPane.XAxis.Scale.MajorStep = number / 10;//設定最大步長
zedGraphControl1.GraphPane.XAxis.Scale.MinorStep = number / 10 / 5;//設定最小步長
zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.Angle = 45;//設定X軸的字體的傾斜度

注意:一定不要調用zedGraphControl1.AxisChange();否則上面的設置就白設置了,相當於重置了

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM