Exemple #1
0
        public StatGraphs(string statname, FilterCondition filter)
        {
            InitializeComponent();

            Title = "Plot: " + statname.Replace("[property] ", "");
            if (filter == null)
            {
                FilterText.Text = "None";
            }
            else
            {
                IList <string> filterstrings = new List <string>();
                foreach (FilterCondition c in ((AndCondition)filter).Subconditions)
                {
                    filterstrings.Add(c.ToString());
                }
                FilterText.Text = string.Join("\n", filterstrings);
            }
            PercentChart.AxisX[0].Title = statname.Replace("[property] ", "");
            CostChart.AxisX[0].Title    = statname.Replace("[property] ", "");

            PercentMapper = Mappers.Xy <StatPoint>();
            PercentMapper.X(value => value.X);
            PercentMapper.Y(value => (double)value.Count / value.Total);
            CostMapper = Mappers.Xy <StatPoint>();
            CostMapper.X(value => value.X);
            CostMapper.Y(value => Math.Log(value.Total * value.Cost / value.Count, 10));
            Min  = double.NaN;
            Max  = double.NaN;
            Incr = double.NaN;
        }
 // Sets the unit conversion factors for voltage (millivolts <-> volts), for either axis mapper
 public void CalculateVoltageUnitConversion(CartesianMapper <GraphingEntry> mapper, ControlEnums.VOLTAGEUNITS unit, bool xAxis)
 {
     if (xAxis)
     {
         mapper.X(entry => entry.voltage * GetVoltageUnitConversionFactor(unit));
     }
     else
     {
         mapper.Y(entry => entry.voltage * GetVoltageUnitConversionFactor(unit));
     }
 }
 // Sets the unit conversion factor for time (milliseconds <-> seconds), for either axis mapper
 public void CalculateTimeUnitConversion(CartesianMapper <GraphingEntry> mapper, ControlEnums.TIMEUNITS unit, bool xAxis)
 {
     if (xAxis)
     {
         mapper.X(entry => entry.uptime * GetTimeUnitConversionFactor(unit));
     }
     else
     {
         mapper.Y(entry => entry.uptime * GetTimeUnitConversionFactor(unit));
     }
 }
 // Sets the unit conversion factors for position, velocity and acceleration, for either axis mapper
 public void CalculateBaseUnitConversion(CartesianMapper <GraphingEntry> mapper, ControlEnums.AXISOPTIONS axis, ControlEnums.BASEUNITS unit, bool xAxis)
 {
     if (axis == ControlEnums.AXISOPTIONS.POSITION)
     {
         if (xAxis)
         {
             mapper.X(entry => entry.position * GetBaseUnitConversionFactor(axis, unit));
         }
         else
         {
             mapper.Y(entry => entry.position * GetBaseUnitConversionFactor(axis, unit));
         }
     }
     if (axis == ControlEnums.AXISOPTIONS.VELOCITY)
     {
         if (xAxis)
         {
             mapper.X(entry => entry.velocity * GetBaseUnitConversionFactor(axis, unit));
         }
         else
         {
             mapper.Y(entry => entry.velocity * GetBaseUnitConversionFactor(axis, unit));
         }
     }
     if (axis == ControlEnums.AXISOPTIONS.ACCELERATION)
     {
         if (xAxis)
         {
             mapper.X(entry => entry.acceleration * GetBaseUnitConversionFactor(axis, unit));
         }
         else
         {
             mapper.Y(entry => entry.acceleration * GetBaseUnitConversionFactor(axis, unit));
         }
     }
 }
        static public SeriesCollection SeriesCollectionForConfiguration(SeriesCollectionConfiguration configuration)
        {
            LineSeries[] Series = new LineSeries[configuration.Types.Length];
            for (int i = 0; i < configuration.Types.Length; i++)
            {
                Series[i] = LineSeriesForType(configuration.Types[i], configuration.DataPoints);
            }

            SeriesCollection collection;
            CartesianMapper <ObservablePoint> Mapper = Mappers.Xy <ObservablePoint>();

            if (configuration.HasLogarithmicX)
            {
                Mapper.X(point => Math.Log(point.X + .000001, 10));
            }
            else
            {
                Mapper.X(point => point.X);
            }

            if (configuration.HasLogarithmicY)
            {
                Mapper.Y(point => Math.Log(point.Y + .000001, 10));
            }
            else
            {
                Mapper.Y(point => point.Y);
            }

            collection = new SeriesCollection(Mapper);
            collection.AddRange(Series);



            return(collection);
        }