public void SetDataSource(GraphData value) { ds = value; FillListBox(); }
/// <summary> /// This overloaded StandardTChart is used with WindowsForms. /// </summary> /// <returns></returns> public static void StandardTChart(GraphData ds, TChart tChart1, bool preserveFormat) { if (tChart1 == null) { tChart1 = new TChart(); } if (ds == null || ds.SeriesRows.Count() == 0) { tChart1.Series.Clear(); tChart1.Text = ""; //return tChart1; } try { int sz = ds.SeriesRows.Count(); if (!preserveFormat) { tChart1.Aspect.View3D = false; tChart1.Aspect.Orthogonal = false; tChart1.Series.Clear(); if (sz == 1) // single graph series. { tChart1.Legend.Visible = false; } else { tChart1.Legend.Visible = true; tChart1.Legend.Alignment = LegendAlignments.Top; } } tChart1.Text = ds.GraphRow.Title; tChart1.Axes.Right.Title.Text = ""; tChart1.Axes.Left.Title.Text = ""; string unitsOfFirstSeries = ds.SeriesRows.First().Units.Trim(); //for(int i=0; i<sz; i++) int i = 0; foreach (var s in ds.SeriesRows) { string tblName = s.TableName; DataTable dataTable = ds.GetTable(tblName); string columnName = dataTable.Columns[1].ColumnName; double avg = AverageOfColumn(dataTable, columnName); Steema.TeeChart.Styles.Line series = null; if (preserveFormat && i < tChart1.Series.Count && tChart1[i] is Steema.TeeChart.Styles.Line) { series = tChart1[i] as Steema.TeeChart.Styles.Line; } else { series = CreateSeries(tChart1, dataTable, columnName, avg); } LoadSeriesData(dataTable, columnName, avg, series); series.Title = s.Title; if (i > 0) // check units to determine what yaxis to use(left,or right) { string units = s.Units.Trim(); if (units != unitsOfFirstSeries) { // right axis series.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right; if (tChart1.Axes.Right.Title.Text.IndexOf(s.Units) < 0) { tChart1.Axes.Right.Title.Text += s.Units + " "; } //tChart1.Axes.Right.Labels.Color = Color.Red;//series.Color; } else { // left axis if (tChart1.Axes.Left.Title.Text.IndexOf(s.Units) < 0) { tChart1.Axes.Left.Title.Text += s.Units + " "; } } } else { tChart1.Axes.Left.Title.Text = s.Units + " "; } tChart1.Series.Add(series); i++; } //tChart1.Zoom.Undo(); //tChart1.Zoom.ZoomPercent(97); } catch (Exception exc) { System.Windows.Forms.MessageBox.Show(exc.Message + "\n " + exc.StackTrace); } }