Пример #1
0
        public static object Scale(this ScaleLinear scale, object value)
        {
            if (scale == null)
            {
                BH.Engine.Reflection.Compute.RecordError("Cannot query the scale of a null linear scale object.");
                return(null);
            }

            return(Map(scale.Domain, scale.Range, System.Convert.ToDouble(value)));
        }
Пример #2
0
        public static IScale IScale(List <object> domain, List <object> range)
        {
            IScale scale = null;

            if (domain.All(d => d.IsNumericType()) && range.All(d => d.IsNumericType()))
            {
                List <double> d = new List <double>();
                domain.ForEach(x => d.Add(System.Convert.ToDouble(x)));
                List <double> r = new List <double>();
                range.ForEach(x => r.Add(System.Convert.ToDouble(x)));

                scale = new ScaleLinear()
                {
                    Domain = Data.Create.Domain(d),
                    Range  = Data.Create.Domain(r)
                };
                return(scale);
            }

            else
            {
                List <string> d = domain.ToStringList().Distinct().ToList();

                scale = new ScaleOrdinal()
                {
                    Domain = d,
                    Range  = range
                };
            }


            //date time
            //non linear
            //others to do
            return(scale);
        }