项目结构调整

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,21 @@
<UserControl x:Class="Wpf.CartesianChart.Basic_Stacked_Bar.BasicStackedColumnExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<lvc:CartesianChart Series="{Binding SeriesCollection}" LegendLocation="Bottom">
<lvc:CartesianChart.AxisX>
<lvc:Axis Title="Browser"
Labels="{Binding Labels}"
Separator="{x:Static lvc:DefaultAxes.CleanSeparator}" />
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="Usage" LabelFormatter="{Binding Formatter}"></lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,54 @@
using System;
using System.Windows.Controls;
using LiveCharts;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.Basic_Stacked_Bar
{
/// <summary>
/// Interaction logic for StackedColumnExample.xaml
/// </summary>
public partial class BasicStackedColumnExample : UserControl
{
public BasicStackedColumnExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new StackedColumnSeries
{
Values = new ChartValues<double> {4, 5, 6, 8},
StackMode = StackMode.Values, // this is not necessary, values is the default stack mode
DataLabels = true
},
new StackedColumnSeries
{
Values = new ChartValues<double> {2, 5, 6, 7},
StackMode = StackMode.Values,
DataLabels = true
}
};
//adding series updates and animates the chart
SeriesCollection.Add(new StackedColumnSeries
{
Values = new ChartValues<double> {6, 2, 7},
StackMode = StackMode.Values
});
//adding values also updates and animates
SeriesCollection[2].Values.Add(4d);
Labels = new[] {"Chrome", "Mozilla", "Opera", "IE"};
Formatter = value => value + " Mill";
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels { get; set; }
public Func<double, string> Formatter { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
<UserControl x:Class="Wpf.CartesianChart.Basic_Stacked_Bar.BasicStackedRowPercentageExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wpf.CartesianChart.Basic_Stacked_Bar"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<lvc:CartesianChart Series="{Binding SeriesCollection}" LegendLocation="Top">
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="Browser" Labels="{Binding Labels}" />
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding Formatter}" />
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip SelectionMode="SharedYValues"></lvc:DefaultTooltip>
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,58 @@
using System;
using System.Windows.Controls;
using LiveCharts;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.Basic_Stacked_Bar
{
/// <summary>
/// Interaction logic for BasicStackedRowPercentageExample.xaml
/// </summary>
public partial class BasicStackedRowPercentageExample : UserControl
{
public BasicStackedRowPercentageExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new StackedRowSeries
{
Values = new ChartValues<double> {4, 5, 6, 8},
StackMode = StackMode.Percentage,
DataLabels = true,
LabelPoint = p => p.X.ToString()
},
new StackedRowSeries
{
Values = new ChartValues<double> {2, 5, 6, 7},
StackMode = StackMode.Percentage,
DataLabels = true,
LabelPoint = p => p.X.ToString()
}
};
//adding series updates and animates the chart
SeriesCollection.Add(new StackedRowSeries
{
Values = new ChartValues<double> { 6, 2, 7 },
StackMode = StackMode.Percentage,
DataLabels = true,
LabelPoint = p => p.X.ToString()
});
//adding values also updates and animates
SeriesCollection[2].Values.Add(4d);
Labels = new[] { "Chrome", "Mozilla", "Opera", "IE" };
Formatter = val => val.ToString("P");
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels { get; set; }
public Func<double, string> Formatter { get; set; }
}
}