예제 #1
0
        private void ConfigureCategoricalAxes(object 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            = ValueMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = ValueMemberPath,
                AxisLocation    = AxisLocation.OutsideLeft
            };

            XAxis = x;
            YAxis = y;
        }
예제 #2
0
        private void ConfigureRadialAxis(object o)
        {
            var i     = o as SolidPSObjectBase;
            var value = i.GetPropValue <object>(AngleMemberPath);

            var r = new ChartAxisViewModel
            {
                AxisType     = ChartAxisType.NumericRadius,
                AxisLocation = AxisLocation.InsideRight,

                Name            = this.RadiusMemberPath,
                DataSource      = this.DataSource,
                Dispatcher      = this.Dispatcher,
                ValueMemberPath = RadiusMemberPath,
            };
            var a = new ChartAxisViewModel()
            {
                AxisType = ChartAxisType.CategoryAngle,
                //AxisLocation = AxisLocation.OutsideTop,
                AxisLocation = AxisLocation.OutsideBottom,

                Name            = this.AngleMemberPath,
                DataSource      = this.DataSource,
                ValueMemberPath = AngleMemberPath,
                LabelTemplate   = "{" + LabelMemberPath + "}"
            };

            this.XAxis = a;
            this.YAxis = r;
        }
예제 #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 ConfigureScatterAxes(object o)
        {
            var x = new ChartAxisViewModel
            {
                AxisType        = ChartAxisType.NumericX,
                Name            = XMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = XMemberPath,
                LabelTemplate   = "{" + LabelMemberPath + "}",
                AxisLocation    = AxisLocation.OutsideBottom
            };
            var y = new ChartAxisViewModel
            {
                AxisType        = ChartAxisType.NumericY,
                Name            = YMemberPath,
                DataSource      = DataSource,
                ValueMemberPath = YMemberPath,
                AxisLocation    = AxisLocation.OutsideLeft
            };

            XAxis = x;
            YAxis = y;
        }
예제 #5
0
        private void ConfigurePolarAxis(object o)
        {
            var r = new ChartAxisViewModel
            {
                AxisType        = ChartAxisType.NumericRadius,
                Name            = this.RadiusMemberPath,
                DataSource      = this.DataSource,
                Dispatcher      = this.Dispatcher,
                ValueMemberPath = RadiusMemberPath,
            };
            var a = new ChartAxisViewModel()
            {
                AxisType     = ChartAxisType.NumericAngle,
                AxisLocation = AxisLocation.OutsideBottom,
                //AxisLocation=AxisLocation.OutsideTop,
                Name            = this.AngleMemberPath,
                DataSource      = this.DataSource,
                ValueMemberPath = AngleMemberPath,
                LabelTemplate   = "{" + LabelMemberPath + "}"
            };

            this.XAxis = a;
            this.YAxis = r;
        }
예제 #6
0
        private bool IsPropertyValidForAxis(PSPropertyInfo prop, ChartAxisViewModel axis)
        {
            if (SeriesType == ChartSeriesType.Timeline)
            {
                return(axis.AxisType != ChartAxisType.CategoryX);
            }

            switch (axis.AxisType)
            {
            case (ChartAxisType.NumericAngle):
            case (ChartAxisType.NumericRadius):
            case (ChartAxisType.NumericX):
            case (ChartAxisType.NumericY):
            {
                return(IsNumericType(prop));
            }

            //case( ChartAxisType.CategoryDateTimeX ):
            //case( ChartAxisType.CategoryX ):
            //case (ChartAxisType.CategoryAngle):
            default:
                return(true);
            }
        }
        private Axis ConvertAxis(ChartAxisViewModel axis)
        {
            Axis newAxis = null;

            switch (axis.AxisType)
            {
                case (ChartAxisType.CategoryX):
                {
                    newAxis = new CategoryAxis
                    {
                        LabelField = axis.ValueMemberPath,
                        ItemsSource = axis.DataSource.Data
                    };
                    break;
                }
                case (ChartAxisType.NumericX):
                case (ChartAxisType.NumericY):
                {
                    newAxis = new LinearAxis
                    {
                    };
                    break;
                }
                case(ChartAxisType.CategoryDateTimeX):
                {
                    var dtaxis = new DateTimeAxis
                    {
                        IntervalType = DateTimeIntervalType.Auto,
                    };

                    var scale = axis.GetScaleForProperty(axis.ValueMemberPath);
                    if (null != scale)
                    {
                        scale.PropertyChanged += (s, a) =>
                        {
                            if( a.PropertyName != "Minimum" && a.PropertyName != "Maximum")
                            {
                                return;
                            }

                            var min = new DateTime((long)scale.Minimum);
                            var max = new DateTime((long)scale.Maximum);

                            var laxis = _plotModel.Axes.FirstOrDefault(x =>  x.Title == scale.Name) as DateTimeAxis;
                            if( null == laxis )
                            {
                                return;
                            }

                            var delta = max - min;

                            var lmax = 0.0d;
                            var lmin = 0.0d;

                            if (TimeSpan.FromSeconds(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Seconds;
                            }
                            else if (TimeSpan.FromMinutes(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Minutes;
                            }
                            else if (TimeSpan.FromHours(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Hours;
                            }
                            else if (TimeSpan.FromDays(1) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Days;
                            }
                            else if (TimeSpan.FromDays(30) > delta)
                            {
                                laxis.IntervalType = DateTimeIntervalType.Months;
                            }
                            else
                            {
                                laxis.IntervalType = DateTimeIntervalType.Auto;
                            }

                            //TODO: remove
                            laxis.IntervalType = DateTimeIntervalType.Seconds;

                            //laxis.Minimum = scale.Minimum;
                            //laxis.Maximum = scale.Maximum;

                            OnPlotModelChanged();
                        };
                    }
                    newAxis = dtaxis;
                    break;
                }
            }

            if (null == newAxis)
            {
                return null;
            }

            switch (axis.AxisLocation)
            {
                case(AxisLocation.InsideBottom):
                case(AxisLocation.OutsideBottom):
                {
                    newAxis.Position = AxisPosition.Bottom;
                    break;
                }
                case (AxisLocation.InsideTop):
                case (AxisLocation.OutsideTop):
                {
                    newAxis.Position = AxisPosition.Top;
                    break;
                }
                case (AxisLocation.InsideLeft):
                case (AxisLocation.OutsideLeft):
                {
                    newAxis.Position = AxisPosition.Left;
                    break;
                }
                case (AxisLocation.InsideRight):
                case (AxisLocation.OutsideRight):
                {
                    newAxis.Position = AxisPosition.Right;
                    break;
                }
                default:
                {
                    newAxis.Position = AxisPosition.None;
                    break;
                }
            }

            newAxis.Title = axis.Name;

            var series = axis.AxisScaleDescriptors.FirstOrDefault();
            if (null != series)
            {
                newAxis.Title = series.Scale.Name;
            }

            newAxis.Key = newAxis.Title;

            return newAxis;
        }
예제 #8
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);
            }
        }
예제 #9
0
        private bool IsPropertyValidForAxis(PSPropertyInfo prop, ChartAxisViewModel axis)
        {
            if( SeriesType == ChartSeriesType.Timeline )
            {
                return axis.AxisType != ChartAxisType.CategoryX;
            }

            switch( axis.AxisType )
            {
                case (ChartAxisType.NumericAngle):
                case( ChartAxisType.NumericRadius ):
                case( ChartAxisType.NumericX ):
                case( ChartAxisType.NumericY ):
                    {
                        return IsNumericType(prop);
                    }
                //case( ChartAxisType.CategoryDateTimeX ):
                //case( ChartAxisType.CategoryX ):
                //case (ChartAxisType.CategoryAngle):
                default:
                    return true;
            }
        }
예제 #10
0
        private void ConfigureScatterAxes(object o)
        {
            var x = new ChartAxisViewModel
                        {
                            AxisType = ChartAxisType.NumericX,
                            Name = XMemberPath,
                            DataSource = DataSource,
                            ValueMemberPath = XMemberPath,
                            LabelTemplate = "{" + LabelMemberPath + "}",
                            AxisLocation = AxisLocation.OutsideBottom
                        };
            var y = new ChartAxisViewModel
                        {
                            AxisType = ChartAxisType.NumericY,
                            Name = YMemberPath,
                            DataSource = DataSource,
                            ValueMemberPath = YMemberPath,
                            AxisLocation = AxisLocation.OutsideLeft
                        };

            XAxis = x;
            YAxis = y;
        }
예제 #11
0
        private void ConfigureRadialAxis(object o)
        {
            var i = o as SolidPSObjectBase;
            var value = i.GetPropValue<object>(AngleMemberPath);

            var r = new ChartAxisViewModel
            {
                AxisType = ChartAxisType.NumericRadius,
                AxisLocation = AxisLocation.InsideRight,

                Name = this.RadiusMemberPath,
                DataSource = this.DataSource,
                Dispatcher = this.Dispatcher,
                ValueMemberPath = RadiusMemberPath,
            };
            var a = new ChartAxisViewModel()
            {
                AxisType = ChartAxisType.CategoryAngle,
                //AxisLocation = AxisLocation.OutsideTop,
                AxisLocation = AxisLocation.OutsideBottom,

                Name = this.AngleMemberPath,
                DataSource = this.DataSource,
                ValueMemberPath = AngleMemberPath,
                LabelTemplate = "{" + LabelMemberPath + "}"
            };

            this.XAxis = a;
            this.YAxis = r;
        }
예제 #12
0
        private void ConfigurePolarAxis(object o)
        {
            var r = new ChartAxisViewModel
                        {
                            AxisType = ChartAxisType.NumericRadius,
                            Name = this.RadiusMemberPath,
                            DataSource = this.DataSource,
                            Dispatcher = this.Dispatcher,
                            ValueMemberPath = RadiusMemberPath,
                        };
            var a = new ChartAxisViewModel()
                        {
                            AxisType = ChartAxisType.NumericAngle,
                            AxisLocation=AxisLocation.OutsideBottom,
                            //AxisLocation=AxisLocation.OutsideTop,
                            Name = this.AngleMemberPath,
                            DataSource = this.DataSource,
                            ValueMemberPath = AngleMemberPath,
                            LabelTemplate = "{" + LabelMemberPath + "}"
                        };

            this.XAxis = a;
            this.YAxis = r;
        }
예제 #13
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;
        }