Skip to content

Commit

Permalink
Merge pull request #1152 from beto-rodriguez/dev
Browse files Browse the repository at this point in the history
2.0.0-beta.910
  • Loading branch information
beto-rodriguez authored Aug 2, 2023
2 parents 5329be3 + eac8c68 commit c4f2444
Show file tree
Hide file tree
Showing 29 changed files with 67 additions and 142 deletions.
12 changes: 0 additions & 12 deletions samples/AvaloniaSample/Bars/Race/View.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ public class View : UserControl
public View()
{
InitializeComponent();
Update();
}

public async void Update()
{
var vm = (ViewModel?)DataContext;
if (vm is null) return;
while (true)
{
Dispatcher.UIThread.Post(vm.RandomIncrement, DispatcherPriority.Background);
await Task.Delay(100);
}
}

private void InitializeComponent()
Expand Down
11 changes: 0 additions & 11 deletions samples/BlazorSample/Pages/Bars/Race.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);

Update();
}

public ViewModel ViewModel { get; set; } = new();

public async void Update()
{
while (true)
{
ViewModel.RandomIncrement();
await Task.Delay(100);
}
}
}
12 changes: 0 additions & 12 deletions samples/EtoFormsSample/Bars/Race/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ public View()

Content = cartesianChart;

UpdateViewModel();

UnLoad += (o, e) => Visible = false;
}

public async void UpdateViewModel()
{
while (Visible)
{
viewModel.RandomIncrement();
cartesianChart.Series = viewModel.Series;
await Task.Delay(100);
}
}
}
11 changes: 0 additions & 11 deletions samples/MauiSample/Bars/Race/View.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,5 @@ public partial class View : ContentPage
public View()
{
InitializeComponent();
Update();
}

public async void Update()
{
var vm = (ViewModel)BindingContext;
while (true)
{
_ = Dispatcher.Dispatch(vm.RandomIncrement);
await Task.Delay(100);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,5 @@ public sealed partial class View : UserControl
public View()
{
InitializeComponent();
Update();
}

public async void Update()
{
var vm = (ViewModel)DataContext;
while (true)
{
_ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => vm.RandomIncrement());
await Task.Delay(100);
}
}
}
37 changes: 28 additions & 9 deletions samples/ViewModelsSamples/Bars/Race/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.Defaults;
Expand All @@ -26,6 +26,13 @@ private static readonly (string, double)[] s_initialData =
("Hamilton", 1000)
};

public ViewModel()
{
_ = StartRace();
}

public bool IsReading { get; set; } = true;

[ObservableProperty]
private ISeries[] _series =
s_initialData
Expand All @@ -49,16 +56,28 @@ private static readonly (string, double)[] s_initialData =
[ObservableProperty]
private Axis[] _yAxes = { new Axis { IsVisible = false } };

public void RandomIncrement()
public async Task StartRace()
{
foreach (var item in Series)
await Task.Delay(1000);

// to keep this sample simple, we run the next infinite loop
// in a real application you should stop the loop/task when the view is disposed

while (IsReading)
{
if (item.Values is null) continue;
foreach (var item in Series)
{
if (item.Values is null) continue;

var i = ((ObservableValue[])item.Values)[0];
i.Value += _r.Next(0, 100);
}
var i = ((ObservableValue[])item.Values)[0];
i.Value += _r.Next(0, 100);
}

Series = Series.OrderByDescending(x => ((ObservableValue[])x.Values!)[0].Value).ToArray();
Series = Series
.OrderByDescending(x => ((ObservableValue[])x.Values!)[0].Value)
.ToArray();

await Task.Delay(100);
}
}
}
9 changes: 7 additions & 2 deletions samples/ViewModelsSamples/General/MultiThreading/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ public ViewModel()

public object Sync { get; } = new object();

private async void ReadData()
public bool IsReading { get; set; } = true;

private async Task ReadData()
{
await Task.Delay(1000);

while (true)
// to keep this sample simple, we run the next infinite loop
// in a real application you should stop the loop/task when the view is disposed

while (IsReading)
{
await Task.Delay(_delay);

Expand Down
11 changes: 8 additions & 3 deletions samples/ViewModelsSamples/General/MultiThreading2/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,22 @@ public ViewModel(Action<Action> uiThreadInvoker)
// create {readTasks} parallel tasks that will add a point every {_delay} milliseconds
for (var i = 0; i < readTasks; i++)
{
ReadData();
_ = Task.Run(ReadData);
}
}

public ISeries[] Series { get; set; }

public async void ReadData()
public bool IsReading { get; set; } = true;

public async Task ReadData()
{
await Task.Delay(1000);

while (true)
// to keep this sample simple, we run the next infinite loop
// in a real application you should stop the loop/task when the view is disposed

while (IsReading)
{
await Task.Delay(_delay);

Expand Down
3 changes: 1 addition & 2 deletions samples/ViewModelsSamples/Pies/Custom/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public partial class ViewModel : ObservableObject
public ViewModel()
{
var outer = 1d;
//var data = new[] { 6, 5, 4, 3 };
var data = new[] { 6 };
var data = new[] { 6, 5, 4, 3 };

// you can convert any array, list or IEnumerable<T> to a pie series collection:
Series = data.AsPieSeries((value, series) =>
Expand Down
11 changes: 0 additions & 11 deletions samples/WPFSample/Bars/Race/View.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,5 @@ public partial class View : UserControl
public View()
{
InitializeComponent();
Update();
}

public async void Update()
{
var vm = (ViewModel)DataContext;
while (true)
{
Application.Current.Dispatcher.Invoke(vm.RandomIncrement);
await Task.Delay(100);
}
}
}
12 changes: 0 additions & 12 deletions samples/WinFormsSample/Bars/Race/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,5 @@ public View()
};

Controls.Add(cartesianChart);

UpdateViewModel();
}

public async void UpdateViewModel()
{
while (true)
{
viewModel.RandomIncrement();
cartesianChart.Series = viewModel.Series;
await Task.Delay(100);
}
}
}
11 changes: 0 additions & 11 deletions samples/WinUISample/WinUISample/Bars/Race/View.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,5 @@ public sealed partial class View : UserControl
public View()
{
InitializeComponent();
Update();
}

public async void Update()
{
var vm = (ViewModel)DataContext;
while (true)
{
_ = DispatcherQueue.TryEnqueue(vm.RandomIncrement);
await Task.Delay(100);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,5 @@ public partial class View : ContentPage
public View()
{
InitializeComponent();
Update();
}

public async void Update()
{
var vm = (ViewModel)BindingContext;
while (true)
{
Device.BeginInvokeOnMainThread(vm.RandomIncrement);
await Task.Delay(100);
}
}
}
2 changes: 1 addition & 1 deletion src/LiveChartsCore/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ protected void CollectVisuals()
/// <param name="rs">The right margin.</param>
protected void DrawLegend(ref float ts, ref float bs, ref float ls, ref float rs)
{
if (Legend is null) return;
if (Legend is null || LegendPosition == LegendPosition.Hidden) return;

_legendSize = Legend.Measure(this);

Expand Down
2 changes: 1 addition & 1 deletion src/LiveChartsCore/LiveChartsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<AssemblyName>LiveChartsCore</AssemblyName>
<RootNamespace>LiveChartsCore</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>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.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
3 changes: 1 addition & 2 deletions src/LiveChartsCore/VisualElements/RelativePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using System;
using System.Collections.Generic;
using LiveChartsCore.Drawing;
using LiveChartsCore.Kernel;
Expand Down Expand Up @@ -62,7 +61,7 @@ public IPaint<TDrawingContext>? BackgroundPaint

internal override IPaint<TDrawingContext>?[] GetPaintTasks()
{
return Array.Empty<IPaint<TDrawingContext>>();
return new[] { _backgroundPaint };
}

internal override IAnimatable?[] GetDrawnGeometries()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>netcoreapp2.0;netstandard2.0;net462;</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.Avalonia</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.Avalonia</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for AvaloniaUI.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.WPF</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WPF</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for WPF.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TargetFrameworks>net462;netcoreapp3.1</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.WinForms</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WinForms</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for WindowsForms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.XamarinForms</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.XamarinForms</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for XamarinForms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<AssemblyName>LiveChartsCore.SkiaSharpView</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for .Net, this package contains the SkiaSharp backend.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Blazor.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.Eto</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.Eto</RootNamespace>
<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Eto.Forms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>

<Version>2.0.0-beta.900</Version>
<Version>2.0.0-beta.910</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for Maui.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading

0 comments on commit c4f2444

Please sign in to comment.