Private void form4_load (Object sender, eventargs E)
{
Createchart (zedgraphcontrol1 );
}
Public void createchart (zedgraphcontrol zgc)
{
Graphpane mypane = zgc. graphpane;
// Set the titles and axis labels
Mypane. Title. Text = "production line output analysis chart ";
// Mypane. xaxis. Title. Text = "time period ";
// Mypane. yaxis. Title. Text = "pressure, PSIA ";
Mypane. xaxis. Title. isvisible = false;
Mypane. yaxis. Title. isvisible = false;
Mypane. xaxis. majorgrid. isvisible = true; // Shan Ge
Mypane. yaxis. majorgrid. isvisible = true;
String [] labels = {"7 ~ "," 8 ~ 9: "," 9 ~ 10 o'clock "," 10 ~ "," 11 ~ 12: 00 "," 12 ~ "," 13 ~ "," 14 ~ "," 15 ~ 16 o'clock "," 16 ~ 17 o'clock "," 17 ~ 18 o'clock "};
Double [] Y = {2000,100 0, 5000,250 0, 3500,750 5200 };
Double [] x = {4000,300 0, 2500,350 0, 1500,550 0, 2000 };
// Hide the legend
Mypane. Legend. isvisible = true;
// Add a curve
Lineitem curve = mypane. addcurve ("total output", null, Y, color. Red, symboltype. Diamond );
Curve. Line. width = 2.0f;
Curve. Line. isantialias = true;
Curve. symbol. Fill = New fill (color. White );
Curve. symbol. size = 7;
Lineitem curve1 = mypane. addcurve ("C-line output", null, X, color. Blue, symboltype. Circle );
Curve1.line. width = 2.0f;
Curve1.line. isantialias = true;
Curve1.symbol. Fill = New fill (color. White );
Curve1.symbol. size = 7;
// Fill the axis background with a gradient
Mypane. Chart. Fill = New fill (color. White, color. fromargb (255, color. forestgreen), 45.0f );
// Offset y space between point and label
// Note: This offset is in Y scale units, so it depends on your actual data
Constdouble offset = 1.0;
// Loop to add text labels to the points
For (INT I = 0; I <Y. length; I ++)
{
// Get the pointpair
Pointpair Pt = curve. Points [I];
// Create a text label from the y Data Value
Textobj text = new textobj (Pt. Y. tostring ("F2"), Pt. X, Pt. Y + offset,
Coordtype. axisxyscale, alignh. Left, alignv. center );
Text. zorder = zorder. a_infront;
// Hide the border and the fill
Text. fontspec. Border. isvisible = false;
Text. fontspec. Fill. isvisible = false;
// Text. fontspec. Fill = New fill (color. fromargb (100, color. White ));
// Rotate the text to 90 degrees
Text. fontspec. angle = 50; // font skew
Mypane. graphobjlist. Add (text );
}
For (INT I = 0; I <X. length; I ++)
{
// Get the pointpair
Pointpair Pt = curve1.points [I];
// Create a text label from the y Data Value
Textobj text = new textobj (Pt. Y. tostring ("F2"), Pt. X, Pt. Y + offset,
Coordtype. axisxyscale, alignh. Left, alignv. center );
Text. zorder = zorder. a_infront;
// Hide the border and the fill
Text. fontspec. Border. isvisible = false;
Text. fontspec. Fill. isvisible = false;
// Text. fontspec. Fill = New fill (color. fromargb (100, color. White ));
// Rotate the text to 90 degrees
Text. fontspec. angle = 50; // numeric font skew
Mypane. graphobjlist. Add (text );
}
// Leave some extra space on top for the labels to fit within the chart rect
// Mypane. yaxis. Scale. maxgrace = 0.2;
Mypane. xaxis. type = axistype. text;
Mypane. xaxis. Scale. textlabels = labels;
Mypane. xaxis. Scale. fontspec. size = 8; // X-ray font
Mypane. xaxis. Scale. fontspec. angle = 60; // X-ray font skew
// Calculate the axis scale ranges
Zgc. axischange ();
}