using Community;
using LiveCharts;
using LiveCharts.Defaults;
using LiveCharts.Wpf;
using Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace ViewModel
{
///
/// 图表显示
///
public class ChartVM: NotificationObject
{
///
/// 曲线图 LineSeries 柱状图 ColumnSeries 堆叠柱状图 StackedColumnSeries 甘特图CartesianChart 饼图 PieSeries 进度环 Gauge
///
private IChartValues v1;
///
/// 第一组数据
///
public IChartValues V1
{
get { return v1; }
set
{
v1 = value;
this.RaisePropertyChanged("V1");
}
}
private IChartValues v2;
///
/// 第二组数据
///
public IChartValues V2
{
get { return v2; }
set
{
v2 = value;
this.RaisePropertyChanged("V2");
}
}
private IChartValues v3;
///
/// 第三组数据
///
public IChartValues V3
{
get { return v3; }
set
{
v3 = value;
this.RaisePropertyChanged("V3");
}
}
private ObservableCollection labels;
///
/// Y轴数据
///
public ObservableCollection Labels
{
get { return labels; }
set
{
labels = value;
this.RaisePropertyChanged("Labels");
}
}
private string colorV2;
///
/// 第二条线的颜色
///
public string ColorV2
{
get { return colorV2; }
set { colorV2 = value; RaisePropertyChanged("ColorV2"); }
}
///
/// Y轴显示格式
///
public Func Formatter { get; set; }
///
/// X轴显示内容格式
///
public Func labelPoint { get; set; }
public ChartVM()
{
////X轴标签
//Labels = new ObservableCollection() { "1","2","3","4","5","6","7","8","9","10","11","12"};
Labels = new ObservableCollection();
V1 = new ChartValues();
V2 = new ChartValues();
V3 = new ChartValues();
//Formatter = value => value.ToString("N"); //Y轴显示格式 N 小数
// Formatter = value => value.ToString("P"); //Y轴显示格式 p 百分比
Formatter = value => value.ToString();
labelPoint = p => p.Participation.ToString("N");
}
///
/// 清空数据
///
public void ClearData()
{
V1.Clear();
V2.Clear();
V3.Clear();
}
}
}