/// <summary> /// constructor /// </summary> /// <param name="cd">Chart Data</param> /// <param name="cc">Chart Control</param> public DrawText(ChControl cc, ChartData cd) { //Init Properties this.Title = cd.Title; this.XLabel = cd.TitleX; // this.YLabels = cd.TitlesY; this.XType = cd.AxisLabelX; this.YType = cd.AxisLabelY; if (cd.TitlesY != null && cd.TitlesY.Length == 1) { legendhorizontal = false; } //Set ChControl this.cc = cc; //Init legend ly = new DrawLegend(); //Add legend and ChControl to Children this.Children.Add(cc); this.Children.Add(ly); //Set Parents of legend and ChControl ly.Parent = this; cc.Parent = this; }
/// <summary> /// Initialize the graph component, only called explicitly when the graph changes /// </summary> void InitializeComponents(Graphics g) { if (cds.Length == 0) { return; } gr = new DrawGrid(cds); colorTheme.Reset(); legend = new DrawLegend(); DrawPlot dp; for (int i = 0; i < cds.Length; i++) { ChartData cd = cds[i]; if (cd.Y.Length == 0 || cd.X.Length == 0) { continue; } //Choose chart switch (cd.ChartType) { case ChartType.Curve: dp = new ChartTypes.Curve(cd.X, cd.Y, cd.TitlesY); break; case ChartType.Stem: dp = new ChartTypes.Stem(cd.X, cd.Y, cd.TitlesY); break; case ChartType.Fast: dp = new ChartTypes.FastCurve(cd.X, cd.Y, cd.TitlesY); break; case ChartType.Histogram: dp = new ChartTypes.Histogram(cd.X, cd.Y, cd.TitlesY); break; case ChartType.Points: dp = new ChartTypes.Points(cd.X, cd.Y, cd.TitlesY); break; case ChartType.Cross: dp = new ChartTypes.Cross(cd.X, cd.Y, cd.TitlesY); break; case ChartType.Step: dp = new ChartTypes.Step(cd.X, cd.Y, cd.TitlesY); break; case ChartType.CurveWide: dp = new ChartTypes.CurveWide(cd.X, cd.Y, cd.TitlesY); break; default: dp = new ChartTypes.Curve(cd.X, cd.Y, cd.TitlesY); break; } //Set colors Color[] plotcolors = new Color[cd.Y.Length]; for (int j = 0; j < cd.Y.Length; j++) { if (cd.Z != null && cd.Z.Length > j) { //int index = (int)Math.Floor(cd.Z[j] % cols.Length); //if (index > 0 && index < cols.Length) // plotcolors[j] = cols[index]; //plotcolors[j] = Color.FromArgb((int)cd.Z[j] * 25, 66, 99); } else { plotcolors[j] = colorTheme.Next(); } // } } dp.Colors = plotcolors; //Set legend for (int j = 0; j < cd.Y.Length; j++) { if (cd.TitlesY != null) { if (cd.TitlesY.Length > j) { legend.Add(dp.Colors[j], cd.TitlesY[j]); } } } gr.Add(dp); } //Add axis labels lg = new DrawGridAxis(gr); lg.NumberOfDecimals = numbdecimals; //Add text l = new DrawText(lg, cds[0]); l.SetLegend(legend); l.ShowTitle = ShowTitle; l.ShowLegend = ShowLegend; l.Location = new System.Drawing.Point(0, 0); l.Size = this.Size; //Set ForeColors gr.GridColor = this.ForeColor; lg.ForeColor = this.ForeColor; legend.ForeColor = this.ForeColor; l.ForeColor = this.ForeColor; //Initialize Controls l.Init(g); }
public void SetLegend(DrawLegend ly) { this.ly = ly; }