Exemplo n.º 1
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.LineSeries)series;

            s.Color                 = this.Color.ToOxyColor();
            s.StrokeThickness       = this.StrokeThickness;
            s.LineStyle             = this.LineStyle;
            s.MarkerResolution      = this.MarkerResolution;
            s.MarkerSize            = this.MarkerSize;
            s.MarkerStroke          = this.MarkerStroke.ToOxyColor();
            s.MarkerType            = this.MarkerType;
            s.MarkerStrokeThickness = this.MarkerStrokeThickness;
            s.Dashes                = this.Dashes;
            s.LineJoin              = this.LineJoin;
            s.MarkerFill            = this.MarkerFill.ToOxyColor();
            s.MarkerOutline         = this.MarkerOutline.ToScreenPointArray();
            s.MinimumSegmentLength  = this.MinimumSegmentLength;
            s.LabelFormatString     = this.LabelFormatString;
            s.LabelMargin           = this.LabelMargin;
            s.LineLegendPosition    = this.LineLegendPosition;
            s.BrokenLineColor       = this.BrokenLineColor.ToOxyColor();
            s.BrokenLineStyle       = this.BrokenLineStyle;
            s.BrokenLineThickness   = this.BrokenLineThickness;
            s.Decimator             = this.Decimator;
        }
Exemplo n.º 2
0
        public void TestOneDateSeries()
        {
            int n = 10;
            IEnumerable <DateTime> x = Enumerable.Range(2, n).Select(i => new DateTime(1900, i, 1));

            double[] y = Enumerable.Range(100, n).Select(i => Convert.ToDouble(i)).ToArray();

            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, false, x.Cast <object>(), y.Cast <object>(), line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(n, series.ItemsSource.Count());
            double[] expectedX = new double[] { 33, 61, 92, 122, 153, 183, 214, 245, 275, 306 };
            int      i         = 0;

            foreach (DataPoint point in series.ItemsSource)
            {
                Assert.AreEqual(expectedX[i], point.X);
                Assert.AreEqual(y[i], point.Y);
                i++;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.BarSeries)series;

            s.BarWidth = this.BarWidth;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.ColumnSeries)series;

            s.ColumnWidth = ColumnWidth;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets a series from the specified point.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="limit">The limit.</param>
        /// <returns>The nearest series.</returns>
        public Series.Series GetSeriesFromPoint(ScreenPoint point, double limit = 100)
        {
            double mindist = double.MaxValue;

            Series.Series nearestSeries = null;
            foreach (var series in this.Series.Reverse().Where(s => s.IsVisible))
            {
                var thr = series.GetNearestPoint(point, true) ?? series.GetNearestPoint(point, false);

                if (thr == null)
                {
                    continue;
                }

                // find distance to this point on the screen
                double dist = point.DistanceTo(thr.Position);
                if (dist < mindist)
                {
                    nearestSeries = series;
                    mindist       = dist;
                }
            }

            if (mindist < limit)
            {
                return(nearestSeries);
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.LineSeries)series;

            s.Color                  = Color.ToOxyColor();
            s.StrokeThickness        = StrokeThickness;
            s.LineStyle              = LineStyle;
            s.MarkerResolution       = MarkerResolution;
            s.MarkerSize             = MarkerSize;
            s.MarkerStroke           = MarkerStroke.ToOxyColor();
            s.MarkerType             = MarkerType;
            s.MarkerStrokeThickness  = MarkerStrokeThickness;
            s.Dashes                 = Dashes;
            s.LineJoin               = LineJoin;
            s.MarkerFill             = MarkerFill.ToOxyColor();
            s.MarkerOutline          = (MarkerOutline ?? Enumerable.Empty <Point>()).Select(point => point.ToScreenPoint()).ToArray();
            s.MinimumSegmentLength   = MinimumSegmentLength;
            s.LabelFormatString      = LabelFormatString;
            s.LabelMargin            = LabelMargin;
            s.LineLegendPosition     = LineLegendPosition;
            s.BrokenLineColor        = BrokenLineColor.ToOxyColor();
            s.BrokenLineStyle        = BrokenLineStyle;
            s.BrokenLineThickness    = BrokenLineThickness;
            s.Decimator              = Decimator;
            s.InterpolationAlgorithm = this.InterpolationAlgorithm;
        }
Exemplo n.º 7
0
        public void TestSimpleCase()
        {
            IEnumerable <object> x = new object[] { 0d, 1d, 2d, 4d };
            IEnumerable <object> y = new object[] { 1d, 2d, 4d, 8d };
            Line   line            = new Line(LineType.Solid, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.Square, MarkerSize.Normal, 1);

            string     title  = "asdf";
            LineSeries input  = new LineSeries(title, Color.Blue, true, x, y, line, marker, "", "");
            Series     output = exporter.Export(input, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(title, series.Title);
            Assert.AreEqual(4, series.ItemsSource.Count());

            // Marker style
            Assert.AreEqual(OxyPlot.MarkerType.Square, series.MarkerType);
            Assert.AreEqual(7, series.MarkerSize);

            // Line style
            Assert.AreEqual(OxyPlot.LineStyle.Solid, series.LineStyle);
            Assert.AreEqual(0.25, series.StrokeThickness);

            // Colours
            Assert.AreEqual(OxyColors.Blue, series.Color);
        }
Exemplo n.º 8
0
        public void TestTwoDateSeries()
        {
            int n = 10;
            IEnumerable <DateTime> x = Enumerable.Range(1, n).Select(i => new DateTime(2000, 1, i));
            IEnumerable <DateTime> y = Enumerable.Range(2000, n).Select(i => new DateTime(i, 1, 1));

            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, false, x.Cast <object>(), y.Cast <object>(), line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(n, series.ItemsSource.Count());
            double[] expectedX = new double[] { 36526, 36527, 36528, 36529, 36530, 36531, 36532, 36533, 36534, 36535 };
            double[] expectedY = new double[] { 36526, 36892, 37257, 37622, 37987, 38353, 38718, 39083, 39448, 39814 };
            int      i         = 0;

            foreach (DataPoint point in series.ItemsSource)
            {
                Assert.AreEqual(expectedX[i], point.X);
                Assert.AreEqual(expectedY[i], point.Y);
                i++;
            }
        }
Exemplo n.º 9
0
 public TrackerHitResult(Series.Series series, DataPoint dp, ScreenPoint sp, object item = null, double index = -1, string text = null)
 {
     this.DataPoint = dp;
     this.Position  = sp;
     this.Item      = item;
     this.Index     = index;
     this.Series    = series;
     this.Text      = text;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.RectangleSeries)series;

            s.ItemsSource = this.ItemsSource;
            s.CanTrackerInterpolatePoints = this.CanTrackerInterpolatePoints;
            s.Mapping      = this.Mapping;
            s.ColorAxisKey = this.ColorAxisKey;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.ScatterErrorSeries)series;

            s.DataFieldErrorX         = DataFieldErrorX;
            s.DataFieldErrorY         = DataFieldErrorY;
            s.ErrorBarColor           = ErrorBarColor.ToOxyColor();
            s.ErrorBarStopWidth       = ErrorBarStopWidth;
            s.ErrorBarStrokeThickness = ErrorBarStrokeThickness;
            s.MinimumErrorSize        = MinimumErrorSize;
        }
Exemplo n.º 12
0
        public void TestNoData()
        {
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line   line            = new Line(LineType.Solid, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.Square, MarkerSize.Normal, 1);

            LineSeries input  = new LineSeries("", Color.Blue, true, x, y, line, marker, "", "");
            Series     output = exporter.Export(input, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(0, series.ItemsSource.Count());
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TrackerHitResult"/> class.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <param name="dp">The data point.</param>
        /// <param name="sp">The screen point.</param>
        /// <param name="item">The item.</param>
        /// <param name="index">The index.</param>
        /// <param name="text">The text.</param>
        public TrackerHitResult(OxyPlot.Series.Series series, IDataPoint dp, ScreenPoint sp, object item = null, double index = -1, string text = null)
        {
            this.DataPoint = dp;
            this.Position  = sp;
            this.Item      = item;
            this.Index     = index;
            this.Series    = series;
            this.Text      = text;
            var ds = series as DataPointSeries;

            if (ds != null)
            {
                this.XAxis = ds.XAxis;
                this.YAxis = ds.YAxis;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Create a series with the given marker size, conver it to an oxyplot
        /// series, and return the generated series' marker size.
        /// </summary>
        /// <param name="markerSize">Desired marker size.</param>
        private double GetExportedMarkerSize(MarkerSize markerSize)
        {
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.Solid, LineThickness.Normal);
            Marker     marker      = new Marker(MarkerType.FilledCircle, markerSize, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            return(series.MarkerSize);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Create a series with the given title and 'show on legend' value.
        /// Then convert to an oxyplot series and ensure that the generated
        /// series' title matches the specified expected value.
        /// </summary>
        /// <param name="title">Input title.</param>
        /// <param name="showOnLegend">Input value for 'show on legend'.</param>
        /// <param name="expectedTitle">Expected title of the oxyplot series.</param>
        private void TestShowOnLegend(string title, bool showOnLegend, string expectedTitle)
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries(title, Color.Black, false, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.Null(series.Title);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Create a series with the given System.Drawing.Color and marker type,
        /// then convert to an oxyplot series and ensure that the generated series'
        /// marker colour matches the given colour.
        /// </summary>
        /// <param name="inputColour">Colour to use when creating the series.</param>
        /// <param name="markerType">Marker type for the created series.</param>
        /// <param name="expectedOutput">Expected colour of the output series.</param>
        private void TestMarkerColour(Color inputColour, MarkerType markerType, OxyColor expectedOutput)
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(markerType, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", inputColour, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(expectedOutput, series.MarkerFill);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.BarSeriesBase)series;

            s.BaseValue         = this.BaseValue;
            s.ColorField        = this.ColorField;
            s.FillColor         = this.FillColor.ToOxyColor();
            s.IsStacked         = this.IsStacked;
            s.NegativeFillColor = this.NegativeFillColor.ToOxyColor();
            s.StrokeColor       = this.StrokeColor.ToOxyColor();
            s.StrokeThickness   = this.StrokeThickness;
            s.StackGroup        = this.StackGroup;
            s.ValueField        = this.ValueField;
            s.LabelFormatString = this.LabelFormatString;
            s.LabelMargin       = this.LabelMargin;
            s.LabelPlacement    = this.LabelPlacement;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Create an apsim series with the given input line type, then
        /// convert the apsim series to an oxyplot series and ensure that
        /// the output series' line type matches the expected output.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="expectedOutput"></param>
        private void TestLineType(LineType input, LineStyle expectedOutput)
        {
            // Create an apsim series with the given line type.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(input, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.None, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            // Ensure that the line type matches the expected line type.
            Assert.AreEqual(expectedOutput, series.LineStyle);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        /// <param name="series">The series.</param>
        protected override void SynchronizeProperties(OxyPlot.Series.Series series)
        {
            base.SynchronizeProperties(series);
            var s = (OxyPlot.Series.ScatterSeries <T>)series;

            s.MarkerFill            = this.MarkerFill.ToOxyColor();
            s.MarkerStroke          = this.MarkerStroke.ToOxyColor();
            s.MarkerStrokeThickness = this.MarkerStrokeThickness;
            s.MarkerType            = this.MarkerType;
            s.MarkerSize            = this.MarkerSize;
            s.DataFieldX            = this.DataFieldX;
            s.DataFieldY            = this.DataFieldY;
            s.DataFieldSize         = this.DataFieldSize;
            s.DataFieldValue        = this.DataFieldValue;
            s.DataFieldTag          = this.DataFieldTag;
            s.ItemsSource           = this.ItemsSource;
            s.BinSize       = this.BinSize;
            s.Mapping       = this.Mapping;
            s.MarkerOutline = this.MarkerOutline;
            s.ColorAxisKey  = this.ColorAxisKey;
        }
        /// <summary>
        /// Gets a series from the specified point.
        /// </summary>
        /// <param name="point">
        /// The point.
        /// </param>
        /// <param name="limit">
        /// The limit.
        /// </param>
        /// <returns>
        /// The nearest series.
        /// </returns>
        public Series.Series GetSeriesFromPoint(ScreenPoint point, double limit)
        {
            double mindist = double.MaxValue;

            Series.Series closest = null;
            foreach (var s in this.VisibleSeries.Reverse())
            {
                var ts = s as ITrackableSeries;
                if (ts == null)
                {
                    continue;
                }

                var thr = ts.GetNearestPoint(point, true) ?? ts.GetNearestPoint(point, false);

                if (thr == null)
                {
                    continue;
                }

                // find distance to this point on the screen
                double dist = point.DistanceTo(thr.Position);
                if (dist < mindist)
                {
                    closest = s;
                    mindist = dist;
                }
            }

            if (mindist < limit)
            {
                return(closest);
            }

            return(null);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Renders the legend for the specified series.
        /// </summary>
        /// <param name="rc">
        /// The render context.
        /// </param>
        /// <param name="s">
        /// The series.
        /// </param>
        /// <param name="rect">
        /// The position and size of the legend.
        /// </param>
        private void RenderLegend(IRenderContext rc, Series.Series s, OxyRect rect)
        {
            double x = rect.Left;

            switch (this.LegendItemAlignment)
            {
            case HorizontalAlignment.Center:
                x = (rect.Left + rect.Right) / 2;
                if (this.LegendSymbolPlacement == LegendSymbolPlacement.Left)
                {
                    x -= (this.LegendSymbolLength + this.LegendSymbolMargin) / 2;
                }
                else
                {
                    x -= (this.LegendSymbolLength + this.LegendSymbolMargin) / 2;
                }

                break;

            case HorizontalAlignment.Right:
                x = rect.Right;

                // if (LegendSymbolPlacement == LegendSymbolPlacement.Right)
                x -= this.LegendSymbolLength + this.LegendSymbolMargin;
                break;
            }

            if (this.LegendSymbolPlacement == LegendSymbolPlacement.Left)
            {
                x += this.LegendSymbolLength + this.LegendSymbolMargin;
            }

            double y       = rect.Top;
            var    maxsize = new OxySize(Math.Max(rect.Right - x, 0), Math.Max(rect.Bottom - y, 0));

            var textSize = rc.DrawMathText(
                new ScreenPoint(x, y),
                s.Title,
                this.LegendTextColor ?? this.TextColor,
                this.LegendFont ?? this.DefaultFont,
                this.LegendFontSize,
                this.LegendFontWeight,
                0,
                this.LegendItemAlignment,
                VerticalAlignment.Top,
                maxsize,
                true);
            double x0 = x;

            switch (this.LegendItemAlignment)
            {
            case HorizontalAlignment.Center:
                x0 = x - (textSize.Width * 0.5);
                break;

            case HorizontalAlignment.Right:
                x0 = x - textSize.Width;
                break;
            }

            var symbolRect =
                new OxyRect(
                    this.LegendSymbolPlacement == LegendSymbolPlacement.Right
                        ? x0 + textSize.Width + this.LegendSymbolMargin
                        : x0 - this.LegendSymbolMargin - this.LegendSymbolLength,
                    rect.Top,
                    this.LegendSymbolLength,
                    textSize.Height);

            s.RenderLegend(rc, symbolRect);
        }
Exemplo n.º 22
0
 public OxyListSeries(ListSeries listSeries, OxyPlot.Series.Series oxySeries)
 {
     ListSeries = listSeries;
     OxySeries  = oxySeries;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Renders the legend for the specified series.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="s">The series.</param>
        /// <param name="rect">The position and size of the legend.</param>
        private void RenderLegend(IRenderContext rc, Series.Series s, OxyRect rect)
        {
            var actualItemAlignment = this.LegendItemAlignment;

            if (this.LegendOrientation == LegendOrientation.Horizontal)
            {
                // center/right alignment is not supported for horizontal orientation
                actualItemAlignment = HorizontalAlignment.Left;
            }

            double x = rect.Left;

            switch (actualItemAlignment)
            {
            case HorizontalAlignment.Center:
                x = (rect.Left + rect.Right) / 2;
                if (this.LegendSymbolPlacement == LegendSymbolPlacement.Left)
                {
                    x -= (this.LegendSymbolLength + this.LegendSymbolMargin) / 2;
                }
                else
                {
                    x -= (this.LegendSymbolLength + this.LegendSymbolMargin) / 2;
                }

                break;

            case HorizontalAlignment.Right:
                x = rect.Right;

                // if (LegendSymbolPlacement == LegendSymbolPlacement.Right)
                x -= this.LegendSymbolLength + this.LegendSymbolMargin;
                break;
            }

            if (this.LegendSymbolPlacement == LegendSymbolPlacement.Left)
            {
                x += this.LegendSymbolLength + this.LegendSymbolMargin;
            }

            double y       = rect.Top;
            var    maxsize = new OxySize(Math.Max(rect.Width - this.LegendSymbolLength - this.LegendSymbolMargin, 0), rect.Height);

            rc.SetToolTip(s.ToolTip);
            var textSize = rc.DrawMathText(
                new ScreenPoint(x, y),
                s.Title,
                this.LegendTextColor.GetActualColor(this.TextColor),
                this.LegendFont ?? this.DefaultFont,
                this.LegendFontSize,
                this.LegendFontWeight,
                0,
                actualItemAlignment,
                VerticalAlignment.Top,
                maxsize,
                true);
            double x0 = x;

            switch (actualItemAlignment)
            {
            case HorizontalAlignment.Center:
                x0 = x - (textSize.Width * 0.5);
                break;

            case HorizontalAlignment.Right:
                x0 = x - textSize.Width;
                break;
            }

            var symbolRect =
                new OxyRect(
                    this.LegendSymbolPlacement == LegendSymbolPlacement.Right
                        ? x0 + textSize.Width + this.LegendSymbolMargin
                        : x0 - this.LegendSymbolMargin - this.LegendSymbolLength,
                    rect.Top,
                    this.LegendSymbolLength,
                    textSize.Height);

            s.RenderLegend(rc, symbolRect);
            rc.SetToolTip(null);
        }
Exemplo n.º 24
0
 public void Add(String name, Series value)
 {
     series.Add(name, value);
 }
Exemplo n.º 25
0
        /// <summary>
        /// Updates the axis with information from the plot series.
        /// </summary>
        /// <param name="series">The series collection.</param>
        /// <remarks>This is used by the category axis that need to know the number of series using the axis.</remarks>
        internal override void UpdateFromSeries(Series[] series)
        {
            base.UpdateFromSeries(series);

            this.UpdateLabels(series);

            var actualLabels = this.ActualLabels;
            if (actualLabels.Count == 0)
            {
                this.TotalWidthPerCategory = null;
                this.maxWidth = double.NaN;
                this.BarOffset = null;
                this.StackedBarOffset = null;
                this.StackIndexMapping = null;

                return;
            }

            this.TotalWidthPerCategory = new double[actualLabels.Count];

            var usedSeries = series.Where(s => s.IsUsing(this)).ToList();

            // Add width of stacked series
            var categorizedSeries = usedSeries.OfType<CategorizedSeries>().ToList();
            var stackedSeries = categorizedSeries.OfType<IStackableSeries>().Where(s => s.IsStacked).ToList();
            var stackIndices = stackedSeries.Select(s => s.StackGroup).Distinct().ToList();
            var stackRankBarWidth = new Dictionary<int, double>();
            for (var j = 0; j < stackIndices.Count; j++)
            {
                var maxBarWidth =
                    stackedSeries.Where(s => s.StackGroup == stackIndices[j]).Select(
                        s => ((CategorizedSeries)s).GetBarWidth()).Concat(new[] { 0.0 }).Max();
                for (var i = 0; i < actualLabels.Count; i++)
                {
                    int k = 0;
                    if (
                        stackedSeries.SelectMany(s => ((CategorizedSeries)s).GetItems()).Any(
                            item => item.GetCategoryIndex(k++) == i))
                    {
                        this.TotalWidthPerCategory[i] += maxBarWidth;
                    }
                }

                stackRankBarWidth[j] = maxBarWidth;
            }

            // Add width of unstacked series
            var unstackedBarSeries = categorizedSeries.Where(s => !(s is IStackableSeries) || !((IStackableSeries)s).IsStacked).ToList();
            foreach (var s in unstackedBarSeries)
            {
                for (var i = 0; i < actualLabels.Count; i++)
                {
                    int j = 0;
                    var numberOfItems = s.GetItems().Count(item => item.GetCategoryIndex(j++) == i);
                    this.TotalWidthPerCategory[i] += s.GetBarWidth() * numberOfItems;
                }
            }

            this.maxWidth = this.TotalWidthPerCategory.Max();

            // Calculate BarOffset and StackedBarOffset
            this.BarOffset = new double[actualLabels.Count];
            this.StackedBarOffset = new double[stackIndices.Count + 1, actualLabels.Count];

            var factor = 0.5 / (1 + this.GapWidth) / this.maxWidth;
            for (var i = 0; i < actualLabels.Count; i++)
            {
                this.BarOffset[i] = 0.5 - (this.TotalWidthPerCategory[i] * factor);
            }

            for (var j = 0; j <= stackIndices.Count; j++)
            {
                for (var i = 0; i < actualLabels.Count; i++)
                {
                    int k = 0;
                    if (
                        stackedSeries.SelectMany(s => ((CategorizedSeries)s).GetItems()).All(
                            item => item.GetCategoryIndex(k++) != i))
                    {
                        continue;
                    }

                    this.StackedBarOffset[j, i] = this.BarOffset[i];
                    if (j < stackIndices.Count)
                    {
                        this.BarOffset[i] += stackRankBarWidth[j] / (1 + this.GapWidth) / this.maxWidth;
                    }
                }
            }

            stackIndices.Sort();
            this.StackIndexMapping = new Dictionary<string, int>();
            for (var i = 0; i < stackIndices.Count; i++)
            {
                this.StackIndexMapping.Add(stackIndices[i], i);
            }

            this.maxStackIndex = stackIndices.Count;
        }
Exemplo n.º 26
0
 /// <summary>
 /// Updates the axis with information from the plot series.
 /// </summary>
 /// <param name="series">The series collection.</param>
 /// <remarks>This is used by the category axis that need to know the number of series using the axis.</remarks>
 internal virtual void UpdateFromSeries(Series[] series)
 {
 }