// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Public License (Ms-PL). // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // All other rights reserved. using System.Globalization; namespace System.Windows.Controls.DataVisualization { /// /// Interpolator which converts a numeric value from its [RangeMinimum, RangeMaximum] /// range to another value in the range [From, To]. /// /// Preview public class DoubleInterpolator : RangeInterpolator { /// /// Interpolates the given value between its [RangeMinimum, RangeMaximum] range /// and returns an interpolated value in the range [From, To]. /// /// Value to interpolate. /// An interpolated value in the range [From, To]. public override object Interpolate(double value) { double result = From; if (ActualDataMaximum - ActualDataMinimum != 0) { double ratio = (value - ActualDataMinimum) / (ActualDataMaximum - ActualDataMinimum); result = From + (ratio * (To - From)); } return result; } } }