Talk:Main Page

From ZedGraphWiki

Jump to: navigation, search

Contents

Help : Zed Graph

I am using zed graph for graphs. It worked well until now... I could not create a graph anymore. My project won't run as expected. I didn't change any codes. It suddenly stopped working... I need help... thanks.

How To feed data to ZedGraph library to draw bar chart

Hi, guys I am a novice at ZedGraph area.

Currently, I need an urgent solution to feed raw data form SQL Server to ZedGraph that in turn draws a bar chart to facilitate users to analyze the data.

Where or what library sohuld I begin?

Is there any example I can refer to ?

Thanks in advance

Regards,

Ricky

Sorting Bars By Magnitude

Hey Folks,

I have been searching the SDK for the equivalent of a Sort() method that will allow me to display the bars in order of magnitude/size from greatest to least or vice versa. Does such a method exist or has anyone had to create a custom method that accomplishes this?

Regards, David

Gas Gauge

Can anyone please tell me how I can scale a gas gauge in VB.net. I would like three regions, one form 0.2 to 0.36, one from 0.36 to 0.4 and one from 0.4 to 0.56. When I create them, I get the three regions, but also a region from 0 to 0.2 with no colour. I would like the gauge to run from 0.2 to 0.56 instead. Is this possible. Regards Dave

Clearing the image from the ZedGraphImages folder while using RenderMode=ImageTag

Hi,

I know we can set the cacheduration but how can we delete the images on the folder created while using RenderMode=ImageTag? I have a number of users and each time the access the page, an image is created and this is accumulating and taking up space. Is there a way to delete these images programatically?


Hi All,

Even i have the same problem. Is there any solution for this.Please help!!!!

Please help me

Hi! Guy

Now I'm writing a new project that must create a graph report and used ZedGraph. But on this report must be create data from data, also display on graph as following

Database field 1. Month -> Sample data is Jan, Feb, Mar 2. Amount -> Sample data is 100, 50, 150

If Field Amount on month is < 100 then display red bar. If Field Amount on month is = 100 then display yellow bar. If Field Amount on month is > 100 then display green bar.

How I can do?

Thanks so much.

You need to use the "Z" value of the PointPair to indicate the bar color.  See the code sample below:
   John

public void CreateGraph_BarColorByZValue(ZedGraphControl z1)
{
  GraphPane myPane = z1.GraphPane;
  PointPairList ppl = new PointPairList();
  ppl.Add(new PointPair(20, 25, 1));
  ppl.Add(new PointPair(30, 30, 2));
  ppl.Add(new PointPair(40, 35, 3));
  ppl.Add(new PointPair(50, 40, 2));
  ppl.Add(new PointPair(60, 45, 1));

  Color[] colors = { Color.Red, Color.Green, Color.Blue };
  Fill myFill = new Fill(colors);
  myFill.Type = FillType.GradientByColorValue;
  myFill.SecondaryValueGradientColor = Color.White;
  myFill.RangeMin = 1;
  myFill.RangeMax = 3;

  BarItem myBar = myPane.AddBar("Curve 1", ppl, Color.Empty);
  myBar.Bar.Fill = myFill;
}

Customization of Y axis, How we can customize YAxis

HOW TO CUSTOMIZED Y-AXIS values in Zed garph . We need to put Currency in Dollor like $100K,$3000K,$400M .

Is there an error in ErrorBar plot or in my code??

Hello ZedGraph users,

I have been using ZedGraph for a month or so and really like its power. I have just run into a problem, though, that I can't solve. Perhaps one of you can assist me.

I am creating an error bar chart using Visual BASIC. Everything seems to work EXCEPT that the error bars ALWAYS extend down to the X axis, instead of to the YBase value. Here is a sample program:

Imports ZedGraph Public Class frmErrBarPlot

   Dim I As Integer
   Dim X, Y, ErrorBarTop, ErrorBarBottom As Double
   Private Sub frmErrBarPlot_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim myPane As GraphPane = ZedGraphControl1.GraphPane
       myPane.Title.Text = "Test of Error Bars with ZedGraph"
       myPane.XAxis.Title.Text = "X axis"
       myPane.YAxis.Title.Text = "Y axis"
       Dim ErrorBarList As New PointPairList
       For I = 0 To 44
           X = I / 44
           Y = Math.Sin(I * Math.PI / 15)
           ErrorBarTop = Y + 0.1
           ErrorBarBottom = Y - 0.1
           'Error bars will be 0.2 long and centered on Y
           ErrorBarList.Add(X, ErrorBarTop, ErrorBarBottom)
       Next I
       Dim ErrorBarSet As ErrorBarItem = myPane.AddErrorBar("Curve 1", ErrorBarList, Color.Red)
       ZedGraphControl1.AxisChange()
   End Sub

End Class

This code is based on the C code in the demo. However, unlike the demo, the error bars always extend to zero instead of to ErrorBarBottom. Any suggestions as to what is wrong?

Dave Cowles

Some problems with plotting in logarithmic scales

Hello colleagues,

I have encountered two problems when tried to plot a graph with logarithmic scales: 1) Y-axis Log: fill does not work properly if the axis lower range is less than 1.0, and 2) X-axis Log: axis tic lables are not shown except for the very first one.

I will highly appreciate if sombody helps me.

Andrey

How to create common bar chart?

I'm trying to create a simple stacked bar chart from data in a database. I can create the chart just fine, but I can't label it correctly. I want the Y axis to show in dollars, and the X axes to show in years.

Table(12) contains "Profit", table(13) contains "Cost" in the following format

Year Total 2006 1000 2007 2000 2008 3000


Here are my specific questions:

1. How do I format the y axis to show $3,000 instead of 3 with a label of Total (10^3) 2. How do I add the totals for each of the stacked bars, onto the chart. For example for 2006, I want to label the Profit bar with the $$ for proft, and the Cost bar for the $$ for cost 3. How do I get the X axis to show a simple "2006" or "2007" label under each bar for the year?



My code:

Dim myPane As GraphPane = pane(0)

       ' Set the title and axis labels
       myPane.Title.Text = "Proft/Cost"
       myPane.YAxis.Title.Text = "Total"
       myPane.XAxis.Title.Text = "Year"
       Dim dspl As New DataSourcePointList
       With dspl
           .DataSource = ds.Tables(12)
           .XDataMember = "Year"
           .YDataMember = "Total"
           .TagDataMember = "Type"
       End With
       Dim dspl2 As New DataSourcePointList
       With dspl2
           .DataSource = ds.Tables(13)
           .XDataMember = "Year"
           .YDataMember = "Total"
           .TagDataMember = "Type"
       End With
       myPane.XAxis.Type = AxisType.Text
       myPane.YAxis.Type = AxisType.Linear
       myPane.BarSettings.Type = BarType.Stack
       myPane.Chart.Fill = New Fill(Color.White, _
                  Color.FromArgb(255, 255, 166), 45.0F)
       myPane.AddBar("Cost", dspl, Color.OrangeRed)
       myPane.AddBar("Profit", dspl2, Color.CadetBlue)

Need Source Code of ZEDGRAPH Version 5.0.9.41461

Hello,

   Can you provide the link to download the Open source code of ZedGraph of Version  5.0.9.41461 .

Other versions are available in the following links .

http://sourceforge.net/project/showfiles.php?group_id=114675

Please Help !!!!!!!!!!

Thanks Rishi

graph and caption

Hello,

I am about to create graphs with VB.NET and I do need some help:

1. How can I fix the focus for the Y- and X-axis in a bar chart? 2. How can I label a bar chart?

Do you have an example?

Thanks moh

how to clear the created graph?

When I have create a graph,how can I clear it? I just want to display one graph at the same time. When I choose another set of data, the graph will changed with the data, only one graph displayed all the time. Can someone help me? Thank U!

Customised cursor

Is there a way to create a crosshair cursor that extends to the boundaries of the graph in the X & Y axis?

This is a very useful feature in financial charting packages and I am struggling to do this with the wonderful zedgraph.


OK, I was being rather thick and have done this using the lineobj as follows:-

In my drawgraph routine I have the following code:- (nb: zgc is the name of the control on my form, and; Private _Point As Point Private _CrosshairCursor As Boolean are declared at form level, the latter obviously controls whether the cursor is drawn or not). This is probably easy peasy stuff to the majority, but if I save anyone the hours I wasted looking for a solution, then I am happy :) ).

           If _CrosshairCursor And _Point <> Nothing Then
               myPane.GraphObjList.Add(GenXhairCursor("Y"))
               myPane.GraphObjList.Add(GenXhairCursor("X"))
           End If
   Private Function GenXhairCursor(ByVal _XorY As String) As LineObj
       Dim lineobj1 As LineObj
       If _XorY = "Y" Then
           Dim y1 As Double = ((1 / zgc.Height) * _Point.Y)
           lineobj1 = New LineObj(Color.Black, 0, y1, 1, y1)
       Else
           Dim x1 As Double = ((1 / zgc.Width) * _Point.X)
           lineobj1 = New LineObj(Color.Black, x1, 0, x1, 1)
       End If
       lineobj1.Location.CoordinateFrame = CoordType.PaneFraction
       Return lineobj1
   End Function

And also:-

   '
   Private Sub MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles zgc.MouseMove
       _Point = New Point(e.X, e.Y)
       DrawGraph()
   End Sub

Happy coding, Jake.


ps, Zedgraph is the best free control in existence.

How to draw a dotted line using LineItem

How to draw a dotted line using LineItem?

LineItem myCurve = myPane.AddCurve( "people",null, topArr, Color.Red, SymbolType.Circle );

dotted line: - - - - - - - - - - - or .............


Creating a Balance Beam Graph

I would like to create a balance beam that shows upward and downward forces acting on the beam in various locations along the beam. The balance beam should tilt about the pivot point to show the net effect of the forces. I also need to be able to adjust the pivot point of the balance beam, which will change the lever arm of the forces acting on the balance beam. Is it possible to create that in ZedGraph? Thanks for your help. Ryan

Personal tools