C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Graphics »

Graph Control(ZedGraph Control)


Posted Date: 21 Apr 2009    Resource Type: Code Snippets    Category: Graphics
Author: gopal.netMember Level: Gold    
Rating: 1 out of 5Points: 10



hi to all,
The following is the code useful drawing graph with different curves with different colors by reading from text file.
ZED-GRAPH CONTROL


private void StripButton_Start_Click(object sender, EventArgs e)
{
// zgc means Zedgraph name,mypane means graph body
myPane = zgc.GraphPane;
// Draw Curve
myCurve = myPane.AddCurve("", list, Color.Red, SymbolType.Circle);
myCurve.Symbol.Size = 5.0F;
myCurve.Symbol.Fill = new Fill(Color.Black);
// Make up some data arrays based on the Sine function
objstream = new StreamReader("E:\\temp.txt"); //Reading data from text file//

// Generate a red curve with diamond
// symbols, and "Porsche" in the legend
zgc.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(MyContextMenuBuilder);
// Set the Y axis intersect the X axis at an X value of 0.0
myPane.YAxis.Cross = 0.0;
// Calculate the Axis Scale Ranges
zgc.AxisChange();

//Timer Enabled
timer1.Enabled = true;
}

private void timer1_Tick(object sender, EventArgs e)
{
GraphPane myPane = zgc.GraphPane;

// Reading the Upto End of File
while (!objstream.EndOfStream)
{
zgc.AxisChange();
zgc.Refresh();
zgc.BringToFront();
str = objstream.ReadLine();
tw.WriteLine(str+"\n");
textBox.Text = str;
string st = textBox6.Text;
object[] myColor ={ Color.Red, Color.Blue, Color.Yellow, Color.Green, Color.HotPink };
myCurve = myPane.AddCurve("", list, (Color)myColor[i], SymbolType.Circle);
if (str == "")
{
//Here I new graph Starts I want to change colors when new PointpairList start. How can i?

list = new PointPairList();
myCurve = myPane.AddCurve("",list, Color.Blue, SymbolType.Circle);
myCurve.Symbol.Size = 5.0F;
myCurve.Symbol.Fill = new Fill(Color.Red);
str = objstream.ReadLine() + "\n";
i++;

}

else
{
string str1 = str.Substring(0, st.IndexOf("\t"));
string str2 = str.Substring(st.IndexOf("\t"));
x = (float)Convert.ToDecimal(str1);
y = (float)Convert.ToDecimal(str2);
list.Add(x, y);
}

}
timer1.Stop();

}




try this....
gopal




Responses

Author: Miss Meetu Choudhary    21 Apr 2009Member Level: Diamond   Points : 2
Please Post Your Resources fully formatted it saves lots of time while editing use & lt instead of "<" and & gt instead of ">" so that your code will appear as you want other wise it will be interpreted as HTML Tags as they are allowed in the resources... and use code /code in the big brackets as special tag to display the code snippets...

Thanks and Regards
Meetu Choudhary
Editor


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Zedgraph  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Simple Visualization Type Application.
Previous Resource: Gradient Color on Form Using ComboBoxes in VB.Net
Return to Discussion Resource Index
Post New Resource
Category: Graphics


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use