mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-12 12:16:37 +08:00
项目结构调整
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<Page
|
||||
x:Class="UWP.CartesianChart.Labels.LabelsExample"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:UWP.CartesianChart.Labels"
|
||||
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="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock>Labels</TextBlock>
|
||||
<Button Grid.Row="1" Height="30" Click="UpdateAllOnClick">
|
||||
Move All
|
||||
</Button>
|
||||
<lvc:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}"
|
||||
DataClick="Chart_OnDataClick">
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis LabelsRotation="20" Labels="{Binding Labels}" Position="LeftBottom" >
|
||||
<lvc:Axis.Separator >
|
||||
<lvc:Separator Step="1"></lvc:Separator>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Title="Sold Items" LabelFormatter="{Binding Formatter}" Position="RightTop"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,86 @@
|
||||
using LiveCharts;
|
||||
using LiveCharts.Defaults;
|
||||
using LiveCharts.Uwp;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace UWP.CartesianChart.Labels
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class LabelsExample : Page
|
||||
{
|
||||
public LabelsExample()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SeriesCollection = new SeriesCollection
|
||||
{
|
||||
new ColumnSeries
|
||||
{
|
||||
Values = new ChartValues<ObservableValue>
|
||||
{
|
||||
new ObservableValue(4),
|
||||
new ObservableValue(2),
|
||||
new ObservableValue(8),
|
||||
new ObservableValue(2),
|
||||
new ObservableValue(3),
|
||||
new ObservableValue(0),
|
||||
new ObservableValue(1),
|
||||
},
|
||||
DataLabels = true,
|
||||
LabelPoint = point => point.X + "K ," + point.Y
|
||||
}
|
||||
};
|
||||
|
||||
Labels = new[]
|
||||
{
|
||||
"Shea Ferriera",
|
||||
"Maurita Powel",
|
||||
"Scottie Brogdon",
|
||||
"Teresa Kerman",
|
||||
"Nell Venuti",
|
||||
"Anibal Brothers",
|
||||
"Anderson Dillman"
|
||||
};
|
||||
|
||||
Formatter = value => value + ".00K items";
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public SeriesCollection SeriesCollection { get; set; }
|
||||
public string[] Labels { get; set; }
|
||||
public Func<double, string> Formatter { 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 async void Chart_OnDataClick(object sender, ChartPoint point)
|
||||
{
|
||||
//point instance contains many useful information...
|
||||
//sender is the shape that called the event.
|
||||
var dialog = new MessageDialog("You clicked " + point.X + ", " + point.Y);
|
||||
await dialog.ShowAsync();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<Page
|
||||
x:Class="UWP.CartesianChart.Labels.LabelsHorizontalExample"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:UWP.CartesianChart.Labels"
|
||||
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="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock>Labels</TextBlock>
|
||||
<Button Grid.Row="1" Height="30" Click="UpdateAllOnClick">
|
||||
Move All
|
||||
</Button>
|
||||
<lvc:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}">
|
||||
<lvc:CartesianChart.DataTooltip>
|
||||
<lvc:DefaultTooltip SelectionMode="SharedYValues"></lvc:DefaultTooltip>
|
||||
</lvc:CartesianChart.DataTooltip>
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Title="Sold Items" LabelFormatter="{Binding Formatter}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Labels="{Binding Labels}" LabelsRotation="65">
|
||||
<lvc:Axis.Separator >
|
||||
<lvc:Separator Step="1"></lvc:Separator>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,74 @@
|
||||
using LiveCharts;
|
||||
using LiveCharts.Defaults;
|
||||
using LiveCharts.Uwp;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace UWP.CartesianChart.Labels
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class LabelsHorizontalExample : Page
|
||||
{
|
||||
public LabelsHorizontalExample()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SeriesCollection = new SeriesCollection
|
||||
{
|
||||
new RowSeries
|
||||
{
|
||||
Values = new ChartValues<ObservableValue>
|
||||
{
|
||||
new ObservableValue(4),
|
||||
new ObservableValue(2),
|
||||
new ObservableValue(8),
|
||||
new ObservableValue(2),
|
||||
new ObservableValue(3),
|
||||
new ObservableValue(0),
|
||||
new ObservableValue(1),
|
||||
},
|
||||
DataLabels = true,
|
||||
LabelPoint = point => point.X + "K ," + point.Y
|
||||
}
|
||||
};
|
||||
|
||||
Labels = new[]
|
||||
{
|
||||
"Shea Ferriera",
|
||||
"Maurita Powel",
|
||||
"Scottie Brogdon",
|
||||
"Teresa Kerman",
|
||||
"Nell Venuti",
|
||||
"Anibal Brothers",
|
||||
"Anderson Dillman"
|
||||
};
|
||||
|
||||
Formatter = value => value + ".00K items";
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public SeriesCollection SeriesCollection { get; set; }
|
||||
public string[] Labels { get; set; }
|
||||
public Func<double, string> Formatter { 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user