mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-01 06:36:36 +08:00
添加项目文件。
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="Wpf.CartesianChart.BasicLine.BasicLineExample"
|
||||
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.BasicLine"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid>
|
||||
<lvc:CartesianChart Series="{Binding SeriesCollection}" LegendLocation="Right" >
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Title="Sales" LabelFormatter="{Binding YFormatter}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Title="Month" Labels="{Binding Labels}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using LiveCharts;
|
||||
using LiveCharts.Wpf;
|
||||
|
||||
namespace Wpf.CartesianChart.BasicLine
|
||||
{
|
||||
public partial class BasicLineExample : UserControl
|
||||
{
|
||||
public BasicLineExample()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SeriesCollection = new SeriesCollection
|
||||
{
|
||||
new LineSeries
|
||||
{
|
||||
Title = "Series 1",
|
||||
Values = new ChartValues<double> { 4, 6, 5, 2 ,7 }
|
||||
},
|
||||
new LineSeries
|
||||
{
|
||||
Title = "Series 2",
|
||||
Values = new ChartValues<double> { 6, 7, 3, 4 ,6 }
|
||||
}
|
||||
};
|
||||
|
||||
Labels = new[] {"Jan", "Feb", "Mar", "Apr", "May"};
|
||||
YFormatter = value => value.ToString("C");
|
||||
|
||||
//modifying the series collection will animate and update the chart
|
||||
SeriesCollection.Add(new LineSeries
|
||||
{
|
||||
Values = new ChartValues<double> {5, 3, 2, 4},
|
||||
LineSmoothness = 0 //straight lines, 1 really smooth lines
|
||||
});
|
||||
|
||||
//modifying any series values will also animate and update the chart
|
||||
SeriesCollection[2].Values.Add(5d);
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public SeriesCollection SeriesCollection { get; set; }
|
||||
public string[] Labels { get; set; }
|
||||
public Func<double, string> YFormatter { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user