1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| private void CreateGraph(ZedGraphControl zgc, DataTable dt,string AxeX, String AxeY,
String Ptf)
{
GraphPane myPane = zgc.GraphPane;
myPane.CurveList.Clear();
// Set the Titles
myPane.Title.Text = AxeX + " / " + AxeY;
myPane.XAxis.Title.Text = AxeX;
myPane.YAxis.Title.Text = AxeY;
// Populate a PointPairList
PointPairList list = new PointPairList();
double x;
double y;
double z;
for (int i = 0; i < dt.Rows.Count ; i++)
{
x = Convert.ToDouble(dt.Rows[i][xind]);
y = Convert.ToDouble(dt.Rows[i][yind]);
z = Convert.ToDouble(dt.Rows[i]["PtfWeight"]);
list.Add(x, y, z > 0 ? 2.0 : 1.0);
}
// Add the curve
LineItem myCurve = myPane.AddCurve("Performance", list, Color.Black, SymbolType.Diamond);
// Don't display the line (This makes a scatter plot)
myCurve.Label.IsVisible = false;
myCurve.Line.IsVisible = false;
// use a gradient fill to color the each line segment according to its Z value
// Color will be blue for Z = 2, and red for Z = 1
myCurve.Symbol.Fill = new Fill(Color.FromArgb(99, 144, 171), Color.FromArgb(240, 0, 86));
myCurve.Symbol.Border.IsVisible = false;
myCurve.Symbol.Fill.Type = FillType.GradientByZ;
myCurve.Symbol.Fill.RangeMin = 1;
myCurve.Symbol.Fill.RangeMax = 2;
//myCurve.Symbol.Fill.SecondaryValueGradientColor = Color.FromArgb(99, 144, 171);
// Fill the background of the chart rect and pane
myPane.Chart.Fill = new Fill(Color.White, Color.White, 45.0f);
myPane.Fill = new Fill(Color.White, Color.White, 45.0f);
myPane.XAxis.MajorGrid.IsVisible = true;
myPane.XAxis.MajorGrid.Color = Color.FromArgb(135, 136, 126);
myPane.YAxis.MajorGrid.IsVisible = true;
myPane.YAxis.MajorGrid.Color = Color.FromArgb(135, 136, 126);
myPane.YAxis.Scale.FontSpec.Size = 10;
myPane.XAxis.Scale.FontSpec.Size = 10;
myPane.YAxis.Title.FontSpec.Size = 14;
myPane.XAxis.Title.FontSpec.Size = 14;
//myPane.;
// Tell ZedGraph to refigure the
// axes since the data have changed
zgc.AxisChange();
} |
Partager