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, }); }
public virtual ScaleBase TransformValueScale(ScaleBase scale) { if (Items != null) { if (Items.Any()) { scale.Input.MergeWidth(ScaleRange.From(Items, Value)); } } return(scale); }
public bool IsEqualTo(ScaleRange range) { return(Start == range.Start && End == range.End); }
public void MergeWidth(ScaleRange range) { Start = Math.Min(Start, range.Start); End = Math.Max(End, range.End); }