mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-26 03:07:55 +08:00
项目结构调整
This commit is contained in:
94
Others/Live-Charts-master/Core/Configurations/PieMapper.cs
Normal file
94
Others/Live-Charts-master/Core/Configurations/PieMapper.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
|
||||
namespace LiveCharts.Configurations
|
||||
{
|
||||
/// <summary>
|
||||
/// Mapper to configure X and Y points
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type to configure</typeparam>
|
||||
public class PieMapper<T> : IPointEvaluator<T>
|
||||
{
|
||||
private readonly Func<T, int, double> _x = (v, i) => i;
|
||||
private Func<T, int, double> _y = (v, i) => i;
|
||||
private Func<T, int, object> _stroke;
|
||||
private Func<T, int, object> _fill;
|
||||
|
||||
/// <summary>
|
||||
/// Sets values for a specific point
|
||||
/// </summary>
|
||||
/// <param name="point">Point to set</param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="key"></param>
|
||||
public void Evaluate(int key, T value, ChartPoint point)
|
||||
{
|
||||
point.X = _x(value, key);
|
||||
point.Y = _y(value, key);
|
||||
if (_stroke != null) point.Stroke = _stroke(value, key);
|
||||
if (_fill != null) point.Fill = _fill(value, key);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Y mapper
|
||||
/// </summary>
|
||||
/// <param name="predicate">function that pulls Y coordinate</param>
|
||||
/// <returns>current mapper instance</returns>
|
||||
public PieMapper<T> Value(Func<T, double> predicate)
|
||||
{
|
||||
return Value((t, i) => predicate(t));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Y mapper
|
||||
/// </summary>
|
||||
/// <param name="predicate">function that pulls Y coordinate, with value and index as parameters</param>
|
||||
/// <returns>current mapper instance</returns>
|
||||
public PieMapper<T> Value(Func<T, int, double> predicate)
|
||||
{
|
||||
_y = predicate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Stroke of the point
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public PieMapper<T> Stroke(Func<T, object> predicate)
|
||||
{
|
||||
return Stroke((t, i) => predicate(t));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Stroke of the point
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public PieMapper<T> Stroke(Func<T, int, object> predicate)
|
||||
{
|
||||
_stroke = predicate;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Fill of the point
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public PieMapper<T> Fill(Func<T, object> predicate)
|
||||
{
|
||||
return Fill((t, i) => predicate(t));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the Fill of the point
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <returns></returns>
|
||||
public PieMapper<T> Fill(Func<T, int, object> predicate)
|
||||
{
|
||||
_fill = predicate;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user