mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-11 03:36:38 +08:00
项目结构调整
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<Page
|
||||
x:Class="UWP.CartesianChart.MixingSeries.MixingSeries"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:UWP.CartesianChart.MixingSeries"
|
||||
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="#303030">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" TextWrapping="Wrap">
|
||||
Yes you can mix any series supported by a cartesian chart, just add the series and the chart wll handle it, charts are smart enough to scale according to the contained series.
|
||||
In this case we will only use ObservableClasses, so the chart updates automatically when a property changes, there are already some observable classes defined in thsi library, you
|
||||
can also build your own
|
||||
<Hyperlink NavigateUri="http://lvcharts.net/#/examples/v1/iocp-wpf?path=WPF-Observable">
|
||||
here
|
||||
</Hyperlink>
|
||||
is an example
|
||||
</TextBlock>
|
||||
<Button Grid.Row="1" Margin="7" Click="UpdateAllOnClick">Click me to update all points</Button>
|
||||
<lvc:CartesianChart Grid.Row="2" Series="{Binding SeriesCollection}"
|
||||
Background="#303030">
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis>
|
||||
<lvc:Axis.Separator>
|
||||
<lvc:Separator Stroke="#606060"></lvc:Separator>
|
||||
</lvc:Axis.Separator>
|
||||
</lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -0,0 +1,93 @@
|
||||
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.MixingSeries
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MixingSeries : Page
|
||||
{
|
||||
public MixingSeries()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
LineSeries = new LineSeries
|
||||
{
|
||||
Values = new ChartValues<ObservableValue>
|
||||
{
|
||||
new ObservableValue(5),
|
||||
new ObservableValue(7),
|
||||
new ObservableValue(2),
|
||||
new ObservableValue(3),
|
||||
},
|
||||
AreaLimit = 0
|
||||
};
|
||||
|
||||
ScatterSeries = new ScatterSeries
|
||||
{
|
||||
Values = new ChartValues<ScatterPoint>
|
||||
{
|
||||
new ScatterPoint(0, 2, 10),
|
||||
new ScatterPoint(1, 1, 2),
|
||||
new ScatterPoint(2, 3, 7),
|
||||
new ScatterPoint(3, 4, 9)
|
||||
}
|
||||
};
|
||||
|
||||
ColumnSeries = new ColumnSeries
|
||||
{
|
||||
Values = new ChartValues<ObservableValue>
|
||||
{
|
||||
new ObservableValue(5),
|
||||
new ObservableValue(7),
|
||||
new ObservableValue(2),
|
||||
new ObservableValue(3),
|
||||
}
|
||||
};
|
||||
|
||||
SeriesCollection = new SeriesCollection
|
||||
{
|
||||
LineSeries,
|
||||
ScatterSeries,
|
||||
ColumnSeries
|
||||
};
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public ScatterSeries ScatterSeries { get; set; }
|
||||
public LineSeries LineSeries { get; set; }
|
||||
public ColumnSeries ColumnSeries { get; set; }
|
||||
public SeriesCollection SeriesCollection { get; set; }
|
||||
|
||||
private void UpdateAllOnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var r = new Random();
|
||||
|
||||
foreach (var value in LineSeries.Values.Cast<ObservableValue>())
|
||||
{
|
||||
value.Value = r.Next(-20, 20);
|
||||
}
|
||||
foreach (var value in ColumnSeries.Values.Cast<ObservableValue>())
|
||||
{
|
||||
value.Value = r.Next(-20, 20);
|
||||
}
|
||||
var i = 0;
|
||||
foreach (var value in ScatterSeries.Values.Cast<ScatterPoint>())
|
||||
{
|
||||
value.X = i;
|
||||
value.Y = r.Next(-20, 20);
|
||||
value.Weight = r.Next(-20, 20);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user