Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rc.5.1 #1771

Merged
merged 11 commits into from
Jan 16, 2025
Merged

rc.5.1 #1771

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>

<LiveChartsVersion>2.0.0-rc5</LiveChartsVersion>
<LiveChartsVersion>2.0.0-rc5.1</LiveChartsVersion>
<LiveChartsAuthors>BetoRodriguez</LiveChartsAuthors>

<GlobalLangVersion>12.0</GlobalLangVersion>
Expand Down
7 changes: 4 additions & 3 deletions docs/overview/1.2.install.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ install a package from NuGet, please follow [this guide](https://docs.microsoft.

> LiveChartsCore.SkiaSharpView.Maui

## Register SkiaSharp
## Register SkiaSharp and LiveCharts Handlers

This is a requirement by SkiaSharp, in the solution explorer, browse for the `MauiProgram` class and register SkiaSharp in the application:
You must register SkiaSharp and LiveCharts handlers now, browse for the `MauiProgram` class and add `.UseSkiaSharp()` and `.UseLiveCharts()`:

<pre><code>using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
Expand All @@ -482,7 +482,8 @@ namespace MauiApp
var builder = MauiApp.CreateBuilder();
builder
.UseSkiaSharp() // mark
.UseMauiApp<App>()
.UseLiveCharts() // mark
.UseMauiApp&lt;App&gt;()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand Down
Binary file modified docs/samples/events/tutorial/result.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 14 additions & 8 deletions docs/samples/general/visualElements/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ the creation and destruction of the drawn geometries in the canvas.

In the next example, we create a `CartesianChart`, this chart contains multiple visual elements, each visual element is defined below in this article:

## View Model

```
{{ full_name | get_vm_from_docs }}
```

{{~ if xaml ~}}
## XAML
{{~ end ~}}
Expand Down Expand Up @@ -59,8 +65,8 @@ Use the `VariableSVGPathGeometry` as the `DrawnElement` to draw svg paths:
The easiest way is to inherit from `DrawnGeometry`, this class implements `IDrawnElement` and also animates all of its properties;
In the next example we inherit from `BoundedDrawnGeometry` it only adds the `Width` and `Height` properties to the `DrawnGeometry` class.

<div class="position-relative text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/custom.png" class="static" alt="sample image" />
<div class="text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/custom.png" alt="sample image" />
</div>

{{~ render_params_file_as_code this "~/../samples/ViewModelsSamples/General/VisualElements/CustomSkiaShape.cs" ~}}
Expand Down Expand Up @@ -96,8 +102,8 @@ Used to place children on its own coordinate system, all the children X and Y co
the size of the largest element in the children collection. For example in the next case, we place the place the RectangleGeometry` in the 0,0
coordinate [in the layout system] and the `LabelGeometry` in the 10,0 coordinate.

<div class="position-relative text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/absolute.png" class="static" alt="sample image" />
<div class="text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/absolute.png" alt="sample image" />
</div>

{{~ render_params_file_as_code this "~/../samples/ViewModelsSamples/General/VisualElements/AbsoluteVisual.cs" ~}}
Expand All @@ -106,8 +112,8 @@ coordinate [in the layout system] and the `LabelGeometry` in the 10,0 coordinate

Stacks `IDrawnElement` objects in vertical or horizontal order.

<div class="position-relative text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/stack.png" class="static" alt="sample image" />
<div class="text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/stack.png" alt="sample image" />
</div>

{{~ render_params_file_as_code this "~/../samples/ViewModelsSamples/General/VisualElements/StackedVisual.cs" ~}}
Expand All @@ -116,8 +122,8 @@ Stacks `IDrawnElement` objects in vertical or horizontal order.

Uses a grid system to place `IDrawnElement` objects.

<div class="position-relative text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/table.png" class="static" alt="sample image" />
<div class="text-center">
<img src="{{ assets_url }}/docs/{{ unique_name }}/table.png" alt="sample image" />
</div>

{{~ render_params_file_as_code this "~/../samples/ViewModelsSamples/General/VisualElements/TableVisual.cs" ~}}
Expand Down
18 changes: 16 additions & 2 deletions src/LiveChartsCore/LiveChartsCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">
$(TargetFrameworks);
net462;
net8.0-windows10.0.19041.0;net8.0-windows10.0.20348.0;
<!--
workaround #250116
netx.0-windows and SupportedOSPlatformVersion is a workaround for
https://github.com/beto-rodriguez/LiveCharts2/issues/1765
this ensures the package is restore to net8 or net6 instead of net462,
we cant restore the core to net462 because it has a strong name.

ideally the user should update the target to net8.0-windows10.0.19041... but the
default template as today uses net8.0-windows and causes this issue.
-->
net6.0-windows;
net8.0-windows;
net6.0-windows10.0.19041.0;
net8.0-windows10.0.19041.0;
</TargetFrameworks>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">7.0</SupportedOSPlatformVersion>

<AssemblyName>LiveChartsCore</AssemblyName>
<RootNamespace>LiveChartsCore</RootNamespace>
Expand Down
6 changes: 5 additions & 1 deletion src/LiveChartsCore/Motion/MotionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public void CopyFrom(IMotionProperty source)
/// <param name="animatable">The <see cref="Animatable"/> instance that is moving.</param>
public void SetMovement(T value, Animatable animatable)
{
if (value is not null && value.Equals(toValue)) return;
// the next commented line was added from rc4 to rc5, this caused
// https://github.com/beto-rodriguez/LiveCharts2/issues/1768
// i dont exactly remember why i added it :(
// lets leave things as they were before.
//if (value is not null && value.Equals(toValue)) return;

fromValue = GetMovement(animatable);
toValue = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@
<LangVersion>$(GlobalLangVersion)</LangVersion>
<UseWPF>true</UseWPF>

<TargetFrameworks>net462;net6.0-windows10.0.19041;net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>
net462;
<!--
workaround #250116
netx.0-windows and SupportedOSPlatformVersion is a workaround for
https://github.com/beto-rodriguez/LiveCharts2/issues/1765
this ensures the package is restore to net8 or net6 instead of net462,
we cant restore the core to net462 because it has a strong name.

ideally the user should update the target to net8.0-windows10.0.19041... but the
default template as today uses net8.0-windows and causes this issue.
-->
net6.0-windows;
net8.0-windows;
net6.0-windows10.0.19041;
net8.0-windows10.0.19041
</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.WPF</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WPF</RootNamespace>
<Version>$(LiveChartsVersion)</Version>
Expand All @@ -31,8 +47,35 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="$(LatestSkiaSharpVersion)" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="$(LatestSkiaSharpVersion)" />

<!--
workaround #250115
SkiaSharp is not loading natives in net framework
https://github.com/mono/SkiaSharp/issues/3111

the LatestSkiaSharpVersion is required for the new LiveCharts.UseGPU flag,
we include the LatestSkiaSharpVersion when net 6 or above is targeted.

On net 462 the code will throw when LiveCharts.UseGPU is set to true, and will
explain the user that the feature is not supported on net 462.
-->
<PackageReference
Condition="'$(TargetFramework)' == 'net462'"
Include="SkiaSharp.Views.WPF"
Version="$(SkiaSharpVersion)" />
<PackageReference
Condition="'$(TargetFramework)' == 'net462'"
Include="SkiaSharp.HarfBuzz"
Version="$(SkiaSharpVersion)" />

<PackageReference
Condition="'$(TargetFramework)' != 'net462'"
Include="SkiaSharp.Views.WPF"
Version="$(LatestSkiaSharpVersion)" />
<PackageReference
Condition="'$(TargetFramework)' != 'net462'"
Include="SkiaSharp.HarfBuzz"
Version="$(LatestSkiaSharpVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 13 additions & 0 deletions src/skiasharp/LiveChartsCore.SkiaSharp.WPF/MotionCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ namespace LiveChartsCore.SkiaSharpView.WPF;
public class MotionCanvas : UserControl
{
private SKElement? _skiaElement;
#if NET6_0_OR_GREATER
// workaround #250115
private SKGLElement? _skiaGlElement;
#endif
private bool _isDrawingLoopRunning = false;

/// <summary>
Expand Down Expand Up @@ -90,8 +93,15 @@ private void InitializeElement()
{
if (LiveCharts.UseGPU)
{
#if NET6_0_OR_GREATER
// workaround #250115
Content = _skiaGlElement = new SKGLElement();
_skiaGlElement.PaintSurface += OnPaintGlSurface;
#else
throw new PlatformNotSupportedException(
"GPU rendering is only supported in .NET 6.0 or greater, " +
"because https://github.com/mono/SkiaSharp/issues/3111 needs to be fixed.");
#endif
}
else
{
Expand Down Expand Up @@ -136,7 +146,10 @@ private async void RunDrawingLoop()
while (!CanvasCore.IsValid)
{
_skiaElement?.InvalidateVisual();
#if NET6_0_OR_GREATER
// workaround #250115
_skiaGlElement?.InvalidateVisual();
#endif
await Task.Delay(ts);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<OutputType>Library</OutputType>
<TargetFrameworks>net462;net6.0-windows10.0.19041;net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks>
net462;
<!--
workaround #250116
netx.0-windows and SupportedOSPlatformVersion is a workaround for
https://github.com/beto-rodriguez/LiveCharts2/issues/1765
this ensures the package is restore to net8 or net6 instead of net462,
we cant restore the core to net462 because it has a strong name.

ideally the user should update the target to net8.0-windows10.0.19041... but the
default template as today uses net8.0-windows and causes this issue.
-->
net6.0-windows;
net8.0-windows;
net6.0-windows10.0.19041;
net8.0-windows10.0.19041
</TargetFrameworks>

<AssemblyName>LiveChartsCore.SkiaSharpView.WinForms</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WinForms</RootNamespace>
<Version>$(LiveChartsVersion)</Version>
Expand All @@ -33,8 +50,35 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="SkiaSharp.Views.WindowsForms" Version="$(LatestSkiaSharpVersion)" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="$(LatestSkiaSharpVersion)" />

<!--
workaround #250115
SkiaSharp is not loading natives in net framework
https://github.com/mono/SkiaSharp/issues/3111

the LatestSkiaSharpVersion is required for the new LiveCharts.UseGPU flag,
we include the LatestSkiaSharpVersion when net 6 or above is targeted.

On net 462 the code will throw when LiveCharts.UseGPU is set to true, and will
explain the user that the feature is not supported on net 462.
-->
<PackageReference
Condition="'$(TargetFramework)' == 'net462'"
Include="SkiaSharp.Views.WindowsForms "
Version="$(SkiaSharpVersion)" />
<PackageReference
Condition="'$(TargetFramework)' == 'net462'"
Include="SkiaSharp.HarfBuzz"
Version="$(SkiaSharpVersion)" />

<PackageReference
Condition="'$(TargetFramework)' != 'net462'"
Include="SkiaSharp.Views.WindowsForms "
Version="$(LatestSkiaSharpVersion)" />
<PackageReference
Condition="'$(TargetFramework)' != 'net462'"
Include="SkiaSharp.HarfBuzz"
Version="$(LatestSkiaSharpVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using System.Windows.Forms;
using LiveChartsCore.Motion;
using LiveChartsCore.SkiaSharpView.Drawing;
using SkiaSharp;
using SkiaSharp.Views.Desktop;

namespace LiveChartsCore.SkiaSharpView.WinForms;
Expand Down Expand Up @@ -76,12 +75,15 @@ private void SkControl_PaintSurface(object sender, SKPaintSurfaceEventArgs e) =>
CanvasCore.DrawFrame(
new SkiaSharpDrawingContext(CanvasCore, e.Info, e.Surface, e.Surface.Canvas));

#if NET6_0_OR_GREATER
// workaround #250115
private void SkglControl_PaintSurface(object sender, SKPaintGLSurfaceEventArgs e) =>
CanvasCore.DrawFrame(
new SkiaSharpDrawingContext(CanvasCore, e.Info, e.Surface, e.Surface.Canvas)
{
Background = new SKColor(Parent.BackColor.R, Parent.BackColor.G, Parent.BackColor.B)
Background = new SkiaSharp.SKColor(Parent!.BackColor.R, Parent.BackColor.G, Parent.BackColor.B)
});
#endif

private void CanvasCore_Invalidated(CoreMotionCanvas sender) =>
RunDrawingLoop();
Expand All @@ -96,7 +98,10 @@ private async void RunDrawingLoop()
while (!CanvasCore.IsValid)
{
_skControl?.Invalidate();
#if NET6_0_OR_GREATER
// workaround #250115
_skglControl?.Invalidate();
#endif

await Task.Delay(ts);
}
Expand Down
Loading
Loading