Can anyone how can i use a zedgraph?
Printable View
Can anyone how can i use a zedgraph?
Can you be a bit more specific? What exactly do you want to do that you can't do? Have you installed ZedGraph and referenced it from your project? Also, have you bothered to search? I Googled zedgraph and the main page was the first result and these were 2 and 3.
http://zedgraph.org/wiki/index.php?title=Sample_Graphs
http://www.codeproject.com/KB/graphics/zedgraph.aspx
It not going to get much easier than that.
ok, i want to create a zedgraph using a bar types in horizontal by showing it's value.....
I need example...can you help me pls...
So, when you followed the first link I provided in my last post, then clicked the second image for the Bar Charts examples, then clicked the sixth image for the Horizontal Bar With Labels Demo example, which part was confusing you?
If it's the fact that they provide C# code then you should first of all make sure you've read the code to get as much from it as you can. It's really not that different to VB code. You should then look at the sample VB code they provide from the Sample Graphs page to see how it compares. You should then try to write VB code that's equivalent to the C# sample code. If you can't then there are online code converters that do a decent job, or you could download Instant VB, which does a near perfect job.
ok thanks..
What if i want to create a zedgrpah with one bar...
in zedgrpah sample it shows with more bars..
but i want to make a graph with one bar only
how can i do that...
If you want multiple bars then you have to create one bar multiple times. If you only want one bar then you only do it once. Have you looked at the code for that sample? It displays three sets of bars and the code does various things three times. If you only want one set of bars you only do those things once.
can you do some sample code?
You've already got sample code. You just need to take out the bits you don't want. Like I said, that horizontal bar sample creates three sets of bars. If you only want one set then you simply take out the code that creates the other two.
i can't not make it one bar...
Here's my code:
Private Sub zedgraph01(ByVal z2 As ZedGraphControl)
Dim myPane1 As GraphPane = z2.GraphPane
myPane1.Title.Text = "Checking Of Station Per Day"
myPane1.XAxis.Title.Text = "Premium"
Dim list1 As New PointPairList
Dim rad1 As New Random
Dim i1 As Integer
For i1 = 0 To 1
Dim x As Double = CDbl(i1) + 1
Dim y As Double = 70
list1.Add(x, y)
Next i1
Dim myCurve1 As BarItem = myPane1.AddBar("M", list1, Color.Blue)
Dim colors1 As Color() = {Color.Red, Color.Yellow}
myCurve1.Bar.Fill = New Fill(colors1)
myCurve1.Bar.Fill.Type = FillType.GradientByX
myCurve1.Bar.Fill.RangeMin = 0
myCurve1.Bar.Fill.RangeMax = 5
myPane1.Chart.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45)
z2.AxisChange()
End Sub
The number of bars in a set is controlled by the number of items you add to your PointPairList. You're adding two items to your PointPairList so you end up with two bars in the set. If you only want a single bar in the set then you only need to add one item to your PointPairList. If you're only adding one item then you don't need to add it in a loop, so get rid of that For loop.
Hi,
I'm also getting to grips with ZedGraph, but am stumped with the following code: Sub CreateGraph correctly displays the curves in the pane. But if I want to add lines later by calling sub DrawGraphs I get a run-time error as noted in the file.
What am I missing??
Thanks for any pointers,HTML Code:Public Sub CreateGraph(ByVal zgc As ZedGraphControl)
Dim BiasGraph As GraphPane = zgc.GraphPane
' Set the titles and axis labels
BiasGraph.Title.Text = "Linear Audio Bias Sleuth"
BiasGraph.XAxis.Title.Text = "mSecs"
BiasGraph.YAxis.Title.Text = "mAmperes"
' Make up some data points from the Sine function
Dim list = New PointPairList()
Dim x As Double, y As Double
For x = 0 To 36
y = Math.Sin(x * Math.PI / 15.0)
list.Add(x, y)
Next x
' Generate a blue curve with circle symbols
Dim BiasCurve As LineItem = BiasGraph.AddCurve("Bias Current", list, Color.Blue, SymbolType.Circle)
' Make the symbols opaque by filling them with white
BiasCurve.Symbol.Fill = New Fill(Color.White)
' Fill the axis background with a color gradient
BiasGraph.Chart.Fill = New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)
' Fill the pane background with a color gradient
BiasGraph.Fill = New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)
' Calculate the Axis Scale Ranges
'BiasGraph.AxisChange()
zgBiasGraph.AxisChange()
zgBiasGraph.Refresh()
End Sub
Public Sub DrawGraphs(ByVal BiasGraph)
' Make up some data points from the Sine function
Dim list = New PointPairList()
Dim x As Double, y As Double
For x = 18 To 54
y = Math.Sin(x * Math.PI / 15.0)
list.Add(x, y)
Next x
'CreateGraph(BiasGraph)
' Generate a red curve with circle symbols
'The next line gives a runtime error:
'AddCurve is not a member of the ZedGraph calss or similar wording...
Dim BiasCurve As LineItem = BiasGraph.AddCurve("Bias Current", list, Color.Red, SymbolType.Circle)
' Calculate the Axis Scale Ranges
'BiasGraph.AxisChange()
zgBiasGraph.AxisChange()
zgBiasGraph.Refresh()
End Sub
Jan Didden