项目结构调整

This commit is contained in:
艾竹
2023-04-16 20:11:40 +08:00
parent cbfbf96033
commit 81f91f3f35
2124 changed files with 218 additions and 5516 deletions

View File

@@ -0,0 +1,47 @@
<Page
x:Class="UWP.PieChart.DoughnutChartExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWP.PieChart"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="using:LiveCharts.Uwp"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Button Height="30" Click="UpdateAllOnClick" Padding="10 0">
Move All
</Button>
<Button Height="30" Click="RestartOnClick">Restart</Button>
<TextBlock VerticalAlignment="Center" Padding="10 0">Series</TextBlock>
<Button Height="30" Click="AddSeriesOnClick" MinWidth="30">
+
</Button>
<Button Height="30" Click="RemoveSeriesOnClick" MinWidth="30">
-
</Button>
<TextBlock VerticalAlignment="Center" Padding="10 0">Values</TextBlock>
<Button Height="30" Click="AddValueOnClick" MinWidth="30">
+
</Button>
<Button Height="30" Click="RemoveValueOnClick" MinWidth="30">
-
</Button>
</StackPanel>
<lvc:PieChart Name="Chart" Grid.Row="1" Series="{Binding SeriesCollection}"
LegendLocation="Right" InnerRadius="100" Margin="0 15">
<lvc:PieChart.ChartLegend>
<lvc:DefaultLegend BulletSize="20"></lvc:DefaultLegend>
</lvc:PieChart.ChartLegend>
<lvc:PieChart.DataTooltip>
<lvc:DefaultTooltip BulletSize="20"></lvc:DefaultTooltip>
</lvc:PieChart.DataTooltip>
</lvc:PieChart>
</Grid>
</Page>

View File

@@ -0,0 +1,129 @@
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Uwp;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace UWP.PieChart
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class DoughnutChartExample : Page
{
public DoughnutChartExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new PieSeries
{
Title = "Chrome",
Values = new ChartValues<ObservableValue> { new ObservableValue(8) },
DataLabels = true
},
new PieSeries
{
Title = "Mozilla",
Values = new ChartValues<ObservableValue> { new ObservableValue(6) },
DataLabels = true
},
new PieSeries
{
Title = "Opera",
Values = new ChartValues<ObservableValue> { new ObservableValue(10) },
DataLabels = true
},
new PieSeries
{
Title = "Explorer",
Values = new ChartValues<ObservableValue> { new ObservableValue(4) },
DataLabels = true
}
};
//adding values or series will update and animate the chart automatically
//SeriesCollection.Add(new PieSeries());
//SeriesCollection[0].Values.Add(5);
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var series in SeriesCollection)
{
foreach (var observable in series.Values.Cast<ObservableValue>())
{
observable.Value = r.Next(0, 10);
}
}
}
private void AddSeriesOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
var c = SeriesCollection.Count > 0 ? SeriesCollection[0].Values.Count : 5;
var vals = new ChartValues<ObservableValue>();
for (var i = 0; i < c; i++)
{
vals.Add(new ObservableValue(r.Next(0, 10)));
}
SeriesCollection.Add(new PieSeries
{
Values = vals
});
}
private void RemoveSeriesOnClick(object sender, RoutedEventArgs e)
{
if (SeriesCollection.Count > 0)
SeriesCollection.RemoveAt(0);
}
private void AddValueOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var series in SeriesCollection)
{
series.Values.Add(new ObservableValue(r.Next(0, 10)));
}
}
private void RemoveValueOnClick(object sender, RoutedEventArgs e)
{
foreach (var series in SeriesCollection)
{
if (series.Values.Count > 0)
series.Values.RemoveAt(0);
}
}
private void RestartOnClick(object sender, RoutedEventArgs e)
{
Chart.Update(true, true);
}
}
}

View File

@@ -0,0 +1,25 @@
<Page
x:Class="UWP.PieChart.PieChartExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWP.PieChart"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lvc="using:LiveCharts.Uwp"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<lvc:PieChart LegendLocation="Bottom">
<lvc:PieChart.Series>
<lvc:PieSeries Title="Maria" Values="{Binding Values1}" DataLabels="True" PushOut="20"
LabelPoint="{Binding PointLabel}"/>
<lvc:PieSeries Title="Charles" Values="{Binding Values2}" DataLabels="True"
LabelPoint="{Binding PointLabel}"/>
<lvc:PieSeries Title="Frida" Values="{Binding Values3}" DataLabels="True"
LabelPoint="{Binding PointLabel}"/>
<lvc:PieSeries Title="Frederic" Values="{Binding Values4}" DataLabels="True"
LabelPoint="{Binding PointLabel}"/>
</lvc:PieChart.Series>
</lvc:PieChart>
</Grid>
</Page>

View File

@@ -0,0 +1,43 @@
using LiveCharts;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace UWP.PieChart
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class PieChartExample : Page
{
public PieChartExample()
{
InitializeComponent();
PointLabel = chartPoint =>
string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
DataContext = this;
}
public Func<ChartPoint, string> PointLabel { get; set; }
public IChartValues Values1 { get; set; } = new ChartValues<int>(new int[] { 3 });
public IChartValues Values2 { get; set; } = new ChartValues<int>(new int[] { 3 });
public IChartValues Values3 { get; set; } = new ChartValues<int>(new int[] { 3 });
public IChartValues Values4 { get; set; } = new ChartValues<int>(new int[] { 3 });
}
}