项目结构调整

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,31 @@
<UserControl x:Class="Wpf.CartesianChart.ScatterPlot.ScatterExample"
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.ScatterPlot"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance local:ScatterExample}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="0" Margin="10" Click="RandomizeOnClick">Randomize</Button>
<lvc:CartesianChart Grid.Row="1" LegendLocation="Bottom">
<lvc:CartesianChart.Series>
<lvc:ScatterSeries Title="Series A" Values="{Binding ValuesA}" />
<lvc:ScatterSeries Title="Series B" Values="{Binding ValuesB}"
PointGeometry="{x:Static lvc:DefaultGeometries.Diamond}" />
<lvc:ScatterSeries Title="Series C" Values="{Binding ValuesC}"
PointGeometry="{x:Static lvc:DefaultGeometries.Triangle}"
StrokeThickness="2" Fill="Transparent"/>
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisY>
<!--setting the axis unit improved the labels rounding rule-->
<lvc:Axis Unit="1"></lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,51 @@
using System;
using System.Windows;
using System.Windows.Controls;
using LiveCharts;
using LiveCharts.Defaults;
namespace Wpf.CartesianChart.ScatterPlot
{
/// <summary>
/// Interaction logic for ScatterExample.xaml
/// </summary>
public partial class ScatterExample : UserControl
{
public ScatterExample()
{
InitializeComponent();
var r = new Random();
ValuesA = new ChartValues<ObservablePoint>();
ValuesB = new ChartValues<ObservablePoint>();
ValuesC = new ChartValues<ObservablePoint>();
for (var i = 0; i < 20; i++)
{
ValuesA.Add(new ObservablePoint(r.NextDouble()*10, r.NextDouble()*10));
ValuesB.Add(new ObservablePoint(r.NextDouble()*10, r.NextDouble()*10));
ValuesC.Add(new ObservablePoint(r.NextDouble()*10, r.NextDouble()*10));
}
DataContext = this;
}
public ChartValues<ObservablePoint> ValuesA { get; set; }
public ChartValues<ObservablePoint> ValuesB { get; set; }
public ChartValues<ObservablePoint> ValuesC { get; set; }
private void RandomizeOnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
for (var i = 0; i < 20; i++)
{
ValuesA[i].X = r.NextDouble()*10;
ValuesA[i].Y = r.NextDouble()*10;
ValuesB[i].X = r.NextDouble()*10;
ValuesB[i].Y = r.NextDouble()*10;
ValuesC[i].X = r.NextDouble()*10;
ValuesC[i].Y = r.NextDouble()*10;
}
}
}
}