ZedGraph教程.docx
《ZedGraph教程.docx》由会员分享,可在线阅读,更多相关《ZedGraph教程.docx(62页珍藏版)》请在冰豆网上搜索。
ZedGraph教程
ZedGraph是一个非常优秀的开源的作图控件
1、在vs中使用ZedGraph
2、 基本一些概念
几个注意点:
图片的保存路径设置:
RenderedImagePath属性中设置,程序对该文件夹应该是有写和修改权限的
图片的输出格式:
OutputFormat属性中设置,Png的推荐,比较清晰。
Chart
ChartBorder
图表区域的边框设置
ChartFill
图表区域的背景填充
Legend
图表的注释标签显示设置项目,一组数据对应一种颜色的注释
IsHStack
当有多个显示项的时候设置 Y 轴数据是叠加的还是分开的
Xaxis
图表区域的 X 轴相关信息设置
AxisColor
坐标轴颜色
Cross
坐标的原点,可以设置坐标的偏移程度
CrossAuto
原点自动设置:
True 的话 Cross 的设置就无效了。
FontSpec
X 轴标题字体相关信息
Angle
X 轴标题字体显示时候的角度,0为水平90为垂直
Fill
X 轴标题字体填充信息
ColorOpacity
透明度
IsScaled
设置 X 轴标题字体显示大小是否根据图的比例放大缩小
RangeMax
填充时候的最大倾斜度(有过渡色,没试过)
RangeMin
填充时候的最小倾斜度(有过渡色,没试过)
StringAlignment
X 轴标题字体排列(不清楚,没试过)
IsOmitMag
是否显示指数幂(10次方,没试过,似乎与 IsUseTenPower 有关系)
IsPreventLabelOverlap
坐标值显示是否允许重叠,如果False的话,控件会根据坐标值长度自动消除部分坐标值的显示状态
IsShowTitle
X 轴标题是否显示
IsTicsBetweenLabels
两个坐标值之间是否自动显示分隔标志
IsUseTenPower
是否使用10次幂指数
IsZeroLine
当数据为0时候是否显示(在饼状图显示的时候有用)
IsVisible
是否显示 X 轴
MajorGrid
大跨度的 X 轴表格虚线线显示信息
DashOff
虚线中孔间距
DashOn
虚线单位长度
MajorTic
大跨度的 X 轴刻度信息
IsInside
在 Chart 内部是否显示
IsOutSide
在 Chart 外部是否显示
IsOpposite
在对面的轴上是否显示
MinorGrid
小跨度的 X 轴表格虚线显示信息
MinorTic
小跨度的 x 轴刻度信息
MinSpace
刻度和轴之间的距离(没试过)
Scale
刻度值的一些设定
IsReverse
X 轴的刻度值从高到低还是从低到高
MajorStep
大刻度步长
MajorStepAuto
是否自动设置大刻度步长
MajorUnit
大刻度步长单位
Max
刻度最大值
MaxAuto
根据输入数据自动设置刻度最大值
Min
刻度最小值
MinAuto
根据输入数据自动设置刻度最小值
MinGrace
不清楚,没试过
MinorStep
小刻度步长
MinorStepAuto
是否自动设置小刻度步长
MinorUnit
小刻度单位
Type
数据显示方式
Liner
直接现实(自动)
Date
按日期方式显示
Log
按指数幂方式显示
Ordinal
顺序显示
Y2Axis
第二个 Y 轴坐标信息显示(具体设置看 X 轴)
Yaxis
第一个 Y 轴坐标信息显示(具体设置看 X 轴)
BarBase
在生成柱状图的时候设置柱状是基于 X 轴还是其他轴
BarType
柱状的类型叠加或其他。
IsFontsScaled
图比例变化时候图表上的文字是否跟着自动缩放
IsIgnoreInitial
是否忽略初始值
IsIgnoreMissing
是否忽略缺省值
IsPenWidthScaled
图比例变化时候图表上的画笔的粗细是否跟着自动缩放
IsShowTitle
图表标题是否显示
PaneFill
Pane 的一些填充信息
BaseDimension
缩放比例基数(可以试试效果)
IsImageMap
不清楚干吗用的
AxisChaneged
是否允许自动绘图(没试过,一般都 true,动态绘图)
CacheDuration
Cache 保存时间0
OutputFormat
输出格式
RenderedImagePath
输出路径
RenderMode
输出模式,不太清楚一般都是 ImageTag,另一个输出的是乱码不是图片。
对于图表而言,一般是三种表现形式:
柱状图、饼状图和点线图。
Class
Description
MasterPane
AclasstomanagemultipleGraphPaneobjects,derivedfromPaneBase.UseoftheMasterPaneclassisoptional,astheGraphPaneclasscanbeuseddirectlyforasinglepane.Alsoprovidesmethodsforlayout,arrangement,andmanagementoftheindividualGraphPaneobjects.
GraphPane
Theprimaryclassforthegraph,derivedfromPaneBase.Includesallotherclassesasproperties.Alsocontrolsthepanetitle,thepaneframeandaxisframe,backgrounds,etc.
XAxis,YAxis,Y2Axis
ChildrenoftheAxisclass.Theseclassesincludemanyaspectsoftheaxisdisplay,includingtics,grids,colors,pens,fonts,labels,andstyles.
Scale
AclassinstancemaintainedbytheAxisclass.Containsthescalerange,stepsizes,formats,anddisplayoptionsforthescale.ComesinvariantsforLinear,Log,Text,Date,Ordinal,Exponent,LinearAsOrdinal,andDateAsOrdinalscales.
Legend
Theclassthatdescribesthelocation,font,colors,etc.,usedtodrawthelegend.
CurveItem
Anabstractbaseclassthatcontainsdataforasinglecurve.LineItem,BarItem,HiLowBarItem,ErrorBarItem,PieItem,StickItem,OHLCBarItem,andJapaneseCandleStickItemareallderivedfromthisclass.
CurveList
AcollectionclasstomaintainalistofCurveItemobjects.TheorderofthecurvesinthelistcontrolstheZ-Orderfordrawing.Thelastcurveinthelistwillappearbehindallothercurves.
GraphObj
Anabstractbaseclassthatincludespositioninformationforavarietyofsupplementalgraphicobjectsonaplot.TextObj,ImageObj,LineObj,ArrowObj,EllipseObj,BoxObj,andPolyObjarederivedfromGraphObj.
GraphObjList
AcollectionclasstomaintainalistofGraphObjobjects.Theorderoftheobjectsinthelist,plusaZOrderproperty,controltheZ-Orderfordrawing.ThelastiteminthelistwillappearbehindallotheritemswiththesameZOrdervalue.
FontSpec
Autilityclassthatincludesinformationaboutthefontfamily,color,angle,size,style,frame,andbackgroundfillofthetextonthegraph.EachclassthatincludestextinformationwillcontainoneormoreFontSpecobjectstospecificallydescribetheassociatedfonts.
Fill
Autilityclassthatincludescharacteristicsofbackgroundcolorfills.EachobjectthathascolorfillcapabilitywillcontainoneormoreFillobjectstospecificallydescribetheassociatedcolorfill.
Border
Autilityclassthatincludescharacteristicsofobjectborders.EachobjectthathasbordercapabilitywillcontainoneormoreBorderobjectstospecificallydescribetheassociatedbordercolorandlineproperties.
Location
Ageneralclassforhandlingthelocationofgraphicobjectsontheplot.
PointPair
Adatastructthatencapsulatesasinglepairofdoublevaluesrepresentingan(X,Y)datapoint.ThisistheinternaldatastorageformatforthevaluearraysineachCurveItem.
PointPairList
AcollectionclasstomaintainalistofPointPairobjects.
XDate
Thisclassencapsulatesasingledate-timevalue(storedasaSystem.Double),plusawidearrayofmethodstoconvertbetweenXLdate,AstronomicalJulianDaynumber,GregorianCalendardate,fractionalyear,etc.SeethediscussionofDate-Timeaxesbelow,fordetails.
Member->>Description
AxisChange()()->>ThisperformsanaxischangecommandonthegraphPane.
BeenDisposed->>Thischecksifthecontrolhasbeendisposed.Thisissynonymouswiththegraphpanehavingbeennulledordisposed.ThereforethisisthesameasZedGraphControl.GraphPane==null.
BorderStyle->>Getsorsetstheborderstyleofthetreeviewcontrol.(InheritedfromUserControl.)
ContextMenuBuilder->>SubscribetothiseventtobeabletomodifytheZedGraphcontextmenu.
Copy(Boolean)->>将图像复制到剪贴板。
DoPageSetup()()->>打开打印设置对话框。
DoPrint()()->>打印图表。
DoPrintPreview()()->>打印预览。
EditButtons->>GetsorsetsavaluethatdetermineswhichMousebuttonwillbeusedtoeditpointdatavalues
EditModifierKeys->>Getsorsetsavaluethatdetermineswhichmodifierkeyswillbeusedtoeditpointdatavalues
GetImage()()->>返回图表上的图像。
GraphPane->>GetsorsetstheGraphPanepropertyforthecontrol
IsAntiAlias->>GetsorsetsavaluethatdeterminesifalldrawingoperationsforthiscontrolwillbeforcedtooperateinAnti-aliasmode.Notethatifthisvalueissetto"true",itoverridesthesettingforsub-objects.Otherwise,thesub-objectsettings(suchasIsAntiAlias)willbehonored.
IsAutoScrollRange->>Getsorsetsavaluethatcontrolswhetherornottheaxisvaluerangeforthescrollbarswillbesetautomatically.
IsEnableHEdit->>Getsorsetsavaluethatdetermineswhetherornoteditingofpointdataisallowedinthehorizontaldirection.
IsEnableHPan->>Getsorsetsavaluethatdetermineswhetherornotpanningisallowedforthecontrolinthehorizontaldirection.
IsEnableHZoom->>是否允许横向缩放。
IsEnableSelection->>Getsorsetsavaluethatdetermineswhetherornotselectionisallowedforthecontrol.
IsEnableVEdit->>Getsorsetsavaluethatdetermineswhetherornoteditingofpointdataisallowedintheverticaldirection.
IsEnableVPan->>Getsorsetsavaluethatdetermineswhetherornotpanningisallowedforthecontrolintheverticaldirection.
IsEnableVZoom->>是否允许纵向缩放。
IsEnableZoom->>是否允许缩放。
IsPrintFillPage->>GetsorsetsavaluethatdetermineswhetherornottheMasterPaneRectdimensionswillbeexpandedtofilltheavailablespacewhenprintingthisZedGraphControl.
IsPrintKeepAspectRatio->>GetsorsetsavaluethatdetermineswhetherornotthevisibleaspectratiooftheMasterPaneRectwillbepreservedwhenprintingthisZedGraphControl.
IsPrintScaleAll->>GetsorsetsavaluethatdetermineswhetherthesettingsofIsFontsScaledandIsPenWidthScaledwillbeoverriddentotrueduringprintingoperations.
IsScrolling->>Returnstrueiftheuseriscurrentlyscrollingviathescrollbar,orfalseifnoscrollingistakingplace.
IsScrollY2->>GetsorsetsavaluethatdeterminesiftheverticalscrollbarwillaffecttheY2axis.
IsShowContextMenu->>是否显示右键菜单,如果指定了ContextMenuStrip会一直显示指定的ContextMenu。
IsShowCopyMessage->>复制图像时是否显示提示信息。
IsShowCursorValues->>鼠标在图表上移动时是否显示鼠标所在点对应的坐标值。
默认为false
IsShowHScrollBar->>是否显示横向滚动条。
IsShowPointValues->>鼠标经过图表上的点时是否气泡显示该点所对应的值。
默认为false
IsShowVScrollBar->>是否显示纵向滚动条。
IsSynchronizeXAxes->>GetsorsetsavaluethatdeterminesiftheXAxisScalerangesforallGraphPaneobjectsintheMasterPanewillbeforcedtomatch.
IsSynchronizeYAxes->>GetsorsetsavaluethatdeterminesiftheYAxisScalerangesforallGraphPaneobjectsintheMasterPanewillbeforcedtomatch.
IsZoomOnMouseCenter->>使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。
LinkButtons->>GetsorsetsavaluethatdetermineswhichMousebuttonwillbeusedtoclickonlinkableobjects
LinkEvent->>Subscribetothiseventtobeabletorespondtomouseclickswithinlinkedobjects.
LinkModifierKeys->>Getsorsetsavaluethatdetermineswhichmodifierkeyswillbeusedtoclickonlinkableobjects
MasterPane->>GetsorsetstheMasterPanepropertyforthecontrol
MouseDownEvent->>代替MouseDown事件,有一个bool类型的返回值,代表是否响应该事件。
MouseUpEvent->>代替MouseUp事件,有一个bool类型的返回值,代表是否响应该事件。
PanButtons->>Getsorsetsavaluethatdetermineswhichmousebuttonwillbeusedasaprimaryoptiontotriggerapanevent.
PanButtons2->>Getsorsetsavaluethatdetermineswhichmousebuttonwillbeusedasthesecondaryoptiontotriggerapanevent.
PanModifierKeys->>Getsorsetsavaluethatdetermineswhichmodifierkeyswillbeusedasaprimaryoptiontotrigg