/// <summary> /// Determines whether the specified scale is equal to the current one. /// </summary> /// <param name="scale">The scale.</param> /// <returns><c>true</c> if the scales are equal; otherwise, <c>false</c>.</returns> public bool IsEqualTo(ScaleBase scale) { if (GetType() != scale.GetType()) { return(false); } return(Input.IsEqualTo(scale.Input) && Output.IsEqualTo(scale.Output)); }
public virtual ScaleBase TransformCategoryScale(ScaleBase scale) { if (Items == null) { return(scale); } if (Items.Any()) { scale.Input.MergeWidth(ScaleRange.From(Items, Category(scale))); } if (IsNumeric(CategoryProperty)) { return(scale); } if (IsDate(CategoryProperty)) { return(new DateScale { Input = scale.Input, Output = scale.Output }); } Func <TItem, object> category = String.IsNullOrEmpty(CategoryProperty) ? (item) => string.Empty : PropertyAccess.Getter <TItem, object>(CategoryProperty); var data = Items.Select(category).ToList(); if (scale is OrdinalScale ordinal) { foreach (var item in ordinal.Data) { if (!data.Contains(item)) { var index = ordinal.Data.IndexOf(item); if (index <= data.Count) { data.Insert(index, item); } else { data.Add(item); } } } } return(new OrdinalScale { Data = data, Input = scale.Input, Output = scale.Output, }); }
internal string Format(ScaleBase scale, object value) { if (Formatter != null) { return(Formatter(value)); } else { return(scale.FormatTick(FormatString, value)); } }
public virtual ScaleBase TransformValueScale(ScaleBase scale) { if (Items != null) { if (Items.Any()) { scale.Input.MergeWidth(ScaleRange.From(Items, Value)); } } return(scale); }
protected Func <TItem, double> Category(ScaleBase scale) { if (IsNumeric(CategoryProperty)) { return(PropertyAccess.Getter <TItem, double>(CategoryProperty)); } if (IsDate(CategoryProperty)) { var category = PropertyAccess.Getter <TItem, DateTime>(CategoryProperty); return((item) => category(item).Ticks); } if (scale is OrdinalScale ordinal) { Func <TItem, object> category = String.IsNullOrEmpty(CategoryProperty) ? (item) => string.Empty : PropertyAccess.Getter <TItem, object>(CategoryProperty); return((item) => ordinal.Data.IndexOf(category(item))); } return((item) => Items.IndexOf(item)); }
protected Func <TItem, double> ComposeValue(ScaleBase scale) { return(scale.Compose(Value)); }
protected Func <TItem, double> ComposeCategory(ScaleBase scale) { return(scale.Compose(Category(scale))); }
public abstract RenderFragment Render(ScaleBase categoryScale, ScaleBase valueScale);
internal string Format(ScaleBase scale, double idx) { var value = scale.Value(idx); return(Format(scale, value)); }
/// <inheritdoc /> public override ScaleBase TransformValueScale(ScaleBase scale) { return(base.TransformCategoryScale(scale)); }