Ejemplo n.º 1
0
 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)
 {
 }
Ejemplo n.º 2
0
 /// <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)
 {
 }
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
        /// <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);
            }
        }
Ejemplo n.º 5
0
        /// <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]);
            }
        }
Ejemplo n.º 6
0
        /// <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());
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
        /// <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);
            }
        }
Ejemplo n.º 9
0
        /// <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);
            }
        }
Ejemplo n.º 10
0
        /// <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);
            }
        }
Ejemplo n.º 11
0
        /// <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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 /// <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;
         }
     }
 }
Ejemplo n.º 15
0
 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);
     }
 }
Ejemplo n.º 16
0
 /// <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);
 }
Ejemplo n.º 17
0
        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);
            }
        }