private void SetupGraphs() { double[] x = { 0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6 }; try { pAboveGround.Model.Axes.Clear(); pAboveGround.Model.Series.Clear(); pBelowGround.Model.Axes.Clear(); pBelowGround.Model.Series.Clear(); pAboveGround.Model.Title = "Above Ground"; pAboveGround.Model.PlotAreaBorderColor = OxyColors.White; pAboveGround.Model.LegendBorder = OxyColors.Transparent; LinearAxis agxAxis = new LinearAxis(); agxAxis.Title = "Multiple of Tree Height"; agxAxis.AxislineStyle = LineStyle.Solid; agxAxis.AxisDistance = 2; agxAxis.Position = AxisPosition.Top; LinearAxis agyAxis = new LinearAxis(); agyAxis.Title = "%"; agyAxis.AxislineStyle = LineStyle.Solid; agyAxis.AxisDistance = 2; Utility.LineSeriesWithTracker seriesShade = new Utility.LineSeriesWithTracker(); List <DataPoint> pointsShade = new List <DataPoint>(); DataRow rowShade = table.Rows[0]; DataColumn col = table.Columns[0]; double[] yShade = new double[table.Columns.Count - 1]; pAboveGround.Model.Axes.Add(agxAxis); pAboveGround.Model.Axes.Add(agyAxis); for (int i = 1; i < table.Columns.Count; i++) { if (rowShade[i].ToString() == "") { return; } yShade[i - 1] = Convert.ToDouble(rowShade[i]); } for (int i = 0; i < x.Length; i++) { pointsShade.Add(new DataPoint(x[i], yShade[i])); } seriesShade.Title = "Shade"; seriesShade.ItemsSource = pointsShade; pAboveGround.Model.Series.Add(seriesShade); } //don't draw the series if the format is wrong catch (FormatException) { pBelowGround.Model.Series.Clear(); } /////////////// Below Ground try { pBelowGround.Model.Title = "Below Ground"; pBelowGround.Model.PlotAreaBorderColor = OxyColors.White; pBelowGround.Model.LegendBorder = OxyColors.Transparent; LinearAxis bgxAxis = new LinearAxis(); LinearAxis bgyAxis = new LinearAxis(); bgyAxis.Position = AxisPosition.Left; bgxAxis.Position = AxisPosition.Top; bgyAxis.Title = "Depth (mm)"; bgxAxis.Title = "Root Length Density (cm/cm3)"; bgxAxis.Minimum = 0; bgxAxis.MinorTickSize = 0; bgxAxis.AxislineStyle = LineStyle.Solid; bgxAxis.AxisDistance = 2; pBelowGround.Model.Axes.Add(bgxAxis); bgyAxis.StartPosition = 1; bgyAxis.EndPosition = 0; bgyAxis.MinorTickSize = 0; bgyAxis.AxislineStyle = LineStyle.Solid; pBelowGround.Model.Axes.Add(bgyAxis); for (int i = 1; i < table.Columns.Count; i++) { Utility.LineSeriesWithTracker series = new Utility.LineSeriesWithTracker(); series.Title = table.Columns[i].ColumnName; double[] data = new double[table.Rows.Count - 4]; for (int j = 4; j < table.Rows.Count; j++) { data[j - 4] = Convert.ToDouble(table.Rows[j].Field <string>(i)); } List <DataPoint> points = new List <DataPoint>(); for (int j = 0; j < data.Length; j++) { points.Add(new DataPoint(data[j], SoilMidpoints[j])); } series.ItemsSource = points; pBelowGround.Model.Series.Add(series); } } //don't draw the series if the format is wrong catch (FormatException) { pBelowGround.Model.Series.Clear(); } finally { pAboveGround.InvalidatePlot(true); pBelowGround.InvalidatePlot(true); } }