Skip to content

Commit

Permalink
Merge pull request #662 from beto-rodriguez/dev
Browse files Browse the repository at this point in the history
beta.500
  • Loading branch information
beto-rodriguez authored Oct 7, 2022
2 parents 868bad9 + 13fb55f commit 30cfa86
Show file tree
Hide file tree
Showing 113 changed files with 1,543 additions and 838 deletions.
18 changes: 15 additions & 3 deletions samples/AvaloniaSample/Axes/Shared/View.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@
Notice we are binding the XAxes to the same instance, this way we are sharing both charts zooming and panning
no matter in which chart you zoom, the other chart will share the view.
-->

<lvc:CartesianChart Grid.Row="0" Series="{Binding SeriesCollection1}" XAxes="{Binding SharedXAxis}" ZoomMode="X"></lvc:CartesianChart>
<lvc:CartesianChart Grid.Row="1" Series="{Binding SeriesCollection2}" XAxes="{Binding SharedXAxis}" ZoomMode="X"></lvc:CartesianChart>

<lvc:CartesianChart
Grid.Row="0"
Series="{Binding SeriesCollection1}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
<lvc:CartesianChart
Grid.Row="1"
Series="{Binding SeriesCollection2}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
</Grid>
</UserControl>
2 changes: 1 addition & 1 deletion samples/AvaloniaSample/Lines/Basic/View.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart Series="{Binding Series}"/>
<lvc:CartesianChart Series="{Binding Series}" Title="{Binding Title}"/>
</UserControl>
2 changes: 2 additions & 0 deletions samples/BlazorSample/Pages/Axes/Shared.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<CartesianChart
Series="ViewModel.SeriesCollection1"
XAxes="ViewModel.SharedXAxis"
DrawMargin="ViewModel.DrawMargin"
ZoomMode="LiveChartsCore.Measure.ZoomAndPanMode.X">
</CartesianChart>
</div>
Expand All @@ -14,6 +15,7 @@
<LiveChartsCore.SkiaSharpView.Blazor.CartesianChart
Series="ViewModel.SeriesCollection2"
XAxes="ViewModel.SharedXAxis"
DrawMargin="ViewModel.DrawMargin"
ZoomMode="LiveChartsCore.Measure.ZoomAndPanMode.X">
</LiveChartsCore.SkiaSharpView.Blazor.CartesianChart>
</div>
Expand Down
2 changes: 1 addition & 1 deletion samples/BlazorSample/Pages/Lines/Basic.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@using LiveChartsCore.SkiaSharpView.Blazor
@using ViewModelsSamples.Lines.Basic

<CartesianChart Series="ViewModel.Series"/>
<CartesianChart Series="ViewModel.Series" Title="ViewModel.Title" />

@code {
public ViewModel ViewModel { get; set; } = new();
Expand Down
14 changes: 13 additions & 1 deletion samples/ConsoleSample/ConsoleSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using LiveChartsCore;
using LiveChartsCore.Drawing;
using LiveChartsCore.Geo;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.SKCharts;
using LiveChartsCore.SkiaSharpView.VisualElements;
using SkiaSharp;

var cartesianChart = new SKCartesianChart
{
Expand All @@ -13,7 +17,15 @@
new LineSeries<int> { Values = new int[] { 1, 5, 4, 6 } },
new ColumnSeries<int> { Values = new int[] { 4, 8, 2, 4 } }
},
LegendPosition = LiveChartsCore.Measure.LegendPosition.Right
Title = new LabelVisual
{
Text = "Hello LiveCharts",
TextSize = 30,
Padding = new Padding(15),
Paint = new SolidColorPaint(0xff303030)
},
LegendPosition = LiveChartsCore.Measure.LegendPosition.Right,
Background = SKColors.White
};

// you can save the image to png (by default)
Expand Down
2 changes: 2 additions & 0 deletions samples/EtoFormsSample/Axes/Shared/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ public View()
{
Series = viewModel.SeriesCollection1,
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
DrawMargin = viewModel.DrawMargin,
XAxes = viewModel.SharedXAxis, // <-- notice we are using the same variable for both charts, this syncs both charts
};

var cartesianChart2 = new CartesianChart
{
Series = viewModel.SeriesCollection2,
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.X,
DrawMargin = viewModel.DrawMargin,
XAxes = viewModel.SharedXAxis, // <-- notice we are using the same variable for both charts, this syncs both charts
};

Expand Down
1 change: 1 addition & 0 deletions samples/EtoFormsSample/Lines/Basic/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public View()
cartesianChart = new CartesianChart
{
Series = viewModel.Series,
Title = viewModel.Title
};

Content = cartesianChart;
Expand Down
2 changes: 2 additions & 0 deletions samples/MauiSample/Axes/Shared/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
Grid.Row="0"
Series="{Binding SeriesCollection1}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>

<lvc:CartesianChart
Grid.Row="1"
Series="{Binding SeriesCollection2}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>

Expand Down
2 changes: 1 addition & 1 deletion samples/MauiSample/Lines/Basic/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart Series="{Binding Series}"/>
<lvc:CartesianChart Series="{Binding Series}" Title="{Binding Title}" />
</ContentPage>
15 changes: 10 additions & 5 deletions samples/QuestPDFSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
using SkiaSharp;

Document.Create(container =>
{
Expand All @@ -22,12 +21,16 @@
.SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);

page.Content()
.Canvas((canvas, size) =>
.PaddingVertical(1, Unit.Centimetre)
.Column(x =>
{
x.Spacing(20);
x.Item().Text(Placeholders.LoremIpsum());

var cartesianChart = new SKCartesianChart
{
Width = (int)size.Width,
Height = (int)size.Width,
Width = 1920,
Height = 300,
Series = new ISeries[]
{
new LineSeries<int> { Values = new int[] { 1, 5, 4, 6 } },
Expand All @@ -36,7 +39,9 @@
};

using var chartImage = cartesianChart.GetImage();
canvas.DrawImage(chartImage, new SKPoint(0, 0));
using var data = chartImage.Encode();

x.Item().Image(data.AsSpan().ToArray());
});

page.Footer()
Expand Down
2 changes: 2 additions & 0 deletions samples/UWPSample/Axes/Shared/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
Grid.Row="0"
Series="{Binding SeriesCollection1}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
<lvc:CartesianChart
Grid.Row="1"
Series="{Binding SeriesCollection2}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion samples/UWPSample/Lines/Basic/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart Series="{Binding Series}"/>
<lvc:CartesianChart Series="{Binding Series}" Title="{Binding Title}" />
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
Grid.Row="0"
Series="{Binding SeriesCollection1}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
<lvc:CartesianChart
Grid.Row="1"
Series="{Binding SeriesCollection2}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart Series="{Binding Series}"/>
<lvc:CartesianChart Series="{Binding Series}" Title="{Binding Title}" />
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
Grid.Row="0"
Series="{Binding SeriesCollection1}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
<lvc:CartesianChart
Grid.Row="1"
Series="{Binding SeriesCollection2}"
XAxes="{Binding SharedXAxis}"
DrawMargin="{Binding DrawMargin}"
ZoomMode="X">
</lvc:CartesianChart>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart Series="{Binding Series}"/>
<lvc:CartesianChart Series="{Binding Series}" Title="{Binding Title}"/>
</UserControl>
8 changes: 7 additions & 1 deletion samples/ViewModelsSamples/Axes/LabelsFormat/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public partial class ViewModel
new Axis
{
Name = "Salesman/woman",
NamePaint = new SolidColorPaint { Color = SKColors.Red },
// Use the labels property for named or static labels // mark
Labels = new string[] { "Sergio", "Lando", "Lewis" }, // mark
LabelsRotation = 15
Expand All @@ -34,6 +33,13 @@ public partial class ViewModel
Name = "Sales amount",
NamePadding = new LiveChartsCore.Drawing.Padding(0, 15),

LabelsPaint = new SolidColorPaint
{
Color = SKColors.Blue,
FontFamily = "Times New Roman",
SKFontStyle = new SKFontStyle(SKFontStyleWeight.ExtraBold, SKFontStyleWidth.Normal, SKFontStyleSlant.Italic)
},

// Use the Labeler property to give format to the axis values // mark
// Now the Y axis we will display it as currency
// LiveCharts provides some common formatters
Expand Down
27 changes: 16 additions & 11 deletions samples/ViewModelsSamples/Axes/LabelsFormat2/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ public partial class ViewModel
new Axis
{
Name = "Salesman/woman",
NamePaint = new SolidColorPaint { Color = SKColors.Red },
//Labels = new string[] { "王", "赵", "张" },
Labels = new string[] { "سرجیو", "لاندو", "لوئیس" },
Labels = new string[] { "王", "赵", "张" },
LabelsPaint = new SolidColorPaint
{
Color = SKColors.Black,
// you need to enable the Chinease characters for SkiaSharp
// Livecharts provides the MatchChar() function that relays on the
// SKFontManager.Default.MatchCharacter() SkiaSharp function.
//FontFamily = LiveChartsSkiaSharp.MatchChar('汉') // 汉语 // mark
FontFamily = LiveChartsSkiaSharp.MatchChar('أ'), // Arab
//FontFamily = LiveChartsSkiaSharp.MatchChar('あ'), // Japanease
//FontFamily = LiveChartsSkiaSharp.MatchChar('Ж'), // Russian

// you need to enable the Chinese characters for SkiaSharp
// use the SKFontManager.Default.MatchCharacter() SkiaSharp function.

SKTypeface = SKFontManager.Default.MatchCharacter('汉') // 汉语 // mark
// SKTypeface = SKFontManager.Default.MatchCharacter('أ'), // Arab
// SKTypeface = SKFontManager.Default.MatchCharacter('あ'), // Japanese
// SKTypeface = SKFontManager.Default.MatchCharacter('Ж'), // Russian
}
}
};
Expand All @@ -43,7 +42,13 @@ public partial class ViewModel
{
Name = "Sales amount",
NamePadding = new LiveChartsCore.Drawing.Padding(0, 15),
Labeler = Labelers.Currency
Labeler = Labelers.Currency,
LabelsPaint = new SolidColorPaint
{
Color = SKColors.Blue,
FontFamily = "Times New Roman",
SKFontStyle = new SKFontStyle(SKFontStyleWeight.ExtraBold, SKFontStyleWidth.Normal, SKFontStyleSlant.Italic)
},
}
};
}
27 changes: 26 additions & 1 deletion samples/ViewModelsSamples/Axes/Shared/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.Measure;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.SKCharts;

namespace ViewModelsSamples.Axes.Shared;

Expand All @@ -21,7 +24,7 @@ public ViewModel()
t += r.Next(-90, 100);
values1[i] = t;

t2 += r.Next(-90, 100);
t2 += r.Next(-9000, 10000);
values2[i] = t2;
}

Expand All @@ -30,9 +33,31 @@ public ViewModel()

// sharing the same instance for both charts will keep the zooming and panning synced // mark
SharedXAxis = new Axis[] { new Axis() };

// Force the chart to use 70px margin on the left, this way we can align both charts. // mark
DrawMargin = new Margin(70, Margin.Auto, Margin.Auto, Margin.Auto);
// and thats it!

// Advanced alternative:
// you can also ask an axis its posible dimensions to determine the margin you need.

// First you need to get a chart from the UI
// in this sample we use the in-memory chart provided by the library.

// var cartesianChart = new SKCartesianChart();
// var axis = cartesianChart.YAxes.First() as Axis;
// var size = axis.GetPossibleSize(cartesianChart.Core);

// finally instead of using the static 70px, we can use the actual width of the axis.

// DrawMargin = new Margin(size.Width, Margin.Auto, Margin.Auto, Margin.Auto);

// normally you would need measure all the axes involved, and use the greater width to
// calculate the required margin.
}

public ISeries[] SeriesCollection1 { get; set; }
public ISeries[] SeriesCollection2 { get; set; }
public Axis[] SharedXAxis { get; set; }
public Margin DrawMargin { get; set; }
}
Loading

0 comments on commit 30cfa86

Please sign in to comment.