Skip to content

Commit 5836c7f

Browse files
Merge pull request #1352 from beto-rodriguez/dev
rc2
2 parents b0e32c2 + cda1e0a commit 5836c7f

File tree

491 files changed

+4173
-3578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

491 files changed

+4173
-3578
lines changed

LiveCharts.sln

Lines changed: 3 additions & 385 deletions
Large diffs are not rendered by default.

build/pack.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ param([string]$configuration = "Debug", [string]$nupkgOutputPath = "./nupkg")
99
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj")
1010
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj")
1111
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj")
12-
[Project]::new("./src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj", $true)
1312
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj", $true)
1413
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno/LiveChartsCore.SkiaSharpView.Uno.csproj", $true)
15-
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj", $true)
14+
[Project]::new("./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj", $true),
1615
[Project]::new(
17-
"./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj",
18-
$true,
19-
"nuget",
20-
"./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.nuspec"
16+
"./src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj", $true,
17+
"nuget", "./src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.nuspec")
18+
[Project]::new(
19+
"./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj", $true,
20+
"nuget", "./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.nuspec"
2121
)
2222
)
2323

docs/overview/1.5.mappers.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ the `TempSample` class by setting a Mapper or implementing `IChartEntity` in our
6868

6969
## Mappers
7070

71-
Mappers are the easiest way but has a performance cost, a mapper is a method that takes both the `instance`
72-
(each `TempSample` in our data collection) and the `point` (that LiveCharts assigned) as parameters, inside this function we must
73-
specify the X and Y coordinates in our chart.
71+
Mappers are the easiest way but has a performance cost, a mapper is a function that takes both: the `instance`
72+
(each `TempSample` in our data collection) and the `index` of the instance in the collection as parameters,
73+
and returns a `Coordinate` in the chart.
7474

7575
```c#
7676
using var streamReader = new StreamReader("data.json");
@@ -86,15 +86,9 @@ var chart = new SKCartesianChart
8686
new LineSeries<TempSample>
8787
{
8888
Values = samples,
89-
Mapping = (sample, chartPoint) => // mark
90-
{ // mark
91-
// use the Temperature property in the Y axis // mark
92-
// and the Time property in the X axis // mark
93-
chartPoint.Coordinate = new(sample.Time, sample.Temperature);
94-
95-
// sometimes it is useful to use the index of the instance in the array as the X coordinate: // mark
96-
// chartPoint.SecondaryValue = chartPoint.Index; // mark
97-
} // mark
89+
// use the Temperature property in the Y axis // mark
90+
// and the Time property in the X axis // mark
91+
Mapping = (sample, index) => new(sample.Time, sample.Temperature) // mark
9892
}
9993
},
10094
XAxes = new[] { new Axis { Labeler = value => $"{value} seconds" } },
@@ -108,19 +102,14 @@ Now it works! You can also register the mapper globally, this means that every t
108102
chart all over our application, the library will use the mapper we indicated.
109103

110104
``` c#
111-
// ideally this code must be placed where your application or view starts
105+
// ideally this code must be placed where your application starts
112106
LiveCharts.Configure(config =>
113-
config
114-
.HasMap<TempSample>(
115-
(sample, chartPoint) =>
116-
{
117-
chartPoint.PrimaryValue = sample.Temperature;
118-
chartPoint.SecondaryValue = sample.Time;
119-
}));
107+
config.HasMap<TempSample>(
108+
(sample, index) => new(sample.Time, sample.Temperature));
120109
```
121110

122111
Global mappers are unique for a type, this means that every time a `TempSample` instance is in a chart, LiveCharts will use this mapper,
123-
if You register again a global mapper for the `TempSample` class, then the previous will be replaced by the new one.
112+
if you register again a global mapper for the `TempSample` class, then the previous will be replaced by the new one.
124113
If the series specifies the `Mapping` property, then the global mapper will be ignored and instead it will use the series instance mapper.
125114

126115
<a href="https://github.com/beto-rodriguez/LiveCharts2/blob/master/samples/MappersSamples/Program.cs" class="btn btn-light btn-lg text-primary shadow-sm mb-3">
@@ -129,8 +118,9 @@ If the series specifies the `Mapping` property, then the global mapper will be i
129118

130119
## IChartEntity
131120

132-
The `IChartEntity` interface force our points to have a [Coordinate](https://lvcharts.com/api/2.0.0-beta.710/LiveChartsCore.Kernel.Coordinate), LiveCharts will use this property to build the plot, when the interface is implemented correctly, you will notice a considerable
133-
performance improvement, specially in large data sets.
121+
The `IChartEntity` interface forces our points to have a [Coordinate](https://lvcharts.com/api/2.0.0-beta.710/LiveChartsCore.Kernel.Coordinate),
122+
LiveCharts will use this property to build the plot, when the interface is implemented correctly, you will notice a considerable
123+
performance improvement, specially on large data sets.
134124

135125
Imagine the same case we used in the previous sample where we have a json file that contains the temperature of a CPU at a given time,
136126
we want to build a chart with that data.

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
For Uno, open ./samples/UnoPlatform_v5/UnoPlatform_v5.sln

samples/AvaloniaSample/App.axaml.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ public override void Initialize()
3131
// finally register your own mappers
3232
// you can learn more about mappers at:
3333
// https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Mappers
34-
.HasMap<City>((city, point) => // mark
35-
{ // mark
36-
// here we use the index as X, and the population as Y // mark
37-
point.Coordinate = new(point.Index, city.Population); // mark
38-
}) // mark
34+
35+
// here we use the index as X, and the population as Y // mark
36+
.HasMap<City>((city, index) => new(index, city.Population)) // mark
3937
// .HasMap<Foo>( .... ) // mark
4038
// .HasMap<Bar>( .... ) // mark
4139
); // mark
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<UserControl x:Class="AvaloniaSample.General.DrawOnCanvas.View"
2+
xmlns="https://github.com/avaloniaui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
5+
xmlns:vms="using:ViewModelsSamples.General.DrawOnCanvas">
6+
<UserControl.DataContext>
7+
<vms:ViewModel/>
8+
</UserControl.DataContext>
9+
10+
<Grid>
11+
<lvc:CartesianChart UpdateStartedCommand="{Binding ChartUpdatedCommand}"/>
12+
</Grid>
13+
</UserControl>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Avalonia.Controls;
2+
using Avalonia.Markup.Xaml;
3+
4+
namespace AvaloniaSample.General.DrawOnCanvas;
5+
6+
public partial class View : UserControl
7+
{
8+
public View()
9+
{
10+
InitializeComponent();
11+
}
12+
13+
private void InitializeComponent()
14+
{
15+
AvaloniaXamlLoader.Load(this);
16+
}
17+
}

samples/BlazorSample/App.razor

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828
// finally register your own mappers
2929
// you can learn more about mappers at:
3030
// https://livecharts.dev/docs/{{ platform }}/{{ version }}/Overview.Mappers
31-
.HasMap<City>((city, point) => // mark
32-
{ // mark
33-
// here we use the index as X, and the population as Y // mark
34-
point.Coordinate = new(point.Index, city.Population); // mark
35-
}) // mark
31+
32+
// here we use the index as X, and the population as Y // mark
33+
.HasMap<City>((city, index) => new(index, city.Population)) // mark
3634
// .HasMap<Foo>( .... ) // mark
3735
// .HasMap<Bar>( .... ) // mark
3836
); // mark
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@page "/General/DrawOnCanvas"
2+
@using LiveChartsCore.SkiaSharpView.Blazor
3+
@using ViewModelsSamples.General.DrawOnCanvas
4+
5+
<CartesianChart
6+
@ref="chart">
7+
</CartesianChart>
8+
9+
@code {
10+
public CartesianChart chart = null!;
11+
public ViewModel ViewModel { get; set; } = new();
12+
13+
protected override void OnAfterRender(bool firstRender)
14+
{
15+
base.OnAfterRender(firstRender);
16+
17+
chart.UpdateStarted += chart =>
18+
{
19+
ViewModel.ChartUpdated(new(chart));
20+
};
21+
}
22+
}

samples/BlazorSample/Pages/Hello.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
<p class="text-center text-muted">
6161
LiveCharts provides controls for any UI framework (console and server-side is also supported). <br />
6262
<small class="text-center text-muted">
63-
The minimum requirement for .Net framework is .Net 4.6.2 and is compatible with is compatible
64-
with .NET standard 2.0.
63+
The minimum requirement for .Net framework is .Net 4.6.2 and is compatible with .NET standard 2.0.
6564
</small>
6665
</p>
6766

0 commit comments

Comments
 (0)