Пример #1
0
        public void Perform()
        {
            this.LineType = LineType;
            List <OxyPlot.DataPoint> list = this.Points;

            PointLineSeries.SortDataPoints(ref list);
        }
Пример #2
0
        public bool AjustAxis(double sourceMinimum, double SourceMaximum, out double minimum, out double maximum)
        {
            minimum = 0;
            maximum = 0;
            if (this.Points.Count == 0)
            {
                return(false);
            }
            if (this.YAxis == null)
            {
                this.YAxis = ((MapPlotModel)PlotModel).GetAxis(this.YKey);
            }
            Axis y_axis = this.YAxis;

            if (!(y_axis is IAxis))
            {
                return(false);
            }

            double cur_min = _minimum < sourceMinimum ? _minimum : sourceMinimum;
            double cur_max = _maximum > SourceMaximum ? _maximum : SourceMaximum;

            PointLineSeries.AjustYAxis(LabelVisible, TextOffset.Y, ActualFontSize, cur_min, cur_max, Scale, ((IAxis)y_axis).Bound, out maximum, out minimum);
            return(true);
        }
Пример #3
0
        public static ISeries CreateSeries(int seriesStyle)
        {
            ISeries series = null;

            switch (seriesStyle)
            {
            case 1: series = new PointLineSeries(); break;

            case 2: series = new PointColumnSeries(); break;

            case 3: series = new PointAreaSeries(); break;

            //case 4:
            //    FontFamily family = SeriesServiceLocator.Current.GetInstance<DataManager>().TryGetFontFamily(element.FontFamily);
            //    if (family != null)
            //        series = new FontLabelSeries(family, element.FontSize);
            //    break;
            case 5:
                series = new ValuePairPointLineSeries();
                break;

            //case 6:
            //    family = SeriesServiceLocator.Current.GetInstance<DataManager>().TryGetFontFamily(element.FontFamily);
            //    if (family != null)
            //        series = new FontLabelValuePairSeries(family, element.FontSize);
            //    break;
            case 7:
                series = new ISOLineSeries();
                break;
            }

            return(series);
        }
Пример #4
0
        internal static ISeries CreateOxyPlotSeries(SeriesMode style, string id)
        {
            ISeries se = null;

            switch (style)
            {
            case SeriesMode.Line:
                se    = new PointLineSeries();
                se.Id = id;
                break;

            case SeriesMode.Column:
                break;

            case SeriesMode.Symbol:
                break;
            }

            return(se);
        }
Пример #5
0
        public override bool AjustAxis(double sourceMinimum, double SourceMaximum, out double minimum, out double maximum)
        {
            minimum = 0;
            maximum = 0;
            if (Count == 0)
                return false;

            IAxis y_axis = this.YAxis as IAxis;
            if (y_axis == null)
            {
                y_axis = ((MapPlotModel)PlotModel).GetAxis(this.YKey) as IAxis;
            }

            if (!(y_axis is IAxis))
                return false;

            double cur_min = _minimum < sourceMinimum ? _minimum : sourceMinimum;
            double cur_max = _maximum > SourceMaximum ? _maximum : SourceMaximum;
            PointLineSeries.AjustYAxis(false, TextOffset.Y, this.ActualFontSize, cur_min, cur_max, 0.15, y_axis.Bound, out maximum, out minimum, 15);
            return true;
        }
        public override bool AjustAxis(double sourceMinimum, double SourceMaximum, out double minimum, out double maximum)
        {
            minimum = 0;
            maximum = 0;
            if (Count == 0)
            {
                return(false);
            }

            IAxis y_axis = this.YAxis as IAxis;

            if (y_axis == null)
            {
                y_axis = ((MapPlotModel)PlotModel).GetAxis(this.YKey) as IAxis;
            }

            if (!(y_axis is IAxis))
            {
                return(false);
            }

            double cur_min = _minimum < sourceMinimum ? _minimum : sourceMinimum;
            double cur_max = _maximum > SourceMaximum ? _maximum : SourceMaximum;

            PointLineSeries.AjustYAxis(false, TextOffset.Y, this.ActualFontSize, cur_min, cur_max, 0.15, y_axis.Bound, out maximum, out minimum, 15);
            //maximum = cur_max;
            //minimum = cur_min;
            //double scale = 0.15;
            //if (maximum == minimum)
            //{
            //    if (maximum == 0)
            //    {
            //        minimum = -10;
            //        maximum = 10;
            //    }
            //    minimum = minimum * (1 - scale);
            //    maximum = maximum * (1 + scale);
            //    return false;
            //}

            //double font_size = this.FontSize;
            //double rest_length =y_axis.Bound.Bottom-y_axis.Bound.Top-2*font_size ;
            //OxyRect bound = y_axis.Bound;
            //if (rest_length <= 0)
            //{
            //    rest_length = (bound.Bottom - bound.Top) >font_size  ? font_size : bound.Bottom - bound.Top;
            //}

            //double max2 = font_size / rest_length * (maximum - minimum) + maximum;
            //double min2 = minimum - (maximum - minimum) *font_size / rest_length;

            //if (max2 == min2)
            //{
            //    if (min2 == 0)
            //    {
            //        min2 = -10;
            //        max2 = 10;
            //    }
            //    min2 = min2 * (1 - scale);
            //    max2 = max2 * (1 + scale);
            //}

            //minimum = min2;
            //maximum = max2;
            return(true);
        }
Пример #7
0
        public override void Render(IRenderContext rc, PlotModel model1)
        {
            PlotModel model = this.PlotModel;

            this.YAxis = ((MapPlotModel)model).GetAxis(this.YKey);
            if (!SeriesVisible || !((IAxis)this.YAxis).AxisVisible)
            {
                return;
            }
            //AjustAxis();
            if (Points.Count == 0)
            {
                return;
            }

            OxyColor limit_color = OxyColors.Red;

            if (Theme != null)
            {
                LineSeriesStyle style = Theme.GetStyle(ThemeMode) as LineSeriesStyle;
                this.Color  = Helper.ConvertColorToOxyColor(style.LineColor);
                limit_color = Helper.ConvertColorToOxyColor(style.AlarmColor);
            }

            rc.ResetClip();
            OxyRect            clippingRect = model.PlotArea;
            List <ScreenPoint> sps          = new List <ScreenPoint>();

            for (int i = 0; i < Points.Count; i++)
            {
                double      x  = this.XAxis.Transform(Points[i].X);
                double      y  = this.YAxis.Transform(Points[i].Y);
                ScreenPoint sp = new ScreenPoint(x, y);
                sps.Add(sp);

                if (LabelVisible)
                {
                    string text = PointLineSeries.FormatValue(Points[i].Y);
                    PointLineSeries.RenderBoxText(rc, ThemeMode, clippingRect, text, TextPadding, sp, TextOffset, Color);
                }
            }

            if (ShowLimit)
            {
                if (LimitValue != Helper.InvalidData)
                {
                    double y     = this.YAxis.Transform(LimitValue);
                    double left  = model.PlotArea.Left;
                    double right = model.PlotArea.Right;

                    if (y >= this.YAxis.ScreenMin.Y && y <= this.YAxis.ScreenMax.Y)
                    {
                        rc.DrawLine(left, y, right, y, new OxyPen(limit_color, 1, LineStyle.Solid, LineJoin.Miter));
                        string limit_text = PointLineSeries.FormatValue(LimitValue);
                        rc.DrawText(new ScreenPoint(left + 10, y - 15), limit_text, limit_color, "Arial");
                    }
                }
            }

            if (Points.Count > 0)
            {
                double x = this.XAxis.Transform(Points[0].X);
                double y = this.YAxis.Transform(YAxis.Minimum) - 2;

                double x1 = this.XAxis.Transform(Points[Points.Count - 1].X);
                double y1 = y;

                ScreenPoint sp  = new ScreenPoint(x, y);
                ScreenPoint sp1 = new ScreenPoint(x1, y1);

                IList <ScreenPoint> poligon = new List <ScreenPoint>();
                poligon.Add(sp);
                foreach (ScreenPoint item in sps)
                {
                    poligon.Add(item);
                }
                poligon.Add(sp1);

                rc.DrawClippedPolygon(clippingRect, poligon, 2, OxyColor.FromAColor(150, Color), OxyColors.Transparent);
                RenderLine(rc, clippingRect, sps, Color, 2, this.LineStyle);
            }
        }
Пример #8
0
        public override void Render(IRenderContext rc, PlotModel model1)
        {
            PlotModel model = this.PlotModel;

            this.YAxis = ((MapPlotModel)model).GetAxis(this.YKey);
            if (!SeriesVisible || !((IAxis)this.YAxis).AxisVisible)
            {
                return;
            }
            //AjustAxis();
            if (_pts.Count == 0)
            {
                return;
            }
            OxyColor average_color = OxyColors.Green;
            OxyColor limit_color   = OxyColors.Red;

            if (Theme != null)
            {
                LineSeriesStyle style = Theme.GetStyle(ThemeMode) as LineSeriesStyle;
                this.FillColor = Helper.ConvertColorToOxyColor(style.LineColor);
                average_color  = Helper.ConvertColorToOxyColor(style.AverageColor);
                limit_color    = Helper.ConvertColorToOxyColor(style.AlarmColor);
            }

            rc.ResetClip();
            IAxis   y_axis       = this.YAxis as IAxis;
            OxyRect clippingRect = y_axis.Bound;

            double width = model.PlotArea.Width;

            List <FeatureText> features = new List <FeatureText>();
            //compute offset
            List <string> column_serieses = new List <string>();

            for (int i = 0; i < model1.Series.Count; i++)
            {
                if (model1.Series[i] is PointColumnSeries || (model1.Series[i] is PointLineSeries && ((PointLineSeries)model1.Series[i]).PointLineStyle == ePointLineStyle.Cloumn))
                {
                    column_serieses.Add(((ISeries)model.Series[i]).Id);
                }
            }

            int    column_padding = 3;
            double total_width    = this.XAxis.Transform(1) - this.XAxis.Transform(0);
            double column_width   = this.ColumnWidth;

            if ((this.ColumnWidth + column_padding) * column_serieses.Count > total_width)
            {
                //auto width;
                column_width = (total_width - column_serieses.Count * column_padding) / column_serieses.Count;
            }
            if (column_width < 1)
            {
                column_width = 1;
            }
            int    index = column_serieses.IndexOf(this.Id);
            double total_column_width = column_width * column_serieses.Count + (column_serieses.Count - 1) * column_padding;
            double offset             = 0;

            if (index >= 0)
            {
                offset = index * (column_width + column_padding) - total_column_width / 2 + column_width / 2;;
            }
            for (int i = 0; i < Count; i++)
            {
                double value = double.Parse(this[i].Value);
                double x     = this.XAxis.Transform(this[i].Index) + offset;
                if (value == 0)
                {
                    continue;
                }
                double      y            = this.YAxis.Transform(value);
                ScreenPoint center_point = new ScreenPoint(x, y);

                string text = PointLineSeries.FormatValue(value);
                if (double.Parse(text) == 0)
                {
                    continue;
                }
                features.Add(new FeatureText(text, center_point, new OxySize(10, 10), center_point));

                ScreenPoint left_top  = new ScreenPoint(center_point.X - ColumnWidth / 2, center_point.Y);
                ScreenPoint right_top = new ScreenPoint(center_point.X + ColumnWidth / 2, center_point.Y);

                double      y1           = this.YAxis.Transform(0);
                ScreenPoint right_bottom = new ScreenPoint(right_top.X, y1 - 2);
                ScreenPoint left_bottom  = new ScreenPoint(left_top.X, y1 - 2);

                IList <ScreenPoint> poligon = new List <ScreenPoint>();
                poligon.Add(left_top);
                poligon.Add(right_top);
                poligon.Add(right_bottom);
                poligon.Add(left_bottom);
                rc.DrawClippedPolygon(clippingRect, poligon, 2, FillColor, FillColor);
            }

            if (_is_average && ShowEverage)
            {
                double y     = this.YAxis.Transform(_average);
                double left  = model.PlotArea.Left;
                double right = model.PlotArea.Right;

                rc.DrawLine(left, y, right, y, new OxyPen(average_color, 1, LineStyle.Dash, LineJoin.Miter));
                string average_text = PointLineSeries.FormatValue(_average);
                rc.DrawText(new ScreenPoint(left + 10, y - 15), average_text, average_color, "Arial");
            }

            if (LimitValue != Helper.InvalidData && ShowLimit)
            {
                double y     = this.YAxis.Transform(LimitValue);
                double left  = model.PlotArea.Left;
                double right = model.PlotArea.Right;

                if (y >= this.YAxis.ScreenMin.Y && y <= this.YAxis.ScreenMax.Y)
                {
                    rc.DrawLine(left, y, right, y, new OxyPen(limit_color, 1, LineStyle.Solid, LineJoin.Miter));
                    string limit_text = PointLineSeries.FormatValue(LimitValue);
                    rc.DrawText(new ScreenPoint(left + 10, y - 15), limit_text, limit_color, "Arial");
                }
            }

            if (LabelVisible)
            {
                foreach (FeatureText feature in features)
                {
                    if (double.Parse(feature.Text) == 0)
                    {
                        continue;
                    }
                    PointLineSeries.RenderBoxText(rc, ThemeMode, clippingRect, feature.Text, TextPadding, feature.Position, TextOffset, FillColor, PointLineSeries.BoxPosition.Middle);
                }
            }
        }