Пример #1
0
        private void ConfigureCategoricalRange(SolidPSObjectBase o)
        {
            var pso   = o as SolidPSObjectBase;
            var xtype = GetPropertyType(pso, this.LabelMemberPath);

            ChartAxisType xaxistype = ChartAxisType.CategoryX;
            ChartAxisType yaxistype = ChartAxisType.NumericY;

            if (xtype == typeof(DateTime))
            {
                xaxistype = ChartAxisType.CategoryDateTimeX;
            }

            var x = new ChartAxisViewModel
            {
                AxisType        = xaxistype,
                Name            = LabelMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = LabelMemberPath,
                LabelTemplate   = "{" + LabelMemberPath + "}",
                AxisLocation    = AxisLocation.OutsideBottom,
            };
            var y = new ChartAxisViewModel
            {
                AxisType        = yaxistype,
                Name            = LowMemberPath ?? HighMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = LowMemberPath ?? HighMemberPath,
                AxisLocation    = AxisLocation.OutsideLeft
            };

            XAxis = x;
            YAxis = y;
        }
 public InvalidChartAxisValueMemberException(ChartSeriesType seriesType, ChartAxisType axisType, SolidPSObjectBase data, string valueMemberPath)
     : base(String.Format(
                "The value member [{0}] of data type [{3}] is invalid for axis type [{2}] series type [{1}]",
                valueMemberPath,
                seriesType,
                axisType,
                null == data ? "null" : data.GetPropTypeName(valueMemberPath)
                ))
 {
     SeriesType      = seriesType;
     AxisType        = axisType;
     Data            = data;
     ValueMemberPath = valueMemberPath;
 }
Пример #3
0
        private void VerifyAxisForData(ChartAxisViewModel xAxis, SolidPSObjectBase dataItem)
        {
            var prop = dataItem.GetPropertyByName(xAxis.ValueMemberPath);

            if (null == prop)
            {
                throw new ChartAxisValueMemberDoesNotExistException(SeriesType, xAxis.AxisType, xAxis.ValueMemberPath);
            }

            if (!IsPropertyValidForAxis(prop, xAxis))
            {
                throw new InvalidChartAxisValueMemberException(SeriesType, xAxis.AxisType, dataItem as SolidPSObjectBase, xAxis.ValueMemberPath);
            }
        }
Пример #4
0
        private void VerifyPropertyForRadius(SolidPSObjectBase dataItem)
        {
            if (String.IsNullOrEmpty(RadiusMemberPath))
            {
                return;
            }

            var prop = dataItem.GetPropertyByName(RadiusMemberPath);

            if (!IsNumericType(prop))
            {
                throw new InvalidChartValueMemberException(SeriesType, prop, RadiusMemberPath, "Radius");
            }
        }
Пример #5
0
        private void VerifyAxisTypes(SolidPSObjectBase dataItem)
        {
            Log.InfoFormat("verifying data type [{0}] for axis", dataItem.GetType().FullName);
            var validAxisTypes = SeriesType.ValidAxisTypes();

            if (!validAxisTypes.Contains(XAxis.AxisType))
            {
                throw new InvalidChartAxisTypeException(SeriesType, XAxis.AxisType);
            }
            if (!validAxisTypes.Contains(YAxis.AxisType))
            {
                throw new InvalidChartAxisTypeException(SeriesType, YAxis.AxisType);
            }

            VerifyAxisForData(XAxis, dataItem);
            VerifyAxisForData(YAxis, dataItem);
            VerifyPropertyForRadius(dataItem);
        }
Пример #6
0
 bool TryConfigureAxes(SolidPSObjectBase o)
 {
     try
     {
         return(ConfigureAxes(o));
     }
     catch (Exception e)
     {
         if (null != AllRecords && null != Dispatcher)
         {
             Dispatcher.BeginInvoke(
                 (Action)
                 (() =>
                  AllRecords.Add(new ErrorRecord(e, "SeeShell.Charts.AxisConfiguration",
                                                 ErrorCategory.InvalidData, this))));
         }
         return(true);
     }
 }
Пример #7
0
        private Type GetPropertyType(SolidPSObjectBase pso, string propertyName)
        {
            var value = pso.GetPropValue <object>(propertyName);

            if (null != value)
            {
                return(value.GetType());
            }
            var xtypename = pso.GetPropTypeName(propertyName);

            if (null == xtypename)
            {
                return(typeof(object));
            }

            var xtype = (from asm in AppDomain.CurrentDomain.GetAssemblies()
                         from t in asm.GetTypes()
                         where t.FullName.ToLowerInvariant() == xtypename
                         select t).FirstOrDefault();

            return(xtype);
        }
 public InvalidChartAxisValueMemberException(ChartSeriesType seriesType, ChartAxisType axisType, SolidPSObjectBase data, string valueMemberPath)
     : base(String.Format(
         "The value member [{0}] of data type [{3}] is invalid for axis type [{2}] series type [{1}]", 
         valueMemberPath, 
         seriesType, 
         axisType, 
         null == data ? "null" : data.GetPropTypeName( valueMemberPath )
     ))
 {
     SeriesType = seriesType;
     AxisType = axisType;
     Data = data;
     ValueMemberPath = valueMemberPath;
 }
Пример #9
0
        private void VerifyPropertyForRadius(SolidPSObjectBase dataItem)
        {
            if( String.IsNullOrEmpty( RadiusMemberPath) )
            {
                return;
            }

            var prop = dataItem.GetPropertyByName(RadiusMemberPath);
            if( ! IsNumericType( prop ))
            {
                throw new InvalidChartValueMemberException( SeriesType, prop, RadiusMemberPath, "Radius");
            }
        }
Пример #10
0
        private void VerifyAxisTypes(SolidPSObjectBase dataItem)
        {
            Log.InfoFormat( "verifying data type [{0}] for axis", dataItem.GetType().FullName );
            var validAxisTypes = SeriesType.ValidAxisTypes();
            if (!validAxisTypes.Contains(XAxis.AxisType))
            {
                throw new InvalidChartAxisTypeException(SeriesType, XAxis.AxisType);
            }
            if (!validAxisTypes.Contains(YAxis.AxisType))
            {
                throw new InvalidChartAxisTypeException(SeriesType, YAxis.AxisType);
            }

            VerifyAxisForData(XAxis, dataItem);
            VerifyAxisForData(YAxis, dataItem);
            VerifyPropertyForRadius(dataItem);
        }
Пример #11
0
        private void VerifyAxisForData(ChartAxisViewModel xAxis, SolidPSObjectBase dataItem)
        {
            var prop = dataItem.GetPropertyByName(xAxis.ValueMemberPath);
            if( null == prop )
            {
                throw new ChartAxisValueMemberDoesNotExistException( SeriesType, xAxis.AxisType, xAxis.ValueMemberPath );
            }

            if( ! IsPropertyValidForAxis( prop, xAxis ))
            {
                throw new InvalidChartAxisValueMemberException(SeriesType, xAxis.AxisType, dataItem as SolidPSObjectBase, xAxis.ValueMemberPath);
            }
        }
Пример #12
0
 bool TryConfigureAxes( SolidPSObjectBase o )
 {
     try
     {
         return ConfigureAxes(o);
     }
     catch (Exception e)
     {
         if (null != AllRecords && null != Dispatcher)
         {
             Dispatcher.BeginInvoke(
                 (Action)
                 (() =>
                  AllRecords.Add(new ErrorRecord(e, "SeeShell.Charts.AxisConfiguration",
                                                 ErrorCategory.InvalidData, this))));
         }
         return true;
     }
 }
Пример #13
0
        private Type GetPropertyType(SolidPSObjectBase pso, string propertyName)
        {
            var value = pso.GetPropValue<object>(propertyName);
            if( null != value )
            {
                return value.GetType();
            }
            var xtypename = pso.GetPropTypeName(propertyName);
            if( null == xtypename )
            {
                return typeof (object);
            }

            var xtype = (from asm in AppDomain.CurrentDomain.GetAssemblies()
                         from t in asm.GetTypes()
                         where t.FullName.ToLowerInvariant() == xtypename
                         select t).FirstOrDefault();
            return xtype;
        }
Пример #14
0
        private void ConfigureCategoricalRange(SolidPSObjectBase o)
        {
            var pso = o as SolidPSObjectBase;
            var xtype = GetPropertyType(pso, this.LabelMemberPath);

            ChartAxisType xaxistype = ChartAxisType.CategoryX;
            ChartAxisType yaxistype = ChartAxisType.NumericY;

            if (xtype == typeof(DateTime))
            {
                xaxistype = ChartAxisType.CategoryDateTimeX;
            }

            var x = new ChartAxisViewModel
            {
                AxisType = xaxistype,
                Name = LabelMemberPath,
                DataSource = DataSource,
                ValueMemberPath = LabelMemberPath,
                LabelTemplate = "{" + LabelMemberPath + "}",
                AxisLocation = AxisLocation.OutsideBottom,
            };
            var y = new ChartAxisViewModel
            {
                AxisType = yaxistype,
                Name = LowMemberPath ?? HighMemberPath,
                DataSource = DataSource,
                ValueMemberPath = LowMemberPath ?? HighMemberPath,
                AxisLocation = AxisLocation.OutsideLeft
            };

            XAxis = x;
            YAxis = y;
        }
Пример #15
0
        private bool ConfigureAxes(SolidPSObjectBase o)
        {
            if (!CanConfigureAxes)
            {
                return false;
            }

            if( SeriesType.IsCategorical() )
            {
                ConfigureCategoricalAxes(o);
            }
            else if( SeriesType.IsCategoricalRange())
            {
                ConfigureCategoricalRange(o);
            }
            else if ( SeriesType.IsScatter() )
            {
                ConfigureScatterAxes(o);
            }
            else if( SeriesType.IsPolar())
            {
                ConfigurePolarAxis(o);
            }
            else if( SeriesType.IsRadial())
            {
                ConfigureRadialAxis(o);
            }
            else
            {
                throw new InvalidOperationException("Unanticipated series type encountered during axis determination: " + SeriesType);
            }

            VerifyAxisTypes(o);

            var sdx = GetScaleForProperty(XAxis.ValueMemberPath);
            var sdy = GetScaleForProperty(YAxis.ValueMemberPath);

            if( null == sdx )
            {
                sdx = new ScaleDescriptor( XAxis.ValueMemberPath, ColorManager.AssignColor() );
            }

            XAxis.AxisScaleDescriptors.Add( new ScaleDescriptorAssignment{ PropertyName = sdx.Name, Scale = sdx } );

            if( null != sdy )
            {
                var sdym = new[]{ sdy }.Union( DataSource.Scales.Select(s=>s.Scale) )
                    .Where(s => s.Name == sdy.Name)
                    .ToList()
                    .ConvertAll(a=> new ScaleDescriptorAssignment{PropertyName = a.Name, Scale = a});
                sdym.ToList().ForEach( YAxis.AxisScaleDescriptors.Add );
            }

            var ev = AxesUpdated;
            if( null != ev )
            {
                ev(this, EventArgs.Empty);
            }

            return true;
        }
Пример #16
0
        private bool ConfigureAxes(SolidPSObjectBase o)
        {
            if (!CanConfigureAxes)
            {
                return(false);
            }

            if (SeriesType.IsCategorical())
            {
                ConfigureCategoricalAxes(o);
            }
            else if (SeriesType.IsCategoricalRange())
            {
                ConfigureCategoricalRange(o);
            }
            else if (SeriesType.IsScatter())
            {
                ConfigureScatterAxes(o);
            }
            else if (SeriesType.IsPolar())
            {
                ConfigurePolarAxis(o);
            }
            else if (SeriesType.IsRadial())
            {
                ConfigureRadialAxis(o);
            }
            else
            {
                throw new InvalidOperationException("Unanticipated series type encountered during axis determination: " + SeriesType);
            }

            VerifyAxisTypes(o);

            var sdx = GetScaleForProperty(XAxis.ValueMemberPath);
            var sdy = GetScaleForProperty(YAxis.ValueMemberPath);

            if (null == sdx)
            {
                sdx = new ScaleDescriptor(XAxis.ValueMemberPath, ColorManager.AssignColor());
            }

            XAxis.AxisScaleDescriptors.Add(new ScaleDescriptorAssignment {
                PropertyName = sdx.Name, Scale = sdx
            });

            if (null != sdy)
            {
                var sdym = new[] { sdy }.Union(DataSource.Scales.Select(s => s.Scale))
                .Where(s => s.Name == sdy.Name)
                .ToList()
                .ConvertAll(a => new ScaleDescriptorAssignment {
                    PropertyName = a.Name, Scale = a
                });
                sdym.ToList().ForEach(YAxis.AxisScaleDescriptors.Add);
            }

            var ev = AxesUpdated;

            if (null != ev)
            {
                ev(this, EventArgs.Empty);
            }

            return(true);
        }