From 84378fc7a915564faead887211f2b217b177987d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 20 Aug 2021 20:36:13 -0500 Subject: [PATCH] designer improvements --- src/LiveChartsCore/CartesianChart.cs | 11 +++--- src/LiveChartsCore/Chart.cs | 16 ++++---- src/LiveChartsCore/Kernel/DesignerKind.cs | 39 +++++++++++++++++++ .../Kernel/LiveChartsSettings.cs | 12 ++++++ src/LiveChartsCore/LiveChartsCore.csproj | 2 +- src/LiveChartsCore/PieChart.cs | 10 +++-- ...veChartsCore.SkiaSharpView.Avalonia.csproj | 2 +- .../LiveChartsCore.SkiaSharpView.WPF.csproj | 4 +- .../CartesianChart.cs | 26 ++++++------- .../Chart.cs | 2 +- ...veChartsCore.SkiaSharpView.WinForms.csproj | 2 +- .../PieChart.cs | 9 ++--- ...rtsCore.SkiaSharpView.Xamarin.Forms.csproj | 4 +- .../LiveChartsCore.SkiaSharpView.csproj | 4 +- .../LiveChartsSkiaSharp.cs | 19 ++++++++- .../LiveChartsCore.SkiaSharpView.WinUI.csproj | 4 +- .../CartesianChart.xaml.cs | 16 ++++---- .../LiveChartsCore.SkiaSharpView.UWP.csproj | 2 +- .../LiveChartsCore.SkiaSharpView.UWP.nuspec | 7 ++-- .../PieChart.xaml.cs | 18 ++++----- 20 files changed, 139 insertions(+), 70 deletions(-) create mode 100644 src/LiveChartsCore/Kernel/DesignerKind.cs diff --git a/src/LiveChartsCore/CartesianChart.cs b/src/LiveChartsCore/CartesianChart.cs index 41d179c49..0f889bc0b 100644 --- a/src/LiveChartsCore/CartesianChart.cs +++ b/src/LiveChartsCore/CartesianChart.cs @@ -29,7 +29,6 @@ using LiveChartsCore.Measure; using LiveChartsCore.Kernel.Sketches; using System.Threading; -using System.Threading.Tasks; #if DEBUG using System.Diagnostics; #endif @@ -52,6 +51,7 @@ public class CartesianChart : Chart private double _zoomingSpeed = 0; private ZoomAndPanMode _zoomMode; private DrawMarginFrame? _previousDrawMarginFrame; + private IEnumerable? _designerSeries = null; /// /// Initializes a new instance of the class. @@ -144,8 +144,6 @@ public CartesianChart( /// public override void Update(ChartUpdateParams? chartUpdateParams = null) { - if (View.DesignerMode) return; - chartUpdateParams ??= new ChartUpdateParams(); if (chartUpdateParams.IsAutomaticUpdate && !View.AutoUpdateEnabled) return; if (!chartUpdateParams.Throttling) @@ -420,8 +418,11 @@ protected override void Measure() animationsSpeed = _chartView.AnimationsSpeed; easingFunction = _chartView.EasingFunction; - Series = _chartView.Series - .Where(x => x.IsVisible) + var actualSeries = View.DesignerMode + ? _designerSeries ??= LiveCharts.CurrentSettings.DesignerSeriesGenerator(DesignerKind.Cartesian) + : _chartView.Series.Where(x => x.IsVisible); + + Series = actualSeries .Cast>() .ToArray(); diff --git a/src/LiveChartsCore/Chart.cs b/src/LiveChartsCore/Chart.cs index f0adefb63..e758fdbef 100644 --- a/src/LiveChartsCore/Chart.cs +++ b/src/LiveChartsCore/Chart.cs @@ -476,16 +476,18 @@ protected bool SeriesMiniatureChanged(IReadOnlyList protected virtual Task UpdateThrottlerUnlocked() { - return Task.Run(() => - { - View.InvokeOnUIThread(() => + return View.DesignerMode + ? Task.CompletedTask + : Task.Run(() => { - lock (Canvas.Sync) + View.InvokeOnUIThread(() => { - Measure(); - } + lock (Canvas.Sync) + { + Measure(); + } + }); }); - }); } private Task TooltipThrottlerUnlocked() diff --git a/src/LiveChartsCore/Kernel/DesignerKind.cs b/src/LiveChartsCore/Kernel/DesignerKind.cs new file mode 100644 index 000000000..7f2dbd63b --- /dev/null +++ b/src/LiveChartsCore/Kernel/DesignerKind.cs @@ -0,0 +1,39 @@ +// The MIT License(MIT) +// +// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace LiveChartsCore.Kernel +{ + /// + /// Designer series kind. + /// + public enum DesignerKind + { + /// + /// The Cartesian kind. + /// + Cartesian, + /// + /// The pie kind. + /// + Pie + } +} diff --git a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs index 9d9a11abb..64a4b0e58 100644 --- a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs +++ b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs @@ -120,6 +120,12 @@ public class LiveChartsSettings internal Func AxisProvider { get; set; } = () => throw new NotImplementedException($"{nameof(AxisProvider)} is not defined yet."); + /// + /// Gets the designer series. + /// + internal Func> DesignerSeriesGenerator { get; set; } = + x => throw new NotImplementedException($"{nameof(DefaultAnimationsSpeed)} is not defined yet."); + /// /// Adds or replaces a mapping for a given type, the mapper defines how a type is mapped to a instance, /// then the will be drawn as a point in our chart. @@ -157,6 +163,12 @@ internal LiveChartsSettings HasAxisProvider(Func provider) return this; } + internal LiveChartsSettings HasDesigerSeriesProvider(Func> provider) + { + DesignerSeriesGenerator = provider; + return this; + } + internal IDataFactoryProvider GetFactory() where TDrawingContext : DrawingContext { diff --git a/src/LiveChartsCore/LiveChartsCore.csproj b/src/LiveChartsCore/LiveChartsCore.csproj index cd63eefd1..e1180a931 100644 --- a/src/LiveChartsCore/LiveChartsCore.csproj +++ b/src/LiveChartsCore/LiveChartsCore.csproj @@ -6,7 +6,7 @@ net462;netstandard2.0;netcoreapp2.0; LiveChartsCore LiveChartsCore - 2.0.0-beta.50 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for .Net, this is the core package probably you need another package also unless you are building your own backed. MIT diff --git a/src/LiveChartsCore/PieChart.cs b/src/LiveChartsCore/PieChart.cs index 63555a01b..a5a250b3e 100644 --- a/src/LiveChartsCore/PieChart.cs +++ b/src/LiveChartsCore/PieChart.cs @@ -44,6 +44,7 @@ public class PieChart : Chart private readonly HashSet _everMeasuredSeries = new(); private readonly IPieChartView _chartView; private int _nextSeries = 0; + private IEnumerable? _designerSeries = null; /// /// Initializes a new instance of the class. @@ -139,8 +140,6 @@ public override TooltipPoint[] FindPointsNearTo(PointF pointerPosition) /// public override void Update(ChartUpdateParams? chartUpdateParams = null) { - if (View.DesignerMode) return; - chartUpdateParams ??= new ChartUpdateParams(); if (chartUpdateParams.IsAutomaticUpdate && !View.AutoUpdateEnabled) return; @@ -182,8 +181,11 @@ protected override void Measure() viewDrawMargin = _chartView.DrawMargin; controlSize = _chartView.ControlSize; - Series = _chartView.Series - .Where(x => x.IsVisible) + var actualSeries = View.DesignerMode + ? _designerSeries ??= LiveCharts.CurrentSettings.DesignerSeriesGenerator(DesignerKind.Cartesian) + : _chartView.Series.Where(x => x.IsVisible); + + Series = actualSeries .Cast>() .ToArray(); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj index ecf388f82..497a86637 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/LiveChartsCore.SkiaSharpView.Avalonia.csproj @@ -6,7 +6,7 @@ netcoreapp2.0;netstandard2.0;net462; LiveChartsCore.SkiaSharpView.Avalonia LiveChartsCore.SkiaSharpView.Avalonia - 2.0.0-beta.50 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for AvaloniaUI. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj index 61197a2ec..c1895d204 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/LiveChartsCore.SkiaSharpView.WPF.csproj @@ -1,4 +1,4 @@ - + enable @@ -7,7 +7,7 @@ net462;netcoreapp3.0 LiveChartsCore.SkiaSharpView.WPF LiveChartsCore.SkiaSharpView.WPF - 2.0.0-beta.50 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for WPF. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs index 0540765ff..b29e7adc7 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs @@ -30,6 +30,7 @@ using System.Collections.Specialized; using System.ComponentModel; using System.Drawing; +using System.Windows.Forms; namespace LiveChartsCore.SkiaSharpView.WinForms { @@ -61,8 +62,6 @@ public CartesianChart() : this(null, null) { } public CartesianChart(IChartTooltip? tooltip = null, IChartLegend? legend = null) : base(tooltip, legend) { - var s = PointStates; - _seriesObserver = new CollectionDeepObserver(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); _xObserver = new CollectionDeepObserver(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); _yObserver = new CollectionDeepObserver(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); @@ -93,7 +92,7 @@ public IEnumerable Series _seriesObserver.Dispose(_series); _seriesObserver.Initialize(value); _series = value; - core?.Update(); + OnPropertyChanged(); } } @@ -107,7 +106,7 @@ public IEnumerable XAxes _xObserver.Dispose(_xAxes); _xObserver.Initialize(value); _xAxes = value; - core?.Update(); + OnPropertyChanged(); } } @@ -121,7 +120,7 @@ public IEnumerable YAxes _yObserver.Dispose(_yAxes); _yObserver.Initialize(value); _yAxes = value; - core?.Update(); + OnPropertyChanged(); } } @@ -135,7 +134,7 @@ public IEnumerable> Sections _sectionsObserverer.Dispose(_sections); _sectionsObserverer.Initialize(value); _sections = value; - core?.Update(); + OnPropertyChanged(); } } @@ -147,7 +146,7 @@ public DrawMarginFrame? DrawMarginFrame set { _drawMarginFrame = value; - core?.Update(); + OnPropertyChanged(); } } @@ -169,6 +168,7 @@ public DrawMarginFrame? DrawMarginFrame protected override void InitializeCore() { core = new CartesianChart(this, LiveChartsSkiaSharp.DefaultPlatformBuilder, motionCanvas.CanvasCore); + if (DesignerMode) return; core.Update(); } @@ -182,17 +182,15 @@ public double[] ScaleUIPoint(PointF point, int xAxisIndex = 0, int yAxisIndex = private void OnDeepCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { - if (core is null) return; - core.Update(); + OnPropertyChanged(); } private void OnDeepCollectionPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (core is null) return; - core.Update(); + OnPropertyChanged(); } - private void OnMouseWheel(object? sender, System.Windows.Forms.MouseEventArgs e) + private void OnMouseWheel(object? sender, MouseEventArgs e) { if (core is null) throw new Exception("core not found"); var c = (CartesianChart)core; @@ -201,12 +199,12 @@ private void OnMouseWheel(object? sender, System.Windows.Forms.MouseEventArgs e) Capture = true; } - private void OnMouseDown(object? sender, System.Windows.Forms.MouseEventArgs e) + private void OnMouseDown(object? sender, MouseEventArgs e) { core?.InvokePointerDown(new PointF(e.Location.X, e.Location.Y)); } - private void OnMouseUp(object? sender, System.Windows.Forms.MouseEventArgs e) + private void OnMouseUp(object? sender, MouseEventArgs e) { core?.InvokePointerUp(new PointF(e.Location.X, e.Location.Y)); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs index f7b1d6c1d..59ab7bc6f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs @@ -328,7 +328,7 @@ public void SyncAction(Action action) /// protected void OnPropertyChanged() { - if (core is null) return; + if (core is null || DesignerMode) return; core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj index b5dcb3e1e..93b0a0ad6 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj @@ -9,7 +9,7 @@ net462;netcoreapp3.0 LiveChartsCore.SkiaSharpView.WinForms LiveChartsCore.SkiaSharpView.WinForms - 2.0.0-beta.55 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for WindowsForms. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs index 50ef2555a..4bb5a339c 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs @@ -55,13 +55,11 @@ public PieChart(IChartTooltip? tooltip = null, IChartLe _seriesObserver = new CollectionDeepObserver( (object? sender, NotifyCollectionChangedEventArgs e) => { - if (core is null) return; - core.Update(); + OnPropertyChanged(); }, (object? sender, PropertyChangedEventArgs e) => { - if (core is null) return; - core.Update(); + OnPropertyChanged(); }, true); } @@ -79,7 +77,7 @@ public IEnumerable Series _seriesObserver.Dispose(_series); _seriesObserver.Initialize(value); _series = value; - core?.Update(); + OnPropertyChanged(); } } @@ -98,6 +96,7 @@ public IEnumerable Series protected override void InitializeCore() { core = new PieChart(this, LiveChartsSkiaSharp.DefaultPlatformBuilder, motionCanvas.CanvasCore); + if (DesignerMode) return; core.Update(); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj index 588bf5f53..bc9b06ebd 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj @@ -1,4 +1,4 @@ - + 9.0 @@ -6,7 +6,7 @@ netstandard2.0; LiveChartsCore.SkiaSharpView.XamarinForms LiveChartsCore.SkiaSharpView.XamarinForms - 2.0.0-beta.50 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for XamarinForms. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj index 1f950a1cd..a7ca1699d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsCore.SkiaSharpView.csproj @@ -1,4 +1,4 @@ - + enable @@ -6,7 +6,7 @@ net462;netstandard2.0;netcoreapp2.0; LiveChartsCore.SkiaSharpView LiveChartsCore.SkiaSharpView - 2.0.0-beta.50 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for .Net, this package contains the SkiaSharp backend. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs index df1a15137..bc8011298 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs @@ -69,7 +69,24 @@ public static LiveChartsSettings AddSkiaSharp(this LiveChartsSettings settings) { return settings .HasDataFactory(new DataFactory()) - .HasAxisProvider(() => new Axis()); + .HasAxisProvider(() => new Axis()) + .HasDesigerSeriesProvider(kind => + { + var r = new Random(); + + var v1 = new int[] { r.Next(0, 10), r.Next(0, 10), r.Next(0, 10), r.Next(0, 10) }; + var v2 = new int[] { r.Next(0, 10), r.Next(0, 10), r.Next(0, 10), r.Next(0, 10) }; + + if (kind == DesignerKind.Pie) return new ISeries[] { new PieSeries { Values = v1 }, new PieSeries { Values = v2 } }; + + var seed = r.NextDouble(); + + return seed > 0.33 + ? (new ISeries[] { new LineSeries { Values = v1 }, new LineSeries { Values = v2 } }) + : (seed > 0.66 + ? new ISeries[] { new ColumnSeries { Values = v1 }, new ColumnSeries { Values = v2 } } + : new ISeries[] { new ScatterSeries { Values = v1 }, new ScatterSeries { Values = v2 } }); + }); } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj index 58d842211..f0250a7db 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj @@ -1,4 +1,4 @@ - + 9.0 enable @@ -7,7 +7,7 @@ LiveChartsCore.SkiaSharpView.WinUI win10-x86;win10-x64;win10-arm64 true - 2.0.0-beta.50 + 2.0.0-beta.60 Simple, flexible, interactive and powerful data visualization for WinUI 3. diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs index bab22143a..97452f131 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs @@ -61,6 +61,14 @@ public sealed partial class CartesianChart : UserControl, ICartesianChartView public CartesianChart() { + if (!LiveCharts.IsConfigured) LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); + + var stylesBuilder = LiveCharts.CurrentSettings.GetTheme(); + var initializer = stylesBuilder.GetVisualsInitializer(); + if (stylesBuilder.CurrentColors is null || stylesBuilder.CurrentColors.Length == 0) + throw new Exception("Default colors are not valid"); + initializer.ApplyStyleToChart(this); + InitializeComponent(); _seriesObserver = new CollectionDeepObserver(OnDeepCollectionChanged, OnDeepCollectionPropertyChanged, true); @@ -832,14 +840,6 @@ public void SyncAction(Action action) private void OnLoaded(object sender, RoutedEventArgs e) { - if (!LiveCharts.IsConfigured) LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); - - var stylesBuilder = LiveCharts.CurrentSettings.GetTheme(); - var initializer = stylesBuilder.GetVisualsInitializer(); - if (stylesBuilder.CurrentColors is null || stylesBuilder.CurrentColors.Length == 0) - throw new Exception("Default colors are not valid"); - initializer.ApplyStyleToChart(this); - var canvas = (MotionCanvas)FindName("motionCanvas"); _canvas = canvas; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.csproj index e7abc73a2..55d1922f6 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.csproj @@ -4,7 +4,7 @@ enable 9.0 - 2.0.0-beta.52 + 2.0.0-beta.60 icon.png Simple, flexible, interactive and powerful data visualization for UWP. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.nuspec b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.nuspec index 63f93222d..cf8a6d6d6 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.nuspec +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/LiveChartsCore.SkiaSharpView.UWP.nuspec @@ -2,7 +2,7 @@ LiveChartsCore.SkiaSharpView.UWP - 2.0.0-beta.57 + 2.0.0-beta.60 LiveChartsCore.SkiaSharpView.UWP BetoRodriguez true @@ -16,8 +16,9 @@ - - + + + diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs index c7ce5d83d..dc61eb0ca 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs @@ -51,6 +51,14 @@ public sealed partial class PieChart : UserControl, IPieChartView public PieChart() { + if (!LiveCharts.IsConfigured) LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); + + var stylesBuilder = LiveCharts.CurrentSettings.GetTheme(); + var initializer = stylesBuilder.GetVisualsInitializer(); + if (stylesBuilder.CurrentColors is null || stylesBuilder.CurrentColors.Length == 0) + throw new Exception("Default colors are not valid"); + initializer.ApplyStyleToChart(this); + InitializeComponent(); _seriesObserver = new CollectionDeepObserver( @@ -718,20 +726,10 @@ public void SyncAction(Action action) private void OnLoaded(object sender, RoutedEventArgs e) { - if (!LiveCharts.IsConfigured) LiveCharts.Configure(LiveChartsSkiaSharp.DefaultPlatformBuilder); - - var stylesBuilder = LiveCharts.CurrentSettings.GetTheme(); - var initializer = stylesBuilder.GetVisualsInitializer(); - if (stylesBuilder.CurrentColors is null || stylesBuilder.CurrentColors.Length == 0) - throw new Exception("Default colors are not valid"); - initializer.ApplyStyleToChart(this); - var canvas = (MotionCanvas)FindName("motionCanvas"); _canvas = canvas; _core = new PieChart(this, LiveChartsSkiaSharp.DefaultPlatformBuilder, canvas.CanvasCore); - //legend = Template.FindName("legend", this) as IChartLegend; - //tooltip = Template.FindName("tooltip", this) as IChartTooltip; if (SyncContext != null) _canvas.CanvasCore.Sync = SyncContext;