using Community;
using LiveCharts;
using LiveCharts.Defaults;
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 Model
{
///
/// 图表模型
///
public class ChartModel : NotificationObject
{
///
/// 曲线图 LineSeries 柱状图 ColumnSeries 堆叠柱状图 StackedColumnSeries 甘特图CartesianChart 饼图 PieSeries 进度环 Gauge
///
private ChartValues v1;
///
/// 第一组数据
///
public ChartValues V1
{
get { return v1; }
set
{
v1 = value;
this.RaisePropertyChanged("V1");
}
}
private ChartValues v2;
///
/// 第二组数据
///
public ChartValues 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 ObservableCollection labels;
/////
///// Y轴数据
/////
//public ObservableCollection Labels
//{
// get { return labels; }
// set
// {
// labels = value;
// this.RaisePropertyChanged("Labels");
// }
//}
///
/// Y轴显示格式
///
public Func Formatter { get; set; }
///
/// X轴显示内容格式
///
public Func labelPoint { get; set; }
public ChartModel()
{
////X轴标签
Labels = new ObservableCollection();
//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 百分比
labelPoint = p => p.Participation.ToString("P");
}
///
/// 清空数据
///
public void ClearData()
{
V1.Clear();
V2.Clear();
V3.Clear();
}
}
}