in

WD Community

Share your workout experiences.

ZedGraph Help

Last post 03-22-2007 10:16 PM by Mcbeev. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 03-22-2007 10:16 PM

    ZedGraph Help

    Someone requested a quick snippet of how to get ZedGraph to work so here we go.

    First off I use these 2 links for documentation The main wiki and the SourceForge project forum.

    1. Setup: Make sure you have the ZedGraph.dll and ZedGraph.Web.dll assemblies in your bin directory.
    2. Create a writeable directory in your web project for temp image creation, I called mine ~/Data/Charts
    3. Add a new .aspx page with and register the tagprefix for the web control by adding this line

      <%@ Register TagPrefix="zgw" Namespace="ZedGraph.Web" Assembly="ZedGraph.Web" %>

    4. Drop now drop a graph control on the page and make sure to use the same tag prefix. It should look something like  this

      <zgw:ZEDGRAPHWEB id="zgChart" runat="server" Width="700" Height="400" RenderMode="RawImage" IsImageMap="false" RenderedImagePath="~/data/charts/" OnRenderGraph="zgChart_RenderGraph" />

    5. On Render Graph  is where the magic happens. In your Code Behind Make sure you wire up your event like so: protected void zgChart_RenderGraph(Graphics g, MasterPane masterPane)

      {

      // Get the GraphPane so we can work with it

      GraphPane myPane = masterPane[0];

      // Create a point pair list, there are many ways to populate the data besides this too.

      PointPairList somePoints = new PointPairList();

      // Add some points

      somePoints.Add(0, 1);

      somePoints.Add(1, 2);

      somePoints.Add(2, 4);

      somePoints.Add(3, 3);

      // add the points to a curve on your pane.

      BarItem myBar = myPane.AddBar("Series Title", somePoints, Color.Red);

      // Finish up by telling the master pane to generate the axis.

      masterPane.AxisChange(g);

      }

    6. Save and Run that should be it.

     

     

     

     

     

    Filed under:
Page 1 of 1 (1 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems