mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-02 23:26:35 +08:00
项目结构调整
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="Wpf.CartesianChart.Basic_Bars.BasicColumn"
|
||||
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.Basic_Bars"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance local:BasicColumn}">
|
||||
<Grid>
|
||||
<lvc:CartesianChart Series="{Binding SeriesCollection}" LegendLocation="Left">
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Title="Salesman" Labels="{Binding Labels}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Title="Sold Apps" LabelFormatter="{Binding Formatter}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using LiveCharts;
|
||||
using LiveCharts.Wpf;
|
||||
|
||||
namespace Wpf.CartesianChart.Basic_Bars
|
||||
{
|
||||
public partial class BasicColumn : UserControl
|
||||
{
|
||||
public BasicColumn()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SeriesCollection = new SeriesCollection
|
||||
{
|
||||
new ColumnSeries
|
||||
{
|
||||
Title = "2015",
|
||||
Values = new ChartValues<double> { 10, 50, 39, 50 }
|
||||
}
|
||||
};
|
||||
|
||||
//adding series will update and animate the chart automatically
|
||||
SeriesCollection.Add(new ColumnSeries
|
||||
{
|
||||
Title = "2016",
|
||||
Values = new ChartValues<double> { 11, 56, 42 }
|
||||
});
|
||||
|
||||
//also adding values updates and animates the chart automatically
|
||||
SeriesCollection[1].Values.Add(48d);
|
||||
|
||||
Labels = new[] {"Maria", "Susan", "Charles", "Frida"};
|
||||
Formatter = value => value.ToString("N");
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public SeriesCollection SeriesCollection { get; set; }
|
||||
public string[] Labels { get; set; }
|
||||
public Func<double, string> Formatter { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<UserControl x:Class="Wpf.CartesianChart.Basic_Bars.BasicRowExample"
|
||||
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.Basic_Bars"
|
||||
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance local:BasicRowExample}">
|
||||
<Grid>
|
||||
<lvc:CartesianChart Series="{Binding SeriesCollection}" LegendLocation="Bottom">
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Title="Salesman" LabelFormatter="{Binding Formatter}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Title="Sold Apps" Labels="{Binding Labels}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
<lvc:CartesianChart.DataTooltip>
|
||||
<lvc:DefaultTooltip SelectionMode="SharedYValues"></lvc:DefaultTooltip>
|
||||
</lvc:CartesianChart.DataTooltip>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using LiveCharts;
|
||||
using LiveCharts.Wpf;
|
||||
|
||||
namespace Wpf.CartesianChart.Basic_Bars
|
||||
{
|
||||
public partial class BasicRowExample : UserControl
|
||||
{
|
||||
public BasicRowExample()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
SeriesCollection = new SeriesCollection
|
||||
{
|
||||
new RowSeries
|
||||
{
|
||||
Title = "2015",
|
||||
Values = new ChartValues<double> { 10, 50, 39, 50 }
|
||||
}
|
||||
};
|
||||
|
||||
//adding series will update and animate the chart automatically
|
||||
SeriesCollection.Add(new RowSeries
|
||||
{
|
||||
Title = "2016",
|
||||
Values = new ChartValues<double> { 11, 56, 42}
|
||||
});
|
||||
|
||||
//also adding values updates and animates the chart automatically
|
||||
SeriesCollection[1].Values.Add(48d);
|
||||
|
||||
Labels = new[] {"Maria", "Susan", "Charles", "Frida"};
|
||||
Formatter = value => value.ToString("N");
|
||||
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public SeriesCollection SeriesCollection { get; set; }
|
||||
public string[] Labels { get; set; }
|
||||
public Func<double, string> Formatter { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user