Exemplo n.º 1
0
        public void SeriesCollectionInstanceChanged()
        {
            var series = new LineSeries <int> {
                Values = new List <int> {
                    1, 6, 4, 2
                }
            };

            var seriesCollection = new List <ISeries> {
                series
            };

            var chart = new TestCartesianChartView
            {
                Series = seriesCollection,
                XAxes  = new[] { new Axis() },
                YAxes  = new[] { new Axis() },
            };

            var canvas = chart.CoreCanvas;

            void DrawChart()
            {
                while (!canvas.IsValid)
                {
                    canvas.DrawFrame(
                        new SkiaSharpDrawingContext(
                            canvas,
                            new SKImageInfo(100, 100),
                            SKSurface.CreateNull(100, 100),
                            new SKCanvas(new SKBitmap())));
                }
            }

            chart.Core.Update(new ChartUpdateParams {
                Throttling = false
            });
            DrawChart();

            var drawables  = canvas.DrawablesCount;
            var geometries = canvas.CountGeometries();

            chart.Series = new List <ISeries>
            {
                new LineSeries <int> {
                    Values = new List <int> {
                        1, 6, 4, 2
                    }
                }
            };

            chart.Core.Update(new ChartUpdateParams {
                Throttling = false
            });
            DrawChart();

            Assert.IsTrue(
                drawables == canvas.DrawablesCount &&
                geometries == canvas.CountGeometries());
        }
Exemplo n.º 2
0
        public void DrawableSeriesFillChanged()
        {
            var series = new LineSeries <int>
            {
                Values = new List <int> {
                    1, 6, 4, 2
                }
            };

            var chart = new TestCartesianChartView
            {
                Series = new List <ISeries> {
                    series
                },
                XAxes = new[] { new Axis() },
                YAxes = new[] { new Axis() },
            };

            var canvas = chart.CoreCanvas;

            void DrawChart()
            {
                while (!canvas.IsValid)
                {
                    canvas.DrawFrame(
                        new SkiaSharpDrawingContext(
                            canvas,
                            new SKImageInfo(100, 100),
                            SKSurface.CreateNull(100, 100),
                            new SKCanvas(new SKBitmap())));
                }
            }

            chart.Core.Update(new ChartUpdateParams {
                Throttling = false
            });
            DrawChart();

            var drawables  = canvas.DrawablesCount;
            var geometries = canvas.CountGeometries();

            // on changing the fill task, the previous instance should be removed.
            series.Fill = new SolidColorPaint();

            chart.Core.Update(new ChartUpdateParams {
                Throttling = false
            });
            DrawChart();

            Assert.IsTrue(
                drawables == canvas.DrawablesCount &&
                geometries == canvas.CountGeometries());
        }
Exemplo n.º 3
0
        public void AxisSeparatorBrushChanged()
        {
            var axis = new Axis();

            var chart = new TestCartesianChartView
            {
                Series = new List <ISeries>
                {
                    new LineSeries <int> {
                        Values = new List <int> {
                            1, 6, 4, 2
                        }
                    },
                },
                XAxes = new[] { new Axis() },
                YAxes = new[] { axis },
            };

            var canvas = chart.CoreCanvas;

            void DrawChart()
            {
                while (!canvas.IsValid)
                {
                    canvas.DrawFrame(
                        new SkiaSharpDrawingContext(
                            canvas,
                            new SKImageInfo(100, 100),
                            SKSurface.CreateNull(100, 100),
                            new SKCanvas(new SKBitmap())));
                }
            }

            chart.Core.Update(new ChartUpdateParams {
                Throttling = false
            });
            DrawChart();

            var drawables  = canvas.DrawablesCount;
            var geometries = canvas.CountGeometries();

            axis.SeparatorsBrush = new SolidColorPaintTask();

            chart.Core.Update(new ChartUpdateParams {
                Throttling = false
            });
            DrawChart();

            Assert.IsTrue(
                drawables == canvas.DrawablesCount &&
                geometries == canvas.CountGeometries());
        }
Exemplo n.º 4
0
        public void LineSeriesGeometryPaintsChanged()
        {
            var series = new LineSeries <int>
            {
                Values = new List <int> {
                    1, 6, 4, 2
                }
            };

            var chart = new TestCartesianChartView
            {
                Series = new List <ISeries> {
                    series
                },
                XAxes = new[] { new Axis() },
                YAxes = new[] { new Axis() },
            };

            var canvas = chart.CoreCanvas;

            void DrawChart()
            {
                while (!canvas.IsValid)
                {
                    canvas.DrawFrame(
                        new SkiaSharpDrawingContext(
                            new SKImageInfo(100, 100),
                            SKSurface.CreateNull(100, 100),
                            new SKCanvas(new SKBitmap())));
                }
            }

            chart.Core.Update(false);
            DrawChart();

            var drawables  = canvas.DrawablesCount;
            var geometries = canvas.CountGeometries();

            series.GeometryFill   = new SolidColorPaintTask();
            series.GeometryStroke = new SolidColorPaintTask();

            chart.Core.Update(false);
            DrawChart();

            Assert.IsTrue(
                drawables == canvas.DrawablesCount &&
                geometries == canvas.CountGeometries());
        }