技术开发 频道

ZedGraph在Asp.net中的应用

【IT168 技术文档】

    ZedGraph是一个不错的图表报表生成器,以前曾经用过,在asp.net2.0的beta版里面。现在忽然有可能用到了,但是却一时找不着以前的资料了,方才发现写blog的伟大作用。所以赶紧先把它记下来,以备后用。

    1:这是for asp.net的版本。现在win版本的例子代码很多。
    2:这里提供的只是一个基本的用法。
    3:详细信息:http://zedgraph.org/wiki/index.php?title=Display_Dynamic_or_Real-Time_Data

    1:Asp页面上

    基本上没有什么技巧,放上这个控件就可以。

    Asp Control

1<zgw:ZedGraphWeb ID="zgw_graph" runat="server" Height="600" OnRenderGraph="zgw_graph_RenderGraph" 2 Width="800"> 3 <XAxis Color="Black" Cross="0" CrossAuto="True" GridColor="Black" GridDashOff="5" 4 GridDashOn="1" GridPenWidth="1" IsInsideTic="True" IsMinorInsideTic="True" IsMinorOppositeTic="True" 5 IsMinorTic="True" IsOmitMag="False" IsOppositeTic="True" IsPreventLabelOverlap="False" 6 IsReverse="False" IsShowGrid="False" IsShowMinorGrid="False" IsShowTitle="True" 7 IsTic="True" IsTicsBetweenLabels="True" IsUseTenPower="False" IsVisible="True" 8 IsZeroLine="False" Max="0" MaxAuto="True" MaxGrace="0.1" Min="0" MinAuto="True" 9 MinGrace="0.1" MinorGridColor="Gray" MinorGridDashOff="10" MinorGridDashOn="1" 10 MinorGridPenWidth="1" MinorStepAuto="True" MinorTicSize="2.5" MinSpace="0" ScaleAlign="Center" 11 ScaleFormat="g" ScaleFormatAuto="True" ScaleMag="0" ScaleMagAuto="True" StepAuto="True" 12 TicPenWidth="1" TicSize="5" Title="" Type="Linear"> 13 <TitleFontSpec Angle="0" Family="Arial" FontColor="Black" IsBold="True" IsItalic="False" 14 IsUnderline="False" Size="14" StringAlignment="Center"> 15 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 16 RangeMax="0" RangeMin="0" Type="None" /> 17 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 18 </TitleFontSpec> 19 <ScaleFontSpec Angle="0" Family="Arial" FontColor="Black" IsBold="False" IsItalic="False" 20 IsUnderline="False" Size="14" StringAlignment="Center"> 21 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 22 RangeMax="0" RangeMin="0" Type="None" /> 23 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 24 </ScaleFontSpec> 25 </XAxis> 26 <AxisBorder Color="Black" InflateFactor="0" IsVisible="True" PenWidth="1" /> 27 <Y2Axis Color="Black" Cross="0" CrossAuto="True" GridColor="Black" GridDashOff="5" 28 GridDashOn="1" GridPenWidth="1" IsInsideTic="True" IsMinorInsideTic="True" IsMinorOppositeTic="True" 29 IsMinorTic="True" IsOmitMag="False" IsOppositeTic="True" IsPreventLabelOverlap="False" 30 IsReverse="False" IsShowGrid="False" IsShowMinorGrid="False" IsShowTitle="True" 31 IsTic="True" IsTicsBetweenLabels="True" IsUseTenPower="False" IsVisible="False" 32 IsZeroLine="True" Max="0" MaxAuto="True" MaxGrace="0.1" Min="0" MinAuto="True" 33 MinGrace="0.1" MinorGridColor="Gray" MinorGridDashOff="10" MinorGridDashOn="1" 34 MinorGridPenWidth="1" MinorStepAuto="True" MinorTicSize="2.5" MinSpace="0" ScaleAlign="Center" 35 ScaleFormat="g" ScaleFormatAuto="True" ScaleMag="0" ScaleMagAuto="True" StepAuto="True" 36 TicPenWidth="1" TicSize="5" Title="" Type="Linear"> 37 <TitleFontSpec Angle="0" Family="Arial" FontColor="Black" IsBold="True" IsItalic="False" 38 IsUnderline="False" Size="14" StringAlignment="Center"> 39 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 40 RangeMax="0" RangeMin="0" Type="None" /> 41 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 42 </TitleFontSpec> 43 <ScaleFontSpec Angle="-90" Family="Arial" FontColor="Black" IsBold="False" IsItalic="False" 44 IsUnderline="False" Size="14" StringAlignment="Center"> 45 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 46 RangeMax="0" RangeMin="0" Type="None" /> 47 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 48 </ScaleFontSpec> 49 </Y2Axis> 50 <AxisFill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 51 RangeMax="0" RangeMin="0" Type="Brush" /> 52 <PaneBorder Color="Black" InflateFactor="0" IsVisible="True" PenWidth="1" /> 53 <AxisRect Height="0" Width="0" X="0" Y="0" /> 54 <PieRect Height="0" Width="0" X="0" Y="0" /> 55 <YAxis Color="Black" Cross="0" CrossAuto="True" GridColor="Black" GridDashOff="5" 56 GridDashOn="1" GridPenWidth="1" IsInsideTic="True" IsMinorInsideTic="True" IsMinorOppositeTic="True" 57 IsMinorTic="True" IsOmitMag="False" IsOppositeTic="True" IsPreventLabelOverlap="False" 58 IsReverse="False" IsShowGrid="False" IsShowMinorGrid="False" IsShowTitle="True" 59 IsTic="True" IsTicsBetweenLabels="True" IsUseTenPower="False" IsVisible="True" 60 IsZeroLine="True" Max="0" MaxAuto="True" MaxGrace="0.1" Min="0" MinAuto="True" 61 MinGrace="0.1" MinorGridColor="Gray" MinorGridDashOff="10" MinorGridDashOn="1" 62 MinorGridPenWidth="1" MinorStepAuto="True" MinorTicSize="2.5" MinSpace="0" ScaleAlign="Center" 63 ScaleFormat="g" ScaleFormatAuto="True" ScaleMag="0" ScaleMagAuto="True" StepAuto="True" 64 TicPenWidth="1" TicSize="5" Title="" Type="Linear"> 65 <TitleFontSpec Angle="-180" Family="Arial" FontColor="Black" IsBold="True" IsItalic="False" 66 IsUnderline="False" Size="14" StringAlignment="Center"> 67 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 68 RangeMax="0" RangeMin="0" Type="None" /> 69 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 70 </TitleFontSpec> 71 <ScaleFontSpec Angle="90" Family="Arial" FontColor="Black" IsBold="False" IsItalic="False" 72 IsUnderline="False" Size="14" StringAlignment="Center"> 73 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 74 RangeMax="0" RangeMin="0" Type="None" /> 75 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 76 </ScaleFontSpec> 77 </YAxis> 78 <PaneFill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 79 RangeMax="0" RangeMin="0" Type="Solid" /> 80 <FontSpec Angle="0" Family="Arial" FontColor="Black" IsBold="True" IsItalic="False" 81 IsUnderline="False" Size="16" StringAlignment="Center"> 82 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 83 RangeMax="0" RangeMin="0" Type="None" /> 84 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 85 </FontSpec> 86 <Legend IsHStack="True" IsVisible="True" Position="Top"> 87 <Location AlignH="Left" AlignV="Center" CoordinateFrame="AxisFraction" Height="0" 88 Width="0" X="0" X1="0" Y="0" Y1="0"> 89 <Rect Height="0" Width="0" X="0" Y="0" /> 90 <TopLeft X="0" Y="0" /> 91 <BottomRight X="0" Y="0" /> 92 </Location> 93 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 94 RangeMax="0" RangeMin="0" Type="Brush" /> 95 <Rect Height="0" Width="0" X="0" Y="0" /> 96 <Border Color="Black" InflateFactor="0" IsVisible="True" PenWidth="1" /> 97 <FontSpec Angle="0" Family="Arial" FontColor="Black" IsBold="False" IsItalic="False" 98 IsUnderline="False" Size="12" StringAlignment="Center"> 99 <Fill AlignH="Center" AlignV="Center" Color="White" IsScaled="True" IsVisible="True" 100 RangeMax="0" RangeMin="0" Type="Solid" /> 101 <Border Color="Black" InflateFactor="0" IsVisible="False" PenWidth="1" /> 102 </FontSpec> 103 </Legend> 104 </zgw:ZedGraphWeb>

    2:连接到处理事件,

    这个和Win的处理不一样。看这里传入的参数:System.Drawing.Graphics g, MasterPane pane,注意最后的更新方式:pane[0].AxisChange(g);

    Event to Draw the Chart 

...

  3:几种图的使用Code to Draw every chart

...


0
相关文章