ZedGraph ASPX VB

R

Ryan

I am trying to use ZedGraph and can succesfully create a pretty nice
graph when I program put all the data directly into the control. Of
course, what I need to do is generate the graph dynamically based on
the information in a database. Since ZedGraph does not seem to handle
databinding, I figured I would just read through a recordset and assign
the point pairs. My first step, after which it should be easy, has
been to simply try to modify the graph via code-behind. I have had no
luck doing this and can't find anything in the samples. My code behind
code is as follows:

Any one have any experince with this?

'============================================================================
'ZedGraph Class Library - A Flexible Charting Library for .Net
'Copyright (C) 2005 John Champion and Jerry Vos
'
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU Lesser General Public
'License as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
'
'This library is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
'Lesser General Public License for more details.
'
'You should have received a copy of the GNU Lesser General Public
'License along with this library; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
'=============================================================================
Imports ZedGraph.ZedGraphWeb
Imports ZedGraph
Public Class graph
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents ZedGraphWeb2 As ZedGraph.ZedGraphWeb


'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub ZedGraphWeb2_RenderGraph(ByVal g As
System.Drawing.Graphics, ByVal mpane As ZedGraph.MasterPane) Handles
ZedGraphWeb2.RenderGraph

Dim list1 As PointPairList
list1.Add(-50, -50)
list1.Add(100, 45)
list1.Add(15, 32)
Dim mycurve2 As LineItem
ZedGraphWeb2.Visible = False

mpane(0).CurveList.Clear()
mpane(1).CurveList.Clear()
mpane(2).CurveList.Clear()
mpane(0).AddCurve("Ryan's Line", list1, Color.BlueViolet,
SymbolType.Diamond)

mpane(0).CurveList(0).Color = Color.BlueViolet
mpane(0).CurveList(0).IsVisible = True

mpane(0).CurveList(0).Draw(g, mpane(0), 0, 0)


Dim mycurve As CurveItem


' mpane(0).CurveList.Add(mycurve)
' mpane(0).CurveList(0).AddPoint(0, 1)
' mpane(0).CurveList(0).AddPoint(4, 6)
' mpane(0).CurveList(0).AddPoint(24, 42)
' mpane(0).CurveList(0).AddPoint(-15, 25)
mpane(0).AxisChange(g)

mpane(0).Draw(g)
ZedGraphWeb2.Draw(True)
ZedGraph.ZedGraphWeb.RenderDemo(g, mpane(0))
End Sub
End Class




The control is as follows:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="graph.aspx.vb" Inherits="ZGBasic.graph"%>
<%@ Register TagPrefix="zgw" Namespace="ZedGraph" Assembly="ZedGraph"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>graph</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<zgw:zedgraphweb id="ZedGraphWeb2" runat="server" AxisChanged="True"
ClusterScaleWidth="1" IsAxisRectAuto="True"
MarginBottom="10" LineType="Normal" IsShowTitle="True"
OutputFormat="Jpeg" CacheDuration="0"
MarginTop="10" MarginRight="10" IsIgnoreMissing="False"
IsIgnoreInitial="False" MinClusterGap="1"
BarType="Cluster" PaneCount="1" MinBarGap="0.2" BaseDimension="8"
IsPenWidthScaled="False" MarginLeft="10"
IsFontsScaled="True" PaneLayout="SquareRowPreferred" BarBase="X"
EnableViewState="False">
<AxisRect Y="0" Height="0" Width="0" X="0"></AxisRect>
<PieRect Y="0" Height="0" Width="0" X="0"></PieRect>
<FontSpec Size="16" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="0" FontColor="Black"
StringAlignment="Center" IsBold="True">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</FontSpec>
<Y2Axis IsOmitMag="False" Max="0" MinGrace="0.1" GridPenWidth="1"
MinSpace="0" CrossAuto="False"
IsShowGrid="False" IsUseTenPower="False" MinorGridColor="Gray"
MinorGridDashOff="10"
MaxAuto="True" MinorGridPenWidth="1" ScaleFormatAuto="False"
IsReverse="False" IsMinorTic="True"
IsTic="True" IsMinorInsideTic="True" Cross="0"
IsTicsBetweenLabels="True" ScaleMag="0"
IsOppositeTic="True" TicPenWidth="1" GridDashOff="5"
IsShowMinorGrid="False" MinAuto="True"
Type="Linear" IsInsideTic="True" MinorGridDashOn="1"
MinorTicSize="2.5" IsVisible="False"
ScaleAlign="Center" MaxGrace="0.1" Color="Black" Min="0"
IsShowTitle="True" ScaleMagAuto="True"
IsPreventLabelOverlap="False" IsMinorOppositeTic="True"
ScaleFormat="g" StepAuto="True"
MinorStepAuto="True" TicSize="5" IsZeroLine="True" GridDashOn="1"
GridColor="Black"
Title="">
<ScaleFontSpec Size="14" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="-90" FontColor="Black"
StringAlignment="Center" IsBold="False">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</ScaleFontSpec>
<TitleFontSpec Size="14" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="0" FontColor="Black"
StringAlignment="Center" IsBold="True">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</TitleFontSpec>
</Y2Axis>
<XAxis IsOmitMag="False" Max="0" MinGrace="0.1" GridPenWidth="1"
MinSpace="0" CrossAuto="False"
IsShowGrid="False" IsUseTenPower="False" MinorGridColor="Gray"
MinorGridDashOff="10"
MaxAuto="True" MinorGridPenWidth="1" ScaleFormatAuto="False"
IsReverse="False" IsMinorTic="True"
IsTic="True" IsMinorInsideTic="True" Cross="0"
IsTicsBetweenLabels="True" ScaleMag="0"
IsOppositeTic="True" TicPenWidth="1" GridDashOff="5"
IsShowMinorGrid="False" MinAuto="True"
Type="Linear" IsInsideTic="True" MinorGridDashOn="1"
MinorTicSize="2.5" IsVisible="True"
ScaleAlign="Center" MaxGrace="0.1" Color="Black" Min="0"
IsShowTitle="True" ScaleMagAuto="True"
IsPreventLabelOverlap="False" IsMinorOppositeTic="True"
ScaleFormat="g" StepAuto="True"
MinorStepAuto="True" TicSize="5" IsZeroLine="False" GridDashOn="1"
GridColor="Black"
Title="">
<ScaleFontSpec Size="14" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="0" FontColor="Black"
StringAlignment="Center" IsBold="False">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</ScaleFontSpec>
<TitleFontSpec Size="14" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="0" FontColor="Black"
StringAlignment="Center" IsBold="True">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</TitleFontSpec>
</XAxis>
<Legend IsHStack="True" Position="Top" IsVisible="True">
<Fill RangeMax="0" Type="Brush" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Rect Y="0" Height="0" Width="0" X="0"></Rect>
<Border IsVisible="True" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
<FontSpec Size="12" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="0" FontColor="Black"
StringAlignment="Center" IsBold="False">
<Fill RangeMax="0" Type="Solid" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</FontSpec>
<Location CoordinateFrame="AxisFraction" Height="0" AlignH="Left"
X1="0" Y1="0" X="0" Y="0"
Width="0" AlignV="Center">
<BottomRight Y="0" X="0"></BottomRight>
<Rect Y="0" Height="0" Width="0" X="0"></Rect>
<TopLeft Y="0" X="0"></TopLeft>
</Location>
</Legend>
<AxisBorder IsVisible="True" PenWidth="1" InflateFactor="0"
Color="Black"></AxisBorder>
<AxisFill RangeMax="0" Type="Brush" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></AxisFill>
<PaneFill RangeMax="0" Type="Solid" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></PaneFill>
<PaneBorder IsVisible="True" PenWidth="1" InflateFactor="0"
Color="Black"></PaneBorder>
<CurveList>
<zgw:ZedGraphWebLineItem DataMember="" IsLegendLabelVisible="True"
StepType="NonStep" Label="Hi" SmoothTension="0.5"
IsSmooth="False" Color="0, 0, 192" Width="1" Style="Solid"
IsY2Axis="False" IsVisible="True">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="Red" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Points>
<zgw:ZedGraphWebPointPair Y="17" Z="0"
X="-6"></zgw:ZedGraphWebPointPair>
<zgw:ZedGraphWebPointPair Y="0" Z="0"
X="0"></zgw:ZedGraphWebPointPair>
<zgw:ZedGraphWebPointPair Y="16" Z="0"
X="1"></zgw:ZedGraphWebPointPair>
<zgw:ZedGraphWebPointPair Y="24" Z="0"
X="2"></zgw:ZedGraphWebPointPair>
</Points>
<Symbol IsVisible="True" SymbolType="Square" Size="7">
<Border IsVisible="True" PenWidth="1" InflateFactor="0"
Color="Red"></Border>
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="Red" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
</Symbol>
</zgw:ZedGraphWebLineItem>
</CurveList>
<YAxis IsOmitMag="False" Max="0" MinGrace="0.1" GridPenWidth="1"
MinSpace="0" CrossAuto="False"
IsShowGrid="False" IsUseTenPower="False" MinorGridColor="Gray"
MinorGridDashOff="10"
MaxAuto="True" MinorGridPenWidth="1" ScaleFormatAuto="False"
IsReverse="False" IsMinorTic="True"
IsTic="True" IsMinorInsideTic="True" Cross="0"
IsTicsBetweenLabels="True" ScaleMag="0"
IsOppositeTic="True" TicPenWidth="1" GridDashOff="5"
IsShowMinorGrid="False" MinAuto="True"
Type="Linear" IsInsideTic="True" MinorGridDashOn="1"
MinorTicSize="2.5" IsVisible="True"
ScaleAlign="Center" MaxGrace="0.1" Color="Black" Min="0"
IsShowTitle="True" ScaleMagAuto="True"
IsPreventLabelOverlap="False" IsMinorOppositeTic="True"
ScaleFormat="g" StepAuto="True"
MinorStepAuto="True" TicSize="5" IsZeroLine="True" GridDashOn="1"
GridColor="Black"
Title="">
<ScaleFontSpec Size="14" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="90" FontColor="Black"
StringAlignment="Center" IsBold="False">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</ScaleFontSpec>
<TitleFontSpec Size="14" IsUnderline="False" IsItalic="False"
Family="Arial" Angle="-180" FontColor="Black"
StringAlignment="Center" IsBold="True">
<Fill RangeMax="0" Type="None" AlignH="Center" IsScaled="True"
Color="White" RangeMin="0"
IsVisible="True" AlignV="Center"></Fill>
<Border IsVisible="False" PenWidth="1" InflateFactor="0"
Color="Black"></Border>
</TitleFontSpec>
</YAxis>
</zgw:zedgraphweb></form>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top