main
syneffort 1 year ago
parent 939e9e96c7
commit d0432955c5
  1. 20
      LC_Tutorial/Tutorial/BasicPlots/BubbleWindow.xaml
  2. 91
      LC_Tutorial/Tutorial/BasicPlots/BubbleWindow.xaml.cs
  3. 1
      LC_Tutorial/Tutorial/MainWindow.xaml
  4. 6
      LC_Tutorial/Tutorial/MainWindow.xaml.cs

@ -0,0 +1,20 @@
<Window x:Class="Tutorial.BasicPlots.BubbleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Tutorial.BasicPlots"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
Title="BubbleWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<lvc:CartesianChart Grid.Row="0" Series="{Binding SeriesCollection}" LegendLocation="Top"/>
<Button x:Name="btnUpdate" Grid.Row="1" Content="Update" Click="btnUpdate_Click"/>
</Grid>
</Window>

@ -0,0 +1,91 @@
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
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.Shapes;
namespace Tutorial.BasicPlots
{
/// <summary>
/// BubbleWindow.xaml에 대한 상호 작용 논리
/// </summary>
public partial class BubbleWindow : Window
{
public SeriesCollection SeriesCollection { get; set; }
public BubbleWindow()
{
InitializeComponent();
InitInstance();
}
private void InitInstance()
{
SeriesCollection = new SeriesCollection()
{
new ScatterSeries()
{
Values = new ChartValues<ScatterPoint>
{
new ScatterPoint(5, 5, 20),
new ScatterPoint(3, 4, 80),
new ScatterPoint(7, 2, 20),
new ScatterPoint(2, 6, 60),
new ScatterPoint(8, 2, 70)
},
MinPointShapeDiameter = 15,
MaxPointShapeDiameter = 45
},
new ScatterSeries
{
Values = new ChartValues<ScatterPoint>
{
new ScatterPoint(7, 5, 1),
new ScatterPoint(2, 2, 1),
new ScatterPoint(1, 1, 1),
new ScatterPoint(6, 3, 1),
new ScatterPoint(8, 8, 1)
},
PointGeometry = DefaultGeometries.Triangle,
MinPointShapeDiameter = 15,
MaxPointShapeDiameter = 45
}
};
DataContext = this;
}
private void btnUpdate_Click(object sender, RoutedEventArgs e)
{
Random rand = new Random();
foreach (var series in SeriesCollection.Cast<ScatterSeries>())
{
foreach (var bubble in series.Values.Cast<ScatterPoint>())
{
bubble.X = rand.NextDouble() * 10;
bubble.Y = rand.NextDouble() * 10;
bubble.Weight = rand.NextDouble() * 10;
}
}
foreach (var series in SeriesCollection.Cast<ScatterSeries>())
{
for (int i = 0; i < 10; i++)
{
series.Values.Add(new ScatterPoint(rand.NextDouble() * 10, rand.NextDouble() * 10, rand.NextDouble() * 10));
}
}
}
}
}

@ -19,6 +19,7 @@
<Button x:Name="btnStackedArea" Content="Stacked Area" Margin="3" Click="btnStackedArea_Click"/>
<Button x:Name="btnStepLine" Content="Step Line" Margin="3" Click="btnStepLine_Click"/>
<Button x:Name="btnScatter" Content="Scatter" Margin="3" Click="btnScatter_Click"/>
<Button x:Name="btnBubble" Content="Bubble" Margin="3" Click="btnBubble_Click"/>
</StackPanel>
</Grid>
</Window>

@ -67,5 +67,11 @@ namespace Tutorial
ScatterWindow win = new ScatterWindow();
win.Show();
}
private void btnBubble_Click(object sender, RoutedEventArgs e)
{
BubbleWindow win = new BubbleWindow();
win.Show();
}
}
}

Loading…
Cancel
Save