public void DrawArea( string title, IEnumerable x1, IEnumerable y1, IEnumerable x2, IEnumerable y2, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, bool showOnLegend) { }
/// <summary> /// Stub method for interface. This method is not used as the plots are not editable. /// </summary> /// <param name="title"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="xAxisType"></param> /// <param name="yAxisType"></param> /// <param name="colour"></param> /// <param name="lineType"></param> /// <param name="markerType"></param> /// <param name="showOnLegend"></param> public void DrawLineAndMarkers( string title, IEnumerable x, IEnumerable y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, Models.Graph.LineType lineType, Models.Graph.MarkerType markerType, bool showOnLegend) { }
/// <summary> /// Gets the maximum scale of the specified axis. /// </summary> public double AxisMaximum(Models.Graph.Axis.AxisType axisType) { OxyPlot.Axes.Axis axis = GetAxis(axisType); if (axis != null) { return(axis.ActualMaximum); } else { return(double.NaN); } }
/// <summary> /// Gets the interval (major step) of the specified axis. /// </summary> public double AxisMajorStep(Models.Graph.Axis.AxisType axisType) { OxyPlot.Axes.Axis axis = GetAxis(axisType); if (axis != null) { return(axis.IntervalLength); } else { return(double.NaN); } }
/// <summary> /// Return an axis that has the specified AxisType. Returns null if not found. /// </summary> /// <param name="axisType">The axis type to retrieve </param> /// <returns>The axis</returns> private OxyPlot.Axes.Axis GetAxis(Models.Graph.Axis.AxisType axisType) { int i = this.GetAxisIndex(axisType); if (i == -1) { return(null); } else { return(this.plot1.Model.Axes[i]); } }
/// <summary>Gets an array of values for the given enumerator</summary> /// <param name="xEnum">The enumumerator</param> /// <param name="axisType">Type of the axis.</param> /// <returns></returns> private double[] GetDataPointValues(IEnumerator enumerator, Models.Graph.Axis.AxisType axisType) { List <double> dataPointValues = new List <double>(); enumerator.MoveNext(); if (enumerator.Current.GetType() == typeof(DateTime)) { this.EnsureAxisExists(axisType, typeof(DateTime)); do { DateTime d = Convert.ToDateTime(enumerator.Current); dataPointValues.Add(DateTimeAxis.ToDouble(d)); if (d < smallestDate) { smallestDate = d; } if (d > largestDate) { largestDate = d; } }while (enumerator.MoveNext()); } else if (enumerator.Current.GetType() == typeof(double) || enumerator.Current.GetType() == typeof(float)) { this.EnsureAxisExists(axisType, typeof(double)); do { dataPointValues.Add(Convert.ToDouble(enumerator.Current, System.Globalization.CultureInfo.InvariantCulture)); }while (enumerator.MoveNext()); } else { this.EnsureAxisExists(axisType, typeof(string)); CategoryAxis axis = GetAxis(axisType) as CategoryAxis; do { int index = axis.Labels.IndexOf(enumerator.Current.ToString()); if (index == -1) { axis.Labels.Add(enumerator.Current.ToString()); index = axis.Labels.IndexOf(enumerator.Current.ToString()); } dataPointValues.Add(index); }while (enumerator.MoveNext()); } return(dataPointValues.ToArray()); }
/// <summary> /// Return an axis that has the specified AxisType. Returns null if not found. /// </summary> /// <param name="axisType">The axis type to retrieve </param> /// <returns>The axis</returns> private int GetAxisIndex(Models.Graph.Axis.AxisType axisType) { AxisPosition position = this.AxisTypeToPosition(axisType); for (int i = 0; i < this.plot1.Model.Axes.Count; i++) { if (this.plot1.Model.Axes[i].Position == position) { return(i); } } return(-1); }
/// <summary> /// Gets the minimum scale of the specified axis. /// </summary> public double AxisMinimum(Models.Graph.Axis.AxisType axisType) { plot1.Refresh(); OxyPlot.Axes.Axis axis = GetAxis(axisType); if (axis != null) { return(axis.ActualMinimum); } else { return(double.NaN); } }
/// <summary> /// Gets the minimum scale of the specified axis. /// </summary> public double AxisMinimum(Models.Graph.Axis.AxisType axisType) { /// TBI foreach (PlotView p in plots) /// TBI p.Refresh(); OxyPlot.Axes.Axis axis = GetAxis(axisType); if (axis != null) { return(axis.ActualMinimum); } else { return(double.NaN); } }
/// <summary> /// Gets the minimum scale of the specified axis. /// </summary> public double AxisMinimum(Models.Graph.Axis.AxisType axisType) { foreach (PlotView p in plots) { p.InvalidatePlot(true); } OxyPlot.Axes.Axis axis = GetAxis(axisType); if (axis != null) { return(axis.ActualMinimum); } else { return(double.NaN); } }
/// <summary> /// Convert the Axis.AxisType into an OxyPlot.AxisPosition. /// </summary> /// <param name="type">The axis type</param> /// <returns>The position of the axis.</returns> private AxisPosition AxisTypeToPosition(Models.Graph.Axis.AxisType type) { if (type == Models.Graph.Axis.AxisType.Bottom) { return(AxisPosition.Bottom); } else if (type == Models.Graph.Axis.AxisType.Left) { return(AxisPosition.Left); } else if (type == Models.Graph.Axis.AxisType.Top) { return(AxisPosition.Top); } return(AxisPosition.Right); }
public void DrawText( string text, double x, double y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour) { TextAnnotation annotation = new TextAnnotation(); annotation.Text = text; annotation.TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Left; annotation.TextVerticalAlignment = VerticalAlignment.Top; annotation.Stroke = OxyColors.White; annotation.TextPosition = new DataPoint(x, y); //annotation.XAxis = this.GetAxis(xAxisType); //annotation.YAxis = this.GetAxis(yAxisType); annotation.TextColor = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B); annotation.FontSize = FontSize - 1; this.plot1.Model.Annotations.Add(annotation); }
public void DrawBar( string title, IEnumerable x, IEnumerable y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, bool showOnLegend) { ColumnXYSeries series = new ColumnXYSeries(); if (showOnLegend) { series.Title = title; } series.FillColor = ConverterExtensions.ToOxyColor(colour); series.StrokeColor = ConverterExtensions.ToOxyColor(colour); series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType); series.XAxisKey = xAxisType.ToString(); series.YAxisKey = yAxisType.ToString(); this.plot1.Model.Series.Add(series); }
/// <summary> /// Format the specified axis. /// </summary> /// <param name="axisType">The axis type to format</param> /// <param name="title">The axis title. If null then a default axis title will be shown</param> /// <param name="inverted">Invert the axis?</param> /// <param name="minimum">Minimum axis scale</param> /// <param name="maximum">Maximum axis scale</param> /// <param name="interval">Axis scale interval</param> public void FormatAxis( Models.Graph.Axis.AxisType axisType, string title, bool inverted, double minimum, double maximum, double interval) { OxyPlot.Axes.Axis oxyAxis = this.GetAxis(axisType); if (oxyAxis != null) { oxyAxis.Title = title; oxyAxis.MinorTickSize = 0; oxyAxis.AxislineStyle = LineStyle.Solid; oxyAxis.AxisTitleDistance = 10; if (inverted) { oxyAxis.StartPosition = 1; oxyAxis.EndPosition = 0; } else { oxyAxis.StartPosition = 0; oxyAxis.EndPosition = 1; } if (!double.IsNaN(minimum)) { oxyAxis.Minimum = minimum; } if (!double.IsNaN(maximum)) { oxyAxis.Maximum = maximum; } if (!double.IsNaN(interval) && interval > 0) { oxyAxis.MajorStep = interval; } } }
public void DrawBar( string title, IEnumerable x, IEnumerable y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, bool showOnLegend) { if (x != null && y != null) { ColumnXYSeries series = new ColumnXYSeries(); if (showOnLegend) { series.Title = title; } series.FillColor = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B); series.StrokeColor = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B); series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType); series.XAxisKey = xAxisType.ToString(); series.YAxisKey = yAxisType.ToString(); this.plot1.Model.Series.Add(series); } }
/// <summary> /// Return an axis that has the specified AxisType. Returns null if not found. /// </summary> /// <param name="axisType">The axis type to retrieve </param> /// <returns>The axis</returns> private OxyPlot.Axes.Axis GetAxis(Models.Graph.Axis.AxisType axisType) { return(null); }
public void DrawLineAndMarkers( string title, IEnumerable x, IEnumerable y, Models.Graph.Axis.AxisType xAxisType, Models.Graph.Axis.AxisType yAxisType, Color colour, Models.Graph.LineType lineType, Models.Graph.MarkerType markerType, Models.Graph.LineThicknessType lineThickness, Models.Graph.MarkerSizeType markerSize, bool showOnLegend) { if (x != null && y != null) { Utility.LineSeriesWithTracker series = new Utility.LineSeriesWithTracker(); series.OnHoverOverPoint += OnHoverOverPoint; if (showOnLegend) { series.Title = title; } else { series.ToolTip = title; } series.Color = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B); series.ItemsSource = this.PopulateDataPointSeries(x, y, xAxisType, yAxisType); series.XAxisKey = xAxisType.ToString(); series.YAxisKey = yAxisType.ToString(); series.CanTrackerInterpolatePoints = false; bool filled = false; string oxyMarkerName = markerType.ToString(); if (oxyMarkerName.StartsWith("Filled")) { oxyMarkerName = oxyMarkerName.Remove(0, 6); filled = true; } // Line type. LineStyle oxyLineType; if (Enum.TryParse <LineStyle>(lineType.ToString(), out oxyLineType)) { series.LineStyle = oxyLineType; if (series.LineStyle == LineStyle.None) { series.Color = OxyColors.Transparent; } } // Line thickness if (lineThickness == LineThicknessType.Thin) { series.StrokeThickness = 0.5; } // Marker type. OxyPlot.MarkerType type; if (Enum.TryParse <OxyPlot.MarkerType>(oxyMarkerName, out type)) { series.MarkerType = type; } if (markerSize == MarkerSizeType.Normal) { series.MarkerSize = 7.0; } else { series.MarkerSize = 5.0; } series.MarkerStroke = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B); if (filled) { series.MarkerFill = OxyColor.FromArgb(colour.A, colour.R, colour.G, colour.B); series.MarkerStroke = OxyColors.White; } this.plot1.Model.Series.Add(series); } }