Talk:Main Page
From ZedGraphWiki
// Help required regarding the backGround Hatching Style for Bar charts Hi Guys, I am stuck with some simple problem while using Zed Graph. I want to put background hatching style for the bar chart. What i mean to say is that i want background style like daigonal, briks, cross etc on the background of the chart.. If any one has idea of implementation using ZedGraph, please share with. I am thankful to all your efforts for give time in thinking about my problem...
LineChart: my lines always start at (0,0)
I'm using a Linear XAxis and the provided x,y values never start in 0,0... but my chart always do. I mean, if I draw just 1 point... I suppose I would get a point in the graph, but instead it draws a line from (0,0) to my point. It is not a problem with the MIN scale property. Do you have any ideas what can I be doing wrong? Thanks!
// After add points remove the first point (0,0):
mypanename.RemovePoint(0);
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
- Hi David, Sorry this has taken so long for you to get an answer. The problem is in ZedGraph, this is a known issue. I have a patched version, and hope to get a new release of Zedgraph out with this fix in it. In the mean-time, you can contact me by using the page https://sourceforge.net/sendmessage.php?touser=371034 and I can send you out a patched dll. I can only assume that at this stage, you have moved on from this problem. Rjosulli 02:55, 24 November 2008 (MST)
Can anyone point me to a version of ZedGraph that does not have this problem? Thanks!
- Version 5.1.5 (release today) does not have this problem. Rjosulli 09:55, 12 December 2008 (MST)
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!
You can do that (C# .NET): ......... ..........
private void CreateGraphClean(ZedGraphControl zgc)
{
GraphPane mypane = zgc.GraphPane;
mypane.CurveList.Clear();
zgc.Refresh();
}
........... ..........
private void buttonClean_Click(object sender, EventArgs e)
{
CreateGraphClean(zg1);
}
Amnesia 11:47, 12 August 2010 (MDT) Thank You!
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 .............
Your can use this:
myCurve.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash; // or change other types of lines
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
Class GraphPane..methodAddErrorBar() NOT working
ZEDgraph ver 5.1.4, Class GraphPane, method AddErrorBar() is described in the chm file as:
public ErrorBarItem AddErrorBar ( string label, double[] x, double[] y, double[] baseValue, Color color )
Parameters label (String) The text label (string) for the curve that will be used as a Legend entry.
x (array<Double>[]()) An array of double precision X values (the independent values) that define the curve.
y (array<Double>[]()) An array of double precision Y values (the dependent values) that define the curve.
baseValue (array<Double>[]()) An array of double precision values that define base value (the bottom) of the bars for this curve.
color (Color) The color to used for the curve line, symbols, etc.
But the following simple example shows it does not work. It always generates an error bar with baseValue=zero, regardless of the value for parameter baseValue:
double[] xx = new double[1] {1.0};
double[] xh= new double[1] {-20.0};
double[] xb= new double[1] {-40.0};
myCurve = myGraphPane.AddErrorBar ("LL", xx, xh, xb, Color.Black );
How do I create Hi/Low bar chart with text x-axis and offset bars at each point?
I am trying to create a Hi-Low bar chart with xAxis of type text and staggered bars. I am trying to create a comparison. For example, information would be: Item Apples Oranges "Price" $1-$1.5 $0.05 - $0.06 "Profit" $1.2 - $1.3 $0.10 - $0.12
In this case the x-axis would have two values - Price and Profit. For each, there would be a bar for Apples and Oranges that shows the range. The bars would have to be one next to the other. By default, they overlap and you can't see what is really being shown. Thanks for your help, Jay
ZEDGraph bar charts
It's very frustrating trying to figure out how to graph HiLow Bar, The CHM help file is useless in resolving this matter.
Why do ZEDGraph bar plots require so much time to figure out ?? Any vertical bar on a chart can be defined by 6 parameters:
x x-axis value where lower left of bar is positioned, y1 y-axis value for top of bar, y2 y-axis value for bottom of bar, W bar width in x-axis units, C bar color, and F bar fill pattern
For multiple bars, the k-th bar would be defined by x[k], y1[k], y2[k], W[k], C[k], F[k]. If W,C,F are specified as single values instead of arrays, they would apply to all bars)
Thus all the ZEDGraph vertical bar classes (BarItem, HiLowBar, Error bars, Overlay Bars, Stacked bars etc.) can be replaced by a single BAR class with simple, easy-to-understand constructors.
For HiLoClose bars, nothing more is needed since 'close' values are essentially an additional symbol plot super-imposed on the bars defined above. Same idea for OHLCB bars.
Y2 memory problem
Hi, I am using Zedgraph on a test application and the program may display thousands of graphs a day. I had problems with my application consuming memory and when I elliminated graphs (Zedgraph), the problem went away. I eventually found that as long as I didn't create a Y2 axis there was not a problem.
Any Thoughts?
How do I change the size &/or color of a point on a graph?
I've been asked to create a graph as follows:
Along the X-axis time would be plotted.
The values of the series along the Y-axis would be fixed so the points of interest would run horizontally
The graph that's wanted is a kind of bubble graph.
Where the Y & X asis intersect, if a secondary value related to the Y series was above a threshold, a point would be plotted.
All of this I have working.
What I'd like to be able to do is to change the size and/or color of the point that's plotted based on the magnitude of the secondary value.
Has anyone done something similar to this in the past and, if so, would you post an example on how to do it?
This code gives an idea of what I'd like.
private void BubbleTest()
{
string[] sDates = {"2007-11-10","2007-11-11","2007-11-12","2007-11-13",
"2007-11-14","2007-11-15","2007-11-16"};
string[] sSeries = { "S1", "S2", "S3", "S4" };
string[] sVal1 = { "1", "5", "2", "2", "1", "8", "4" };
string[] sVal2 = { "4", "3", "2", "9", "9", "8", "2" };
string[] sVal3 = { "2", "4", "6", "8", "10", "12", "14" };
string[] sVal4 = { "2", "2", "3", "4", "3", "3", "4" };
string[][] sv = { sVal1, sVal2, sVal3, sVal4 };
for (int s = 0; s < sSeries.Length; s++)
{
PointPairList ppl = new PointPairList();
for (int p = 0; p < sVal1.Length; p++)
{
XDate xd = new XDate(DateTime.Parse(sDates[p]));
double z = double.Parse( sv[s][ p]);
if (z >= 4)
{
PointPair pt = new PointPair((double)xd, s + 1, z);
ppl.Add(pt);
}
}
LineItem li = zgcGraph1.GraphPane.AddCurve(sSeries[s], ppl, Color.Black, SymbolType.Diamond);
li.Tag = sSeries[s];
li.Symbol.Fill = new Fill(li.Color);
li.Symbol.Border.IsVisible = true;
li.Line.IsVisible = false;
}
zgcGraph1.GraphPane.XAxis.Type = AxisType.Date;
//zgcGraph1.GraphPane.XAxis.Scale.FontSpec.Angle = 65;
//zgcGraph1.GraphPane.XAxis.Scale.FontSpec.IsBold = true;
//zgcGraph1.GraphPane.XAxis.Scale.FontSpec.Size = 12;
zgcGraph1.GraphPane.XAxis.Scale.Format = "d MMM\r\n ddd";
zgcGraph1.AxisChange();
}
Thanks in advance.
Don
Here is what I did. It's cheesy, but it seems to work:
1. Add a new curve to your chart with one single point pair at the same location that you want to high-light. 2. Change the property on the curve to the correct symbol that you want. 3. If you wnat to replace that point by some other point, delete that curve and add another one. that way, you don't have a lot of curves floating around.
tvu.
Re-boot of ZedGraph
Hi all, you may have noticed that there has been no activity on the ZedGraph project for quite some time now (I'm not sure how long it has been since anyone has been actively working on it).
I am interested in getting it back on it's feet and getting a community together who use it and can discuss what the future should be for ZedGraph. It's the community that can provide help and feedback to other users and who can make sure that it remains as useful as it currently is.
This is a great project, and I still can't find a graphing library that does what it does (never mind does it in a .NET language). If anyone is interested in getting involved, leave a message here, I'll look into creating a page for discussion on this specific topic. Maybe we can even start answering some of the above questions. Rjosulli 02:49, 24 November 2008 (MST)
NOTE: add your comments HERE Rjosulli 02:57, 24 November 2008 (MST)
With my limit programming experience, count me in. I have only been using ZedGraph recently, but I love the tool. I will start answering some of the questions here that I know the answer to.
How do I display horizontal bar labels on vertical bars?
I found the demo to display vertical bar labels on vertical bars and horizontal bar labels on horizontal bars, but no way to display them horizontal for vertical. Any suggestions? http://zedgraph.org/wiki/index.php?title=Vertical_Bar_With_Labels_Demo
This may not be the most elegant way to do it, but it works.
' Move the bar labels
Dim sc As Scale = pane.YAxis.Scale
Dim offset As Double = (sc.Max - sc.Min) * 0.02
For Each lab As Object In pane.GraphObjList
If lab.GetType Is GetType(TextObj) Then
With CType(lab, TextObj)
.FontSpec.Angle = 0
.Location.Y += offset
End With
End If
Next
I have a problem
Excuse for my english, I'm a russian. I have some problem with use of ZedGraph. Can you tell me how can I move a zeroline under zero-value, for example on value =-30?? If you can help me with my problem, please write me ICQ 361-494-578.
CHM File for v5.1.5 shows index but no help text
The CHM file for v5.1.5 shows the index but no text. All items show a "This page cannot be displayed". Is there a setting or fixed location where this CHM should reside?
Visual aid to capturing points
Greetings, I'm using ZedGraph (awesome chunk of code, BTW!) as a strip chart to display some pressure vs time data. I'd like to be able to visually indicate a region on the graph for which the data should be analyzed. For example, a user would like to capture the data from 11 seconds to 88 seconds. I've successfully experimented with getting the point nearest the mouse position when I click, but I don't have a good way to show the user visually what region has been captured. I'm looking for something like the dotted line box that's drawn when one uses the 'Zoom' feature on a graph. In fact, more generally, I'd like to be able to draw lines / shapes on a graph. Any hints? Much appreciated!
Graph in Smartphone
Hi everyone, I really really need help on this. [my life is dependent on it :(] OK I need to create a bar-graph on windows Mobile and I could easily do it on windows using the DLL provided. But how could I use the Dll in Windows Mobile [smart-phone]?
Plz help me on this, since we have the source code, I think someone could create Dll for Smartphone [but I am very new to programming], or if you know any other way I could simply show any bar graph on Smart-phone.
I am satisfy with anything [I even tried to use progress bar, but I could not rotate it] if you have any comment or ideas plz let me know .
How do I make my web graph bigger?
Hi, I'm new to ZedGraph. It's working great, but how do I make the whole graph bigger? I see adjustments for scale, etc...but my overall graph is tiny by default. Thanks for any replies. I'm using the web version.
Look at your graph in design view in Visual Studio and edit the height and width settings for the MasterPane.
How do I Automatically Zoom a Bar Graph?
I've created a horizontal bar graph, but have noticed that my Y Axis is not tall enough to display all categories (I want all Y Axis values displayed even if their bar has a height of zero). I can get the proper zoom by right-clicking on my graph and hitting "Set Scale to Default", but how do I do via code in C#?
AxisType.Text for Y axis
hi,
I want to AxisType.Text for Y axis. In the example given below its given as x-axis.
How i can do it for Y or Y2 axis.
Basically ,y values are enumerated values for which i want to plot a graph. How i can do it for Y axis using 'AxisType.Text' or any other property settings...?
http://zedgraph.org/wiki/index.php?title=Tutorial:Text_Axis_Chart_Demo&redirect=no
Thanks in davance, Zee
X-axis with date and time
Hi.
in my application i want to plot a line graph using data from database. there are several columns which include date, time and data. there are multiple time entries along with same no. of data entries for each date.
what i want to do is plot the date and time on xaxis such that date is displayed once for all the time entries belonging to that date. also date should be displayed on next line.
please help me achive this. please help
zed.
How do I Re-scale multiple y-axes when zooming on one?
I have 4 graphs stacked and Synchronized on the X axes. When I zoom in on a chunk of data on one, I want all the y axes on each of the graphs to rescale. Right now it looks like flat lines. I want each y axis to take up the maximum amount of space while fitting in the window.
Thanks!
PaneLayout.SingleColumn master pane chart with the same XAxis
Hello
I have a master pane that contains 3 graph pane with the SingleColumn setting. What i want is that the two graph panes on the top to enherit the xAxis from the first graph.
10x.
graph with color shaded
Hello everybody! My table looks like it:
984,5000901 962,5906104 962,5906104 962,5906104 964,7384707
984,5000901 978,0787584 978,0787584 978,0787584 972,6781589
927,2294968 930,1109876 998,4731156 998,4731156 993,1826341
1108,127272 973,1089432 969,1068961 969,1068961 969,1068961
1108,127272 973,1089432 976,5383053 976,5383053 976,5383053
In my graph, I 'd like that each value correspond to a color shade in a way to show high values and low values ...


