添加项目文件。

This commit is contained in:
akwkevin
2021-07-23 09:42:22 +08:00
commit f25a958797
2798 changed files with 352360 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<UserControl x:Class="Wpf.CartesianChart.HeatChart.HeatSeriesExample"
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:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:heatChart="clr-namespace:Wpf.CartesianChart.HeatChart"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance heatChart:HeatSeriesExample}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Grid.Row="0" Click="ButtonBase_OnClick" Margin="10">Randomize</Button>
<lvc:CartesianChart Grid.Row="1" DataTooltip="{x:Null}">
<lvc:CartesianChart.Series>
<lvc:HeatSeries Values="{Binding Values}" DataLabels="True">
<!--
The GradientStopCollection is optional to define a custom gradient
If this property is not specified, LiveCharts will set a gradient
-->
<lvc:HeatSeries.GradientStopCollection>
<GradientStop Offset="0" Color="#99FFFF00"></GradientStop>
<GradientStop Offset=".25" Color="#FFFFFF00"></GradientStop>
<GradientStop Offset=".50" Color="#990000FF"></GradientStop>
<GradientStop Offset=".75" Color="#FF0000FF"></GradientStop>
<GradientStop Offset="1" Color="#50505050"></GradientStop>
</lvc:HeatSeries.GradientStopCollection>
</lvc:HeatSeries>
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisX >
<lvc:Axis Labels="{Binding SalesMan}" LabelsRotation="-15">
<lvc:Axis.Separator>
<lvc:Separator Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Labels="{Binding Days}"></lvc:Axis>
</lvc:CartesianChart.AxisY>
</lvc:CartesianChart>
</Grid>
</UserControl>

View File

@@ -0,0 +1,104 @@
using System;
using System.Windows;
using System.Windows.Controls;
using LiveCharts;
using LiveCharts.Defaults;
namespace Wpf.CartesianChart.HeatChart
{
public partial class HeatSeriesExample : UserControl
{
public HeatSeriesExample()
{
InitializeComponent();
var r = new Random();
Values = new ChartValues<HeatPoint>
{
//X means sales man
//Y is the day
//"Jeremy Swanson"
new HeatPoint(0, 0, r.Next(0, 10)),
new HeatPoint(0, 1, r.Next(0, 10)),
new HeatPoint(0, 2, r.Next(0, 10)),
new HeatPoint(0, 3, r.Next(0, 10)),
new HeatPoint(0, 4, r.Next(0, 10)),
new HeatPoint(0, 5, r.Next(0, 10)),
new HeatPoint(0, 6, r.Next(0, 10)),
//"Lorena Hoffman"
new HeatPoint(1, 0, r.Next(0, 10)),
new HeatPoint(1, 1, r.Next(0, 10)),
new HeatPoint(1, 2, r.Next(0, 10)),
new HeatPoint(1, 3, r.Next(0, 10)),
new HeatPoint(1, 4, r.Next(0, 10)),
new HeatPoint(1, 5, r.Next(0, 10)),
new HeatPoint(1, 6, r.Next(0, 10)),
//"Robyn Williamson"
new HeatPoint(2, 0, r.Next(0, 10)),
new HeatPoint(2, 1, r.Next(0, 10)),
new HeatPoint(2, 2, r.Next(0, 10)),
new HeatPoint(2, 3, r.Next(0, 10)),
new HeatPoint(2, 4, r.Next(0, 10)),
new HeatPoint(2, 5, r.Next(0, 10)),
new HeatPoint(2, 6, r.Next(0, 10)),
//"Carole Haynes"
new HeatPoint(3, 0, r.Next(0, 10)),
new HeatPoint(3, 1, r.Next(0, 10)),
new HeatPoint(3, 2, r.Next(0, 10)),
new HeatPoint(3, 3, r.Next(0, 10)),
new HeatPoint(3, 4, r.Next(0, 10)),
new HeatPoint(3, 5, r.Next(0, 10)),
new HeatPoint(3, 6, r.Next(0, 10)),
//"Essie Nelson"
new HeatPoint(4, 0, r.Next(0, 10)),
new HeatPoint(4, 1, r.Next(0, 10)),
new HeatPoint(4, 2, r.Next(0, 10)),
new HeatPoint(4, 3, r.Next(0, 10)),
new HeatPoint(4, 4, r.Next(0, 10)),
new HeatPoint(4, 5, r.Next(0, 10)),
new HeatPoint(4, 6, r.Next(0, 10))
};
Days = new[]
{
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
SalesMan = new[]
{
"Jeremy Swanson",
"Lorena Hoffman",
"Robyn Williamson",
"Carole Haynes",
"Essie Nelson"
};
DataContext = this;
}
public ChartValues<HeatPoint> Values { get; set; }
public string[] Days { get; set; }
public string[] SalesMan { get; set; }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
var r = new Random();
foreach (var chartValue in Values)
{
chartValue.Weight = r.Next(0, 10);
}
}
}
}