项目结构调整

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,30 @@
<UserControl x:Class="Wpf.CartesianChart.StackedColumnExample"
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"
xmlns:wpf="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="1" Click="UpdateAllOnClick">
Move All
</Button>
<wpf:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}">
<wpf:CartesianChart.AxisX>
<wpf:Axis Labels="{Binding Labels}">
<wpf:Axis.Separator>
<!--step 1 forces the axis to display all labels, disabling it makes it invisible-->
<wpf:Separator Step="1" IsEnabled="False"></wpf:Separator>
</wpf:Axis.Separator>
</wpf:Axis>
</wpf:CartesianChart.AxisX>
</wpf:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart
{
/// <summary>
/// Interaction logic for StackedBarSeries.xaml
/// </summary>
public partial class StackedColumnExample
{
public StackedColumnExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new StackedColumnSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(5),
new ObservableValue(8),
new ObservableValue(2),
new ObservableValue(4),
new ObservableValue(6),
new ObservableValue(2),
new ObservableValue(9),
new ObservableValue(3)
},
DataLabels = true
},
new StackedColumnSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(7),
new ObservableValue(4),
new ObservableValue(1),
new ObservableValue(7),
new ObservableValue(2),
new ObservableValue(7),
new ObservableValue(0),
new ObservableValue(3)
},
DataLabels = true
},
new StackedColumnSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(6),
new ObservableValue(2),
new ObservableValue(8),
new ObservableValue(2),
new ObservableValue(9),
new ObservableValue(2),
new ObservableValue(3),
new ObservableValue(3)
},
DataLabels = true
}
};
Labels = new[]
{
"Jan", "Feb","Mar", "Apr", "May", "Jun", "Jul", "Ago"
};
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels { get; set; }
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var series in SeriesCollection)
{
foreach (var observableValue in series.Values.Cast<ObservableValue>())
{
observableValue.Value = r.Next(-10, 10);
}
}
}
}
}

View File

@@ -0,0 +1,29 @@
<UserControl x:Class="Wpf.CartesianChart.StackedBar.StackedRowExample"
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:wpf="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="1" Click="UpdateAllOnClick">
Move All
</Button>
<wpf:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}" AxisX="{x:Static wpf:DefaultAxes.DefaultAxis}">
<wpf:CartesianChart.AxisY>
<wpf:Axis Labels="{Binding Labels}">
<wpf:Axis.Separator>
<!--step 1 forces the axis to display all labels, disabling it makes it invisible-->
<wpf:Separator Step="1" IsEnabled="False"></wpf:Separator>
</wpf:Axis.Separator>
</wpf:Axis>
</wpf:CartesianChart.AxisY>
</wpf:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
namespace Wpf.CartesianChart.StackedBar
{
/// <summary>
/// Interaction logic for StackedRowExample.xaml
/// </summary>
public partial class StackedRowExample : UserControl
{
public StackedRowExample()
{
InitializeComponent();
SeriesCollection = new SeriesCollection
{
new StackedRowSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(5),
new ObservableValue(8),
new ObservableValue(2),
new ObservableValue(4),
new ObservableValue(6),
new ObservableValue(2),
new ObservableValue(9),
new ObservableValue(3)
},
DataLabels = true
},
new StackedRowSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(7),
new ObservableValue(4),
new ObservableValue(1),
new ObservableValue(7),
new ObservableValue(2),
new ObservableValue(7),
new ObservableValue(0),
new ObservableValue(3)
},
DataLabels = true
},
new StackedRowSeries
{
Values = new ChartValues<ObservableValue>
{
new ObservableValue(6),
new ObservableValue(2),
new ObservableValue(8),
new ObservableValue(2),
new ObservableValue(9),
new ObservableValue(2),
new ObservableValue(3),
new ObservableValue(3)
},
DataLabels = true
}
};
Labels = new[]
{
"Jan", "Feb","Mar", "Apr", "May", "Jun", "Jul", "Ago"
};
DataContext = this;
}
public SeriesCollection SeriesCollection { get; set; }
public string[] Labels { get; set; }
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var series in SeriesCollection)
{
foreach (var observableValue in series.Values.Cast<ObservableValue>())
{
observableValue.Value = r.Next(-10, 10);
}
}
}
}
}