chart sample

main
syneffort 2 years ago
parent 5ccf800134
commit eb31a46b67
  1. 9
      PacticeSolution/ChartSample/App.xaml
  2. 17
      PacticeSolution/ChartSample/App.xaml.cs
  3. 10
      PacticeSolution/ChartSample/AssemblyInfo.cs
  4. 14
      PacticeSolution/ChartSample/ChartSample.csproj
  5. 35
      PacticeSolution/ChartSample/MainWindow.xaml
  6. 51
      PacticeSolution/ChartSample/MainWindow.xaml.cs
  7. 6
      PacticeSolution/PacticeSolution.sln

@ -0,0 +1,9 @@
<Application x:Class="ChartSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ChartSample"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ChartSample
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
</ItemGroup>
</Project>

@ -0,0 +1,35 @@
<Window x:Class="ChartSample.MainWindow"
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:ChartSample"
xmlns:live="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<!--Code-->
<live:CartesianChart x:Name="chart" Grid.Row="0"
BorderBrush="Red" BorderThickness="2" LegendLocation="Top" Margin="15"/>
<!--Xaml-->
<live:CartesianChart x:Name="xamlChart" Grid.Row="1"
BorderBrush="Red" BorderThickness="2" LegendLocation="Top" Margin="15">
<live:CartesianChart.AxisY>
<live:Axis MinValue="0" MaxValue="1000"/>
</live:CartesianChart.AxisY>
<live:CartesianChart.AxisX>
<live:Axis Labels="1, 2, 3, 4, 5, 6, 7, 8, 9, 10"/>
</live:CartesianChart.AxisX>
<live:CartesianChart.Series>
<live:LineSeries Stroke="Green" Title="Sample1" Values="100, 20, 45, 45, 12, 33, 56, 45, 83, 88"/>
<live:LineSeries Stroke="Red" Title="Sample2" Values="33, 34, 443, 725, 162, 233, 46, 375, 93, 128"/>
</live:CartesianChart.Series>
</live:CartesianChart>
</Grid>
</Window>

@ -0,0 +1,51 @@
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.Navigation;
using System.Windows.Shapes;
namespace ChartSample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
InitInstance();
}
private void InitInstance()
{
chart.LegendLocation = LiveCharts.LegendLocation.Top;
chart.AxisY.Add(new LiveCharts.Wpf.Axis { MinValue = 0, MaxValue = 1000 });
chart.Series.Clear();
chart.Series.Add(new LiveCharts.Wpf.LineSeries()
{
Title = "Sample1",
Stroke = new SolidColorBrush(Colors.Blue),
Values = new LiveCharts.ChartValues<double>(new List<double> { 700, 200, 300, 400, 500, 600, 700, 800, 900, 90 })
});
chart.Series.Add(new LiveCharts.Wpf.LineSeries()
{
Title = "Sample2",
Stroke = new SolidColorBrush(Colors.Gray),
Values = new LiveCharts.ChartValues<double>(new List<double> { 70, 20, 100, 140, 50, 60, 70, 80, 90, 100 })
});
}
}
}

@ -135,6 +135,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TreeViewSample", "TreeViewS
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TriggerAnimations", "TriggerAnimations\TriggerAnimations.csproj", "{9D9FD436-C73C-4DB4-A311-09D2DB65E03E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TriggerAnimations", "TriggerAnimations\TriggerAnimations.csproj", "{9D9FD436-C73C-4DB4-A311-09D2DB65E03E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChartSample", "ChartSample\ChartSample.csproj", "{2052E6D4-43B5-4847-B629-B844E521C807}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -405,6 +407,10 @@ Global
{9D9FD436-C73C-4DB4-A311-09D2DB65E03E}.Debug|Any CPU.Build.0 = Debug|Any CPU {9D9FD436-C73C-4DB4-A311-09D2DB65E03E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D9FD436-C73C-4DB4-A311-09D2DB65E03E}.Release|Any CPU.ActiveCfg = Release|Any CPU {9D9FD436-C73C-4DB4-A311-09D2DB65E03E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D9FD436-C73C-4DB4-A311-09D2DB65E03E}.Release|Any CPU.Build.0 = Release|Any CPU {9D9FD436-C73C-4DB4-A311-09D2DB65E03E}.Release|Any CPU.Build.0 = Release|Any CPU
{2052E6D4-43B5-4847-B629-B844E521C807}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2052E6D4-43B5-4847-B629-B844E521C807}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2052E6D4-43B5-4847-B629-B844E521C807}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2052E6D4-43B5-4847-B629-B844E521C807}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Loading…
Cancel
Save