Skip to content

Commit

Permalink
add outlabels sample
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Sep 12, 2023
1 parent c90b43e commit fa19edd
Show file tree
Hide file tree
Showing 22 changed files with 416 additions and 0 deletions.
16 changes: 16 additions & 0 deletions samples/AvaloniaSample/Pies/OutLabels/View.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


<UserControl x:Class="AvaloniaSample.Pies.OutLabels.View"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lv="clr-namespace:LiveChartsCore;assembly=LiveChartsCore"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Avalonia"
xmlns:vms="using:ViewModelsSamples.Pies.OutLabels">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PieChart Series="{Binding Series}"
IsClockwise="False"
InitialRotation="-90">
</lvc:PieChart>
</UserControl>
17 changes: 17 additions & 0 deletions samples/AvaloniaSample/Pies/OutLabels/View.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace AvaloniaSample.Pies.OutLabels;

public partial class View : UserControl
{
public View()
{
InitializeComponent();
}

private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
13 changes: 13 additions & 0 deletions samples/BlazorSample/Pages/Pies/OutLabels.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@page "/Pies/OutLabels"
@using LiveChartsCore.SkiaSharpView.Blazor
@using ViewModelsSamples.Pies.OutLabels

<PieChart
Series="ViewModel.Series"
IsClockwise="false"
InitialRotation="-90">
</PieChart>

@code {
public ViewModel ViewModel { get; set; } = new();
}
24 changes: 24 additions & 0 deletions samples/EtoFormsSample/Pies/OutLabels/View.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Eto.Forms;
using LiveChartsCore.SkiaSharpView.Eto;
using ViewModelsSamples.Pies.OutLabels;

namespace EtoFormsSample.Pies.OutLabels;

public class View : Panel
{
private readonly PieChart pieChart;

public View()
{
var viewModel = new ViewModel();

pieChart = new PieChart
{
Series = viewModel.Series,
IsClockwise = false,
InitialRotation = -90
};

Content = pieChart;
}
}
16 changes: 16 additions & 0 deletions samples/MauiSample/Pies/OutLabels/View.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="MauiSample.Pies.OutLabels.View"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Maui;assembly=LiveChartsCore.SkiaSharpView.Maui"
xmlns:vms="clr-namespace:ViewModelsSamples.Pies.OutLabels;assembly=ViewModelsSamples"
>
<ContentPage.BindingContext>
<vms:ViewModel/>
</ContentPage.BindingContext>
<lvc:PieChart
Series="{Binding Series}"
IsClockwise="False"
InitialRotation="-90">
</lvc:PieChart>
</ContentPage>
10 changes: 10 additions & 0 deletions samples/MauiSample/Pies/OutLabels/View.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace MauiSample.Pies.OutLabels;

[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class View : ContentPage
{
public View()
{
InitializeComponent();
}
}
17 changes: 17 additions & 0 deletions samples/UWPSample/Pies/OutLabels/View.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<UserControl x:Class="UWPSample.Pies.OutLabels.View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.Uno"
xmlns:vms="using:ViewModelsSamples.Pies.OutLabels"
mc:Ignorable="d">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PieChart
Series="{Binding Series}"
IsClockwise="False"
InitialRotation="-90">
</lvc:PieChart>
</UserControl>
12 changes: 12 additions & 0 deletions samples/UWPSample/Pies/OutLabels/View.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Windows.UI.Xaml.Controls;

namespace UWPSample.Pies.OutLabels
{
public sealed partial class View : UserControl
{
public View()
{
InitializeComponent();
}
}
}
7 changes: 7 additions & 0 deletions samples/UWPSample/UWPSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@
<Compile Include="Pies\AutoUpdate\View.xaml.cs">
<DependentUpon>View.xaml</DependentUpon>
</Compile>
<Compile Include="Pies\OutLabels\View.xaml.cs">
<DependentUpon>View.xaml</DependentUpon>
</Compile>
<Compile Include="Pies\Basic\View.xaml.cs">
<DependentUpon>View.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -686,6 +689,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Pies\OutLabels\View.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Pies\Basic\View.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<UserControl x:Class="UnoWinUISample.Pies.OutLabels.View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="using:LiveChartsCore.SkiaSharpView.WinUI"
xmlns:vms="using:ViewModelsSamples.Pies.OutLabels"
mc:Ignorable="d">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PieChart
Series="{Binding Series}"
IsClockwise="False"
InitialRotation="-90">
</lvc:PieChart>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Microsoft.UI.Xaml.Controls;

namespace UnoWinUISample.Pies.OutLabels;

public sealed partial class View : UserControl
{
public View()
{
InitializeComponent();
}
}
1 change: 1 addition & 0 deletions samples/ViewModelsSamples/Index.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static class Index
"Pies/Doughnut",
"Pies/Pushout",
"Pies/Custom",
"Pies/OutLabels",
"Pies/NightingaleRose",
"Pies/Gauges",
//"Pies/Gauge",
Expand Down
28 changes: 28 additions & 0 deletions samples/ViewModelsSamples/Pies/OutLabels/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using LiveChartsCore;
using CommunityToolkit.Mvvm.ComponentModel;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;
using LiveChartsCore.SkiaSharpView.Extensions;
using System;

namespace ViewModelsSamples.Pies.OutLabels;

public partial class ViewModel : ObservableObject
{
public IEnumerable<ISeries> Series { get; set; } =
new[] { 8, 6, 5, 3, 3 }.AsPieSeries((value, series) =>
{
series.DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Outer; // mark
series.DataLabelsSize = 15;
series.DataLabelsPaint = new SolidColorPaint(new SKColor(30, 30, 30));
series.DataLabelsFormatter =
point =>
$"This slide takes{Environment.NewLine}" +
$"{point.Coordinate.PrimaryValue} out of {point.StackedValue!.Total} parts";
});

// add some margin to the chart so the labels can be drawn // mark
public LiveChartsCore.Measure.Margin DrawMargin { get; set; } =
new LiveChartsCore.Measure.Margin(0);
}
14 changes: 14 additions & 0 deletions samples/WPFSample/Pies/OutLabels/View.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<UserControl x:Class="WPFSample.Pies.OutLabels.View"
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.Pies.OutLabels;assembly=ViewModelsSamples">
<UserControl.DataContext>
<vms:ViewModel/>
</UserControl.DataContext>
<lvc:PieChart
Series="{Binding Series}"
IsClockwise="False"
InitialRotation="-90">
</lvc:PieChart>
</UserControl>
14 changes: 14 additions & 0 deletions samples/WPFSample/Pies/OutLabels/View.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Windows.Controls;

namespace WPFSample.Pies.OutLabels;

/// <summary>
/// Interaction logic for View.xaml
/// </summary>
public partial class View : UserControl
{
public View()
{
InitializeComponent();
}
}
46 changes: 46 additions & 0 deletions samples/WinFormsSample/Pies/OutLabels/View.Designer.cs

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

32 changes: 32 additions & 0 deletions samples/WinFormsSample/Pies/OutLabels/View.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Windows.Forms;
using LiveChartsCore.SkiaSharpView.WinForms;
using ViewModelsSamples.Pies.OutLabels;

namespace WinFormsSample.Pies.OutLabels;

public partial class View : UserControl
{
private readonly PieChart pieChart;

public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);

var viewModel = new ViewModel();

pieChart = new PieChart
{
Series = viewModel.Series,
IsClockwise = false,
InitialRotation = -90,

// out of livecharts properties...
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};

Controls.Add(pieChart);
}
}
60 changes: 60 additions & 0 deletions samples/WinFormsSample/Pies/OutLabels/View.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Loading

0 comments on commit fa19edd

Please sign in to comment.