public override void ConstructSeries(IDrawableSeries <SkiaSharpDrawingContext> series) { if ((series.SeriesProperties & SeriesProperties.PieSeries) == SeriesProperties.PieSeries) { var pieSeries = (IPieSeries <SkiaSharpDrawingContext>)series; pieSeries.Fill = LiveChartsSK.DefaultPaint; pieSeries.Stroke = null; pieSeries.PushOut = 6; pieSeries.TransitionsSetter = (IDoughnutVisualChartPoint <SkiaSharpDrawingContext> visual, Animation defaultAnimation) => { visual .DefinePropertyTransitions(nameof(visual.StartAngle), nameof(visual.SweepAngle)) .DefineAnimation(animation => { animation.Duration = defaultAnimation.Duration; animation.EasingFunction = EasingFunctions.BounceOut; }); }; return; } series.Fill = LiveChartsSK.DefaultPaint; series.Stroke = LiveChartsSK.DefaultPaint; }
/// <summary> /// Gets the stacked row postion. /// </summary> /// <param name="series">The series.</param> /// <returns></returns> public int GetStackedRowPostion(IDrawableSeries <TDrawingContext> series) { if (areBarsIndexed) { return(stackRowsPositions[series.GetStackGroup()]); } IndexBars(); return(stackRowsPositions[series.GetStackGroup()]); }
/// <summary> /// Gets the row postion. /// </summary> /// <param name="series">The series.</param> /// <returns></returns> public int GetRowPostion(IDrawableSeries <TDrawingContext> series) { if (areBarsIndexed) { return(rowPositions[series]); } IndexBars(); return(rowPositions[series]); }
internal void ConstructSeries(IDrawableSeries <TDrawingContext> series) { if (seriesInitializer == null) { throw new NullReferenceException( $"An instance of {nameof(SeriesInitializer<TDrawingContext>)} is no configured yet, " + $"please register an instance using {nameof(UseSeriesInitializer)}() method."); } seriesInitializer.ConstructSeries(series); }
private Stacker <TDrawingContext> GetStacker(IDrawableSeries <TDrawingContext> series, int stackGroup) { var key = $"{series.SeriesProperties}.{stackGroup}"; if (!stackers.TryGetValue(key, out var stacker)) { stacker = new Stacker <TDrawingContext>(); stackers.Add(key, stacker); } return(stacker); }
public int GetSeriesStackPosition(IDrawableSeries <TDrawingContext> series) { if (!stackPositions.TryGetValue(series, out var i)) { var n = new List <StackedValue>(knownMaxLenght); stack.Add(n); i = stackCount++; stackPositions[series] = i; } return(i); }
public override void ConstructSeries(IDrawableSeries <SkiaSharpDrawingContext> series) { if ((series.SeriesProperties & SeriesProperties.PieSeries) == SeriesProperties.PieSeries) { var pieSeries = (IPieSeries <SkiaSharpDrawingContext>)series; pieSeries.Fill = LiveChartsSK.DefaultPaint; pieSeries.Stroke = null; pieSeries.Pushout = 0; pieSeries.OnPointCreated = (IDoughnutVisualChartPoint <SkiaSharpDrawingContext> visual, IChartView <SkiaSharpDrawingContext> chart) => { visual .TransitionateProperties( nameof(visual.StartAngle), nameof(visual.SweepAngle), nameof(visual.PushOut)) .WithAnimation(animation => animation .WithDuration(chart.AnimationsSpeed) .WithEasingFunction(EasingFunctions.SinOut)); }; return; } if ((series.SeriesProperties & SeriesProperties.Line) == SeriesProperties.Line) { var lineSeries = (ILineSeries <SkiaSharpDrawingContext>)series; if ((series.SeriesProperties & SeriesProperties.Stacked) == SeriesProperties.Stacked) { lineSeries.GeometrySize = 0; lineSeries.ShapesFill = null; lineSeries.ShapesStroke = null; lineSeries.Stroke = null; series.Fill = LiveChartsSK.DefaultPaint; return; } lineSeries.GeometrySize = 18; lineSeries.ShapesFill = new SolidColorPaintTask(new SKColor(250, 250, 250)); lineSeries.ShapesStroke = LiveChartsSK.DefaultPaint; } series.Fill = LiveChartsSK.DefaultPaint; series.Stroke = LiveChartsSK.DefaultPaint; }
public void ConstructSeries <TDrawingContext>(IDrawableSeries <TDrawingContext> series) where TDrawingContext : DrawingContext { if (!seriesStyleBuilder.TryGetValue(typeof(TDrawingContext), out var stylesBuilder)) { #if DEBUG Trace.WriteLine(nameof(TDrawingContext) + " is not registered, the style was not applied."); #endif return; } var sb = (StyleBuilder <TDrawingContext>)stylesBuilder; sb.ConstructSeries(series); }
public override void ResolveSeriesDefaults(Color[] colors, IDrawableSeries <SkiaSharpDrawingContext> series) { var color = colors[series.SeriesId % colors.Length]; if (series.Name == null) { series.Name = $"Series {series.SeriesId + 1}"; } if ((series.SeriesProperties & SeriesProperties.PieSeries) == SeriesProperties.PieSeries) { if (series.Fill == LiveChartsSkiaSharp.DefaultPaint) { series.Fill = new SolidColorPaintTask(ColorAsSKColor(color)); } if (series.Stroke == LiveChartsSkiaSharp.DefaultPaint) { series.Stroke = new SolidColorPaintTask(ColorAsSKColor(color), 3); } return; } if (series.Fill == LiveChartsSkiaSharp.DefaultPaint) { var mask = SeriesProperties.Line | SeriesProperties.Stacked; var opacity = (series.SeriesProperties & mask) == mask ? 1 : 0.5; series.Fill = new SolidColorPaintTask(ColorAsSKColor(color, (byte)(opacity * 255))); } if (series.Stroke == LiveChartsSkiaSharp.DefaultPaint) { series.Stroke = new SolidColorPaintTask(ColorAsSKColor(color), 3.5f); } if ((series.SeriesProperties & SeriesProperties.Line) == SeriesProperties.Line) { var lineSeries = (ILineSeries <SkiaSharpDrawingContext>)series; if (lineSeries.GeometryFill == LiveChartsSkiaSharp.DefaultPaint) { lineSeries.GeometryFill = new SolidColorPaintTask(ColorAsSKColor(color)); } if (lineSeries.GeometryStroke == LiveChartsSkiaSharp.DefaultPaint) { lineSeries.GeometryStroke = new SolidColorPaintTask(ColorAsSKColor(color), lineSeries.Stroke?.StrokeThickness ?? 3.5f); } } }
/// <summary> /// Gets the stack position. /// </summary> /// <param name="series">The series.</param> /// <param name="stackGroup">The stack group.</param> /// <returns></returns> public StackPosition <TDrawingContext>?GetStackPosition(IDrawableSeries <TDrawingContext> series, int stackGroup) { if (!series.IsStackedSeries()) { return(null); } var s = GetStacker(series, stackGroup); return(s == null ? null : new StackPosition <TDrawingContext> { Stacker = s, Position = s.GetSeriesStackPosition(series) }); }
internal void ResolveDefaults(IDrawableSeries <TDrawingContext> series) { if (seriesInitializer == null) { throw new NullReferenceException( $"An instance of {nameof(SeriesInitializer<TDrawingContext>)} is no configured yet, " + $"please register an instance using {nameof(UseSeriesInitializer)}() method."); } if (colors == null || colors.Length == 0) { throw new NullReferenceException( $"A color pack is not registered yet or is not valid, please register a pack using the {nameof(UseColors)}() method."); } seriesInitializer.ResolveDefaults(colors[series.SeriesId % colors.Length], series); }
public override void ResolveDefaults(Color color, IDrawableSeries <SkiaSharpDrawingContext> series) { if (series.Name == null) { series.Name = $"Series {series.SeriesId + 1}"; } if ((series.SeriesProperties & SeriesProperties.PieSeries) == SeriesProperties.PieSeries) { if (series.Fill == LiveChartsSK.DefaultPaint) { series.Fill = new SolidColorPaintTask(ColorAsSKColor(color)); } if (series.Stroke == LiveChartsSK.DefaultPaint) { series.Stroke = new SolidColorPaintTask(ColorAsSKColor(color), 3); } return; } if ((series.SeriesProperties & SeriesProperties.Line) == SeriesProperties.Line) { var lineSeries = (ILineSeries <SkiaSharpDrawingContext>)series; if (lineSeries.ShapesFill == LiveChartsSK.DefaultPaint) { lineSeries.ShapesFill = new SolidColorPaintTask(ColorAsSKColor(color)); } if (lineSeries.ShapesStroke == LiveChartsSK.DefaultPaint) { lineSeries.ShapesStroke = null; } } if (series.Fill == LiveChartsSK.DefaultPaint) { series.Fill = new SolidColorPaintTask(ColorAsSKColor(color, (byte)(0.7 * 255))); } if (series.Stroke == LiveChartsSK.DefaultPaint) { series.Stroke = new SolidColorPaintTask(ColorAsSKColor(color), 3); } }
public override void ConstructSeries(IDrawableSeries <SkiaSharpDrawingContext> series) { if ((series.SeriesProperties & SeriesProperties.PieSeries) == SeriesProperties.PieSeries) { var pieSeries = (IPieSeries <SkiaSharpDrawingContext>)series; pieSeries.Fill = LiveChartsSkiaSharp.DefaultPaint; pieSeries.Stroke = null; pieSeries.Pushout = 0; return; } if ((series.SeriesProperties & SeriesProperties.Line) == SeriesProperties.Line) { var lineSeries = (ILineSeries <SkiaSharpDrawingContext>)series; if ((series.SeriesProperties & SeriesProperties.Stacked) == SeriesProperties.Stacked) { lineSeries.GeometrySize = 0; lineSeries.GeometryFill = null; lineSeries.GeometryStroke = null; lineSeries.Stroke = null; series.Fill = LiveChartsSkiaSharp.DefaultPaint; return; } lineSeries.GeometrySize = 18; lineSeries.GeometryFill = new SolidColorPaintTask(new SKColor(250, 250, 250)); lineSeries.GeometryStroke = LiveChartsSkiaSharp.DefaultPaint; } series.Fill = LiveChartsSkiaSharp.DefaultPaint; series.Stroke = LiveChartsSkiaSharp.DefaultPaint; }
/// <summary> /// Constructs a series. /// </summary> /// <param name="series">The series.</param> public virtual void ApplyStyleToSeries(IDrawableSeries <TDrawingContext> series) { foreach (var rule in SeriesBuilder) { rule(series); } if ((series.SeriesProperties & SeriesProperties.PieSeries) == SeriesProperties.PieSeries) { foreach (var rule in PieSeriesBuilder) { rule((IPieSeries <TDrawingContext>)series); } } if ((series.SeriesProperties & SeriesProperties.CartesianSeries) == SeriesProperties.CartesianSeries) { foreach (var rule in CartesianSeriesBuilder) { rule((ICartesianSeries <TDrawingContext>)series); } } if ((series.SeriesProperties & SeriesProperties.Bar) == SeriesProperties.Bar && (series.SeriesProperties & SeriesProperties.Stacked) != SeriesProperties.Stacked) { var barSeries = (IBarSeries <TDrawingContext>)series; foreach (var rule in BarSeriesBuilder) { rule(barSeries); } if ((series.SeriesProperties & SeriesProperties.VerticalOrientation) == SeriesProperties.VerticalOrientation) { foreach (var rule in ColumnSeriesBuilder) { rule(barSeries); } } if ((series.SeriesProperties & SeriesProperties.HorizontalOrientation) == SeriesProperties.HorizontalOrientation) { foreach (var rule in RowSeriesBuilder) { rule(barSeries); } } } var stackedBarMask = SeriesProperties.Bar | SeriesProperties.Stacked; if ((series.SeriesProperties & stackedBarMask) == stackedBarMask) { var stackedBarSeries = (IStackedBarSeries <TDrawingContext>)series; foreach (var rule in StackedBarSeriesBuilder) { rule(stackedBarSeries); } if ((series.SeriesProperties & SeriesProperties.VerticalOrientation) == SeriesProperties.VerticalOrientation) { foreach (var rule in StackedColumnSeriesBuilder) { rule(stackedBarSeries); } } if ((series.SeriesProperties & SeriesProperties.HorizontalOrientation) == SeriesProperties.HorizontalOrientation) { foreach (var rule in StackedRowSeriesBuilder) { rule(stackedBarSeries); } } } if ((series.SeriesProperties & SeriesProperties.Scatter) == SeriesProperties.Scatter) { foreach (var rule in ScatterSeriesBuilder) { rule((IScatterSeries <TDrawingContext>)series); } } if ((series.SeriesProperties & SeriesProperties.Line) == SeriesProperties.Line) { var lineSeries = (ILineSeries <TDrawingContext>)series; foreach (var rule in LineSeriesBuilder) { rule(lineSeries); } if ((series.SeriesProperties & SeriesProperties.Stacked) == SeriesProperties.Stacked) { foreach (var rule in StackedLineSeriesBuilder) { rule(lineSeries); } } } }
public abstract void ResolveSeriesDefaults(Color[] colors, IDrawableSeries <TDrawingContext> series);
public abstract void ConstructSeries(IDrawableSeries <TDrawingContext> series);
/// <summary> /// Resolves the series defaults. /// </summary> /// <param name="colors">The colors.</param> /// <param name="series">The series.</param> public virtual void ResolveSeriesDefaults(Color[] colors, IDrawableSeries <TDrawingContext> series) { SeriesDefaultsResolver?.Invoke(colors, series); }