using System; namespace LiveCharts.Configurations { /// /// Mapper to configure X and Y points /// /// Type to configure public class PieMapper : IPointEvaluator { private readonly Func _x = (v, i) => i; private Func _y = (v, i) => i; private Func _stroke; private Func _fill; /// /// Sets values for a specific point /// /// Point to set /// /// 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); } /// /// Sets the Y mapper /// /// function that pulls Y coordinate /// current mapper instance public PieMapper Value(Func predicate) { return Value((t, i) => predicate(t)); } /// /// Sets the Y mapper /// /// function that pulls Y coordinate, with value and index as parameters /// current mapper instance public PieMapper Value(Func predicate) { _y = predicate; return this; } /// /// Sets the Stroke of the point /// /// /// public PieMapper Stroke(Func predicate) { return Stroke((t, i) => predicate(t)); } /// /// Sets the Stroke of the point /// /// /// public PieMapper Stroke(Func predicate) { _stroke = predicate; return this; } /// /// Sets the Fill of the point /// /// /// public PieMapper Fill(Func predicate) { return Fill((t, i) => predicate(t)); } /// /// Sets the Fill of the point /// /// /// public PieMapper Fill(Func predicate) { _fill = predicate; return this; } } }