Skip to content

Commit

Permalink
Merge pull request #599 from beto-rodriguez/axes-features
Browse files Browse the repository at this point in the history
Adds missing visual features to the Axis class.
  • Loading branch information
beto-rodriguez authored Aug 27, 2022
2 parents 8c2ea38 + a0dd7bb commit 6f7f1b2
Show file tree
Hide file tree
Showing 18 changed files with 713 additions and 316 deletions.
8 changes: 6 additions & 2 deletions samples/AvaloniaSample/Axes/Style/View.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:vms="using:ViewModelsSamples.Axes.Style">
xmlns:vms="using:ViewModelsSamples.Axes.Style"
Background="#333333">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</UserControl>
16 changes: 10 additions & 6 deletions samples/BlazorSample/Pages/Axes/Style.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
@using LiveChartsCore.SkiaSharpView.Blazor
@using ViewModelsSamples.Axes.Style

<CartesianChart
Series="ViewModel.Series"
XAxes="ViewModel.XAxes"
YAxes="ViewModel.YAxes"
DrawMarginFrame="ViewModel.Frame">
</CartesianChart>
<div style="background-color: #333333; padding: 20px">
<CartesianChart
Series="ViewModel.Series"
XAxes="ViewModel.XAxes"
YAxes="ViewModel.YAxes"
DrawMarginFrame="ViewModel.Frame"
ZoomMode="LiveChartsCore.Measure.ZoomAndPanMode.Both"
TooltipPosition="LiveChartsCore.Measure.TooltipPosition.Hidden">
</CartesianChart>
</div>

@code {
public ViewModel ViewModel { get; set; } = new();
Expand Down
3 changes: 3 additions & 0 deletions samples/EtoFormsSample/Axes/Style/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class View : Panel

public View()
{
BackgroundColor = new Eto.Drawing.Color(60, 60, 60);
var viewModel = new ViewModel();

cartesianChart = new CartesianChart
Expand All @@ -18,6 +19,8 @@ public View()
XAxes = viewModel.XAxes,
YAxes = viewModel.YAxes,
DrawMarginFrame = viewModel.Frame,
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.Both,
TooltipPosition = LiveChartsCore.Measure.TooltipPosition.Hidden
};

Content = cartesianChart;
Expand Down
5 changes: 4 additions & 1 deletion samples/MauiSample/Axes/Style/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</ContentPage>
17 changes: 11 additions & 6 deletions samples/UWPSample/Axes/Style/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
</lvc:CartesianChart>
<Grid Background="#333333">
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
</lvc:CartesianChart>
<Grid Background="#333333">
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
</lvc:CartesianChart>
<Grid Background="#333333">
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</Grid>
</UserControl>
104 changes: 82 additions & 22 deletions samples/ViewModelsSamples/Axes/Style/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.Generic;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.Painting.Effects;
Expand All @@ -10,11 +12,17 @@ namespace ViewModelsSamples.Axes.Style;
[ObservableObject]
public partial class ViewModel
{
private static readonly SKColor s_gray = new(195, 195, 195);
private static readonly SKColor s_gray1 = new(160, 160, 160);
private static readonly SKColor s_gray2 = new(90, 90, 90);
private static readonly SKColor s_dark3 = new(60, 60, 60);

public ISeries[] Series { get; set; } =
{
new LineSeries<int>
new LineSeries<ObservablePoint>
{
Values = new int[] { 5, 3, 2, 8, 7, 4, 5, 4, 6, 7, 5 },
Values = Fetch(),
Stroke = new SolidColorPaint(new SKColor(33, 150, 243), 4),
Fill = null,
GeometrySize = 0
}
Expand All @@ -24,15 +32,36 @@ public partial class ViewModel
{
new Axis
{
MinLimit = 0,
MaxLimit = 10,
ForceStepToMin = true,
MinStep = 0.5,
TextSize = 14,
Name = "X axis",
NamePaint = new SolidColorPaint(s_gray1),
TextSize = 18,
Padding = new LiveChartsCore.Drawing.Padding(5, 15, 5, 5),
LabelsPaint = new SolidColorPaint(s_gray),
SeparatorsPaint = new SolidColorPaint
{
Color = SKColors.Gray,
Color = s_gray,
StrokeThickness = 1,
PathEffect = new DashEffect(new float[] { 3, 3 })
},
SubseparatorsPaint = new SolidColorPaint
{
Color = s_gray2,
StrokeThickness = 0.5f
},
ZeroPaint = new SolidColorPaint
{
Color = s_gray1,
StrokeThickness = 2
},
TicksPaint = new SolidColorPaint
{
Color = s_gray,
StrokeThickness = 1.5f
},
SubticksPaint = new SolidColorPaint
{
Color = s_gray,
StrokeThickness = 1
}
}
};
Expand All @@ -41,31 +70,62 @@ public partial class ViewModel
{
new Axis
{
MinLimit = 0,
MaxLimit = 10,
ForceStepToMin = true,
MinStep = 1,
TextSize = 14,
Name = "Y axis",
NamePaint = new SolidColorPaint(s_gray1),
TextSize = 18,
Padding = new LiveChartsCore.Drawing.Padding(5, 0, 15, 0),
LabelsPaint = new SolidColorPaint(s_gray),
SeparatorsPaint = new SolidColorPaint
{
Color = SKColors.Gray,
StrokeThickness = 2,
Color = s_gray,
StrokeThickness = 1,
PathEffect = new DashEffect(new float[] { 3, 3 })
},
SubseparatorsPaint = new SolidColorPaint
{
Color = s_gray2,
StrokeThickness = 0.5f
},
ZeroPaint = new SolidColorPaint
{
Color = s_gray1,
StrokeThickness = 2
},
TicksPaint = new SolidColorPaint
{
Color = s_gray,
StrokeThickness = 1.5f
},
SubticksPaint = new SolidColorPaint
{
Color = s_gray,
StrokeThickness = 1
}
}
};

public DrawMarginFrame Frame { get; set; } =
new()
{
Fill = new SolidColorPaint
{
Color = new SKColor(0, 0, 0, 30)
},
Fill = new SolidColorPaint(s_dark3),
Stroke = new SolidColorPaint
{
Color = new SKColor(80, 80, 80),
StrokeThickness = 2
Color = s_gray,
StrokeThickness = 1
}
};

private static List<ObservablePoint> Fetch()
{
var list = new List<ObservablePoint>();
var fx = EasingFunctions.BounceInOut;

for (var x = 0f; x < 1f; x += 0.001f)
{
var y = fx(x);
list.Add(new ObservablePoint(x - 0.5, y - 0.5));
}

return list;
}
}
8 changes: 6 additions & 2 deletions samples/WPFSample/Axes/Style/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.Style;assembly=ViewModelsSamples">
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.Style;assembly=ViewModelsSamples"
Background="#333333">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</UserControl>
6 changes: 5 additions & 1 deletion samples/WinFormsSample/Axes/Style/View.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Forms;
using System.Drawing;
using System.Windows.Forms;
using LiveChartsCore.SkiaSharpView.WinForms;
using ViewModelsSamples.Axes.Style;

Expand All @@ -12,6 +13,7 @@ public View()
{
InitializeComponent();
Size = new System.Drawing.Size(100, 100);
BackColor = Color.FromArgb(255, 50, 50, 50);

var viewModel = new ViewModel();

Expand All @@ -21,6 +23,8 @@ public View()
XAxes = viewModel.XAxes,
YAxes = viewModel.YAxes,
DrawMarginFrame = viewModel.Frame,
ZoomMode = LiveChartsCore.Measure.ZoomAndPanMode.Both,
TooltipPosition = LiveChartsCore.Measure.TooltipPosition.Hidden,

// out of livecharts properties...
Location = new System.Drawing.Point(0, 0),
Expand Down
16 changes: 10 additions & 6 deletions samples/WinUISample/WinUISample/Axes/Style/View.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
</lvc:CartesianChart>
<Grid Background="#333333">
<lvc:CartesianChart
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}"
TooltipPosition="Hidden"
ZoomMode="Both">
</lvc:CartesianChart>
</Grid>
</UserControl>

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 @@ -3,14 +3,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinSample.Axes.Style.View"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Xamarin.Forms;assembly=LiveChartsCore.SkiaSharpView.XamarinForms"
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.Style;assembly=ViewModelsSamples">
xmlns:vms="clr-namespace:ViewModelsSamples.Axes.Style;assembly=ViewModelsSamples"
Background="#333333">
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:CartesianChart
Margin="20"
Series="{Binding Series}"
XAxes="{Binding XAxes}"
YAxes="{Binding YAxes}"
DrawMarginFrame="{Binding Frame}">
DrawMarginFrame="{Binding Frame}"
ZoomMode="Both"
TooltipPosition="Hidden">
</lvc:CartesianChart>
</ContentPage>
Loading

0 comments on commit 6f7f1b2

Please sign in to comment.