/// <summary> /// The MoveInsideContainer /// </summary> /// <param name="range">The range<see cref="RangeDouble"/></param> /// <param name="container">The container<see cref="RangeDouble"/></param> /// <returns>The <see cref="RangeDouble"/></returns> public static RangeDouble MoveInsideContainer(this RangeDouble range, RangeDouble container) { if (container.Contains(range)) { return(range); } var length = range.Length(); if (length > container.Length()) { length = container.Length(); } var rangeInside = range.Start < container.Start ? new RangeDouble(container.Start, container.Start + length) : new RangeDouble(container.End - length, container.End); return(rangeInside); }
/// <summary> /// The Offset the range to the specified distance. /// </summary> /// <param name="range">The range<see cref="RangeDouble"/></param> /// <param name="distance">The distance<see cref="double"/></param> /// <param name="extentRange">The extentRange<see cref="RangeDouble"/></param> /// <returns>The <see cref="RangeDouble"/></returns> public static RangeDouble Offset(this RangeDouble range, double distance, RangeDouble extentRange) { var length = range.Length(); if (extentRange.Length() < length) { length = extentRange.Length(); } var start = range.Start + distance; var end = start + length; var newRange = new RangeDouble(start, end); if (extentRange.Contains(newRange)) { return(newRange); } return(start < extentRange.Start ? new RangeDouble(extentRange.Start, extentRange.Start + length) : new RangeDouble(extentRange.End - length, extentRange.End)); }
/// <summary> /// The GenerateDummyData. /// </summary> /// <param name="viewModel">The viewModel<see cref="BarChartViewModel"/>.</param> private void GenerateDummyData(BarChartViewModel viewModel) { viewModel.Title = "Bar Chart Test App"; viewModel.Subtitle = "Show Bar Chart with Dummy Data"; var n = 5; var range = new RangeDouble(0, 1000); for (var i = 0; i < n; i++) { var model = new BarModel { Index = i, Name = $"Bar Test {i}", Value = (n - i) * (range.Length() / n), VisibleRange = range }; viewModel.BarModels.Add(model); } }
/// <summary> /// The Center /// </summary> /// <param name="range">The range<see cref="RangeDouble"/></param> /// <returns>The <see cref="double"/></returns> public static double Center(this RangeDouble range) { var center = range.Start + range.Length() * 0.5; return(center); }