main
syneffort 1 year ago
parent f385096d7f
commit 79795d676a
  1. 21
      LC_Tutorial/Tutorial/BasicPlots/StepLineWindow.xaml
  2. 63
      LC_Tutorial/Tutorial/BasicPlots/StepLineWindow.xaml.cs
  3. 1
      LC_Tutorial/Tutorial/MainWindow.xaml
  4. 6
      LC_Tutorial/Tutorial/MainWindow.xaml.cs

@ -0,0 +1,21 @@
<Window x:Class="Tutorial.BasicPlots.StepLineWindow"
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="StepLineWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<lvc:CartesianChart Grid.Row="0" Series="{Binding SeriesCollection}" LegendLocation="Right">
</lvc:CartesianChart>
<Button x:Name="btnAdd" Grid.Row="1" Content="Add Series" Click="btnAdd_Click"/>
</Grid>
</Window>

@ -0,0 +1,63 @@
using LiveCharts;
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>
/// StepLineWindow.xaml에 대한 상호 작용 논리
/// </summary>
public partial class StepLineWindow : Window
{
public SeriesCollection SeriesCollection { get; set; }
public StepLineWindow()
{
InitializeComponent();
InitInstance();
}
private void InitInstance()
{
SeriesCollection = new SeriesCollection()
{
new StepLineSeries()
{
Title = "Series 1",
Values = new ChartValues<double> { 9, 6, 5, 7, 8, 9, 7, 6, 7, 5 }
},
new StepLineSeries()
{
Title = "Series 2",
Values = new ChartValues<double> { 1, 4, 3, 1, 4, 2, 1, 2, 3, 5 },
AlternativeStroke = Brushes.Transparent,
StrokeThickness = 3,
PointGeometry = null
}
};
DataContext = this;
}
private void btnAdd_Click(object sender, RoutedEventArgs e)
{
Random rand = new Random();
foreach (var series in SeriesCollection.Cast<StepLineSeries>())
{
series.Values.Add((double)rand.Next(1, 11));
}
}
}
}

@ -17,6 +17,7 @@
<Button x:Name="btnStackedColumns" Content="Stacked Columns" Margin="3" Click="btnStackedColumns_Click"/> <Button x:Name="btnStackedColumns" Content="Stacked Columns" Margin="3" Click="btnStackedColumns_Click"/>
<Button x:Name="btnRows" Content="Rows" Margin="3" Click="btnRows_Click"/> <Button x:Name="btnRows" Content="Rows" Margin="3" Click="btnRows_Click"/>
<Button x:Name="btnStackedArea" Content="Stacked Area" Margin="3" Click="btnStackedArea_Click"/> <Button x:Name="btnStackedArea" Content="Stacked Area" Margin="3" Click="btnStackedArea_Click"/>
<Button x:Name="btnStepLine" Content="Step Line" Margin="3" Click="btnStepLine_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>

@ -55,5 +55,11 @@ namespace Tutorial
StackedAreaWindow win = new StackedAreaWindow(); StackedAreaWindow win = new StackedAreaWindow();
win.Show(); win.Show();
} }
private void btnStepLine_Click(object sender, RoutedEventArgs e)
{
StepLineWindow win = new StepLineWindow();
win.Show();
}
} }
} }

Loading…
Cancel
Save