예제 #1
0
        public AreaSeriesChart()
        {
            const int numberOfDays = 20;
            const int maxValue     = 100;

            var dataSource = GenerateData(numberOfDays, maxValue).ToList();

            var areaSeries = new AreaSeries
            {
                Opacity      = 0.9,
                Label        = nameof(ChartDataModel),
                ItemsSource  = dataSource,
                XBindingPath = nameof(ChartDataModel.Date),
                YBindingPath = nameof(ChartDataModel.Value)
            };

            Series = new ChartSeriesCollection {
                areaSeries
            };

            PrimaryAxis = new DateTimeAxis
            {
                IntervalType = DateTimeIntervalType.Days,
                Interval     = 1,
                RangePadding = DateTimeRangePadding.Round,
                Minimum      = dataSource.Min(x => x.Date),
                Maximum      = dataSource.Max(x => x.Date)
            };

            SecondaryAxis = new NumericalAxis
            {
                Minimum = 0,
                Maximum = maxValue
            };

            ChartBehaviors = new ChartBehaviorCollection
            {
                new ChartZoomPanBehavior(),
                new ChartTrackballBehavior()
            };
        }
예제 #2
0
            public Chart()
            {
                Margin       = 0;
                ChartPadding = new Thickness(0, 24, 0, 4);

                BackgroundColor = Color.Transparent;

                AutomationId = TrendsPageAutomationIds.TrendsChart;

                TotalViewsSeries = new TrendsAreaSeries(TrendsChartConstants.TotalViewsTitle, nameof(DailyViewsModel.LocalDay), nameof(DailyViewsModel.TotalViews), nameof(BaseTheme.TotalViewsColor));
                TotalViewsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyViewsList));
                TotalViewsSeries.SetBinding(ChartSeries.IsVisibleProperty, nameof(TrendsViewModel.IsViewsSeriesVisible));

                TotalUniqueViewsSeries = new TrendsAreaSeries(TrendsChartConstants.UniqueViewsTitle, nameof(DailyViewsModel.LocalDay), nameof(DailyViewsModel.TotalUniqueViews), nameof(BaseTheme.TotalUniqueViewsColor));
                TotalUniqueViewsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyViewsList));
                TotalUniqueViewsSeries.SetBinding(ChartSeries.IsVisibleProperty, nameof(TrendsViewModel.IsUniqueViewsSeriesVisible));

                TotalClonesSeries = new TrendsAreaSeries(TrendsChartConstants.TotalClonesTitle, nameof(DailyClonesModel.LocalDay), nameof(DailyClonesModel.TotalClones), nameof(BaseTheme.TotalClonesColor));
                TotalClonesSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyClonesList));
                TotalClonesSeries.SetBinding(ChartSeries.IsVisibleProperty, nameof(TrendsViewModel.IsClonesSeriesVisible));

                TotalUniqueClonesSeries = new TrendsAreaSeries(TrendsChartConstants.UniqueClonesTitle, nameof(DailyClonesModel.LocalDay), nameof(DailyClonesModel.TotalUniqueClones), nameof(BaseTheme.TotalUniqueClonesColor));
                TotalUniqueClonesSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyClonesList));
                TotalUniqueClonesSeries.SetBinding(ChartSeries.IsVisibleProperty, nameof(TrendsViewModel.IsUniqueClonesSeriesVisible));

                ChartBehaviors = new ChartBehaviorCollection
                {
                    new ChartZoomPanBehavior(),
                    new ChartTrackballBehavior()
                };

                Series = new ChartSeriesCollection
                {
                    TotalViewsSeries,
                    TotalUniqueViewsSeries,
                    TotalClonesSeries,
                    TotalUniqueClonesSeries,
                };

                var primaryAxisLabelStyle = new ChartAxisLabelStyle
                {
                    FontSize   = 9,
                    FontFamily = FontFamilyConstants.RobotoRegular,
                    Margin     = new Thickness(2, 4, 2, 0)
                };

                primaryAxisLabelStyle.SetDynamicResource(ChartLabelStyle.TextColorProperty, nameof(BaseTheme.ChartAxisTextColor));

                var axisLineStyle = new ChartLineStyle()
                {
                    StrokeWidth = 1.51
                };

                axisLineStyle.SetDynamicResource(ChartLineStyle.StrokeColorProperty, nameof(BaseTheme.ChartAxisLineColor));

                PrimaryAxis = new DateTimeAxis
                {
                    AutomationId   = TrendsPageAutomationIds.TrendsChartPrimaryAxis,
                    IntervalType   = DateTimeIntervalType.Days,
                    Interval       = 1,
                    RangePadding   = DateTimeRangePadding.Round,
                    LabelStyle     = primaryAxisLabelStyle,
                    AxisLineStyle  = axisLineStyle,
                    MajorTickStyle = new ChartAxisTickStyle {
                        StrokeColor = Color.Transparent
                    },
                    ShowMajorGridLines = false,
                };
                PrimaryAxis.SetBinding(DateTimeAxis.MinimumProperty, nameof(TrendsViewModel.MinDateValue));
                PrimaryAxis.SetBinding(DateTimeAxis.MaximumProperty, nameof(TrendsViewModel.MaxDateValue));

                var secondaryAxisMajorTickStyle = new ChartAxisTickStyle();

                secondaryAxisMajorTickStyle.SetDynamicResource(ChartAxisTickStyle.StrokeColorProperty, nameof(BaseTheme.ChartAxisLineColor));

                var secondaryAxisLabelStyle = new ChartAxisLabelStyle
                {
                    FontSize   = 12,
                    FontFamily = FontFamilyConstants.RobotoRegular,
                };

                secondaryAxisLabelStyle.SetDynamicResource(ChartLabelStyle.TextColorProperty, nameof(BaseTheme.ChartAxisTextColor));

                SecondaryAxis = new NumericalAxis
                {
                    AutomationId       = TrendsPageAutomationIds.TrendsChartSecondaryAxis,
                    LabelStyle         = secondaryAxisLabelStyle,
                    AxisLineStyle      = axisLineStyle,
                    MajorTickStyle     = secondaryAxisMajorTickStyle,
                    ShowMajorGridLines = false
                };
                SecondaryAxis.SetBinding(NumericalAxis.MinimumProperty, nameof(TrendsViewModel.DailyViewsClonesMinValue));
                SecondaryAxis.SetBinding(NumericalAxis.MaximumProperty, nameof(TrendsViewModel.DailyViewsClonesMaxValue));
            }
예제 #3
0
            public GitHubTrendsChart()
            {
                TotalViewsSeries = new TrendsAreaSeries("Views", nameof(DailyViewsModel.LocalDay), nameof(DailyViewsModel.TotalViews), ColorConstants.DarkestBlue);
                TotalViewsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyViewsList));

                TotalUniqueViewsSeries = new TrendsAreaSeries("Unique Views", nameof(DailyViewsModel.LocalDay), nameof(DailyViewsModel.TotalUniqueViews), ColorConstants.MediumBlue);
                TotalUniqueViewsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyViewsList));

                TotalClonesSeries = new TrendsAreaSeries("Clones", nameof(DailyClonesModel.LocalDay), nameof(DailyClonesModel.TotalClones), ColorConstants.DarkNavyBlue);
                TotalClonesSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyClonesList));

                TotalUniqueClonesSeries = new TrendsAreaSeries("Unique Clones", nameof(DailyClonesModel.LocalDay), nameof(DailyClonesModel.TotalUniqueClones), ColorConstants.LightNavyBlue);
                TotalUniqueClonesSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyClonesList));

                this.SetBinding(IsVisibleProperty, nameof(TrendsViewModel.IsChartVisible));

                ChartBehaviors = new ChartBehaviorCollection
                {
                    new ChartZoomPanBehavior(),
                    new ChartTrackballBehavior()
                };

                Series = new ChartSeriesCollection
                {
                    TotalViewsSeries,
                    TotalUniqueViewsSeries,
                    TotalClonesSeries,
                    TotalUniqueClonesSeries
                };

                Legend = new ChartLegend
                {
                    DockPosition           = LegendPlacement.Bottom,
                    ToggleSeriesVisibility = true,
                    IconWidth  = 20,
                    IconHeight = 20,
                    LabelStyle = new ChartLegendLabelStyle {
                        TextColor = ColorConstants.DarkNavyBlue
                    }
                };

                var axisLabelStyle = new ChartAxisLabelStyle
                {
                    TextColor = ColorConstants.DarkNavyBlue,
                    FontSize  = 14
                };
                var axisLineStyle = new ChartLineStyle {
                    StrokeColor = ColorConstants.LightNavyBlue
                };

                PrimaryAxis = new DateTimeAxis
                {
                    IntervalType   = DateTimeIntervalType.Days,
                    Interval       = 1,
                    RangePadding   = DateTimeRangePadding.Round,
                    LabelStyle     = axisLabelStyle,
                    AxisLineStyle  = axisLineStyle,
                    MajorTickStyle = new ChartAxisTickStyle {
                        StrokeColor = Color.Transparent
                    },
                    ShowMajorGridLines = false
                };
                PrimaryAxis.SetBinding(DateTimeAxis.MinimumProperty, nameof(TrendsViewModel.MinDateValue));
                PrimaryAxis.SetBinding(DateTimeAxis.MaximumProperty, nameof(TrendsViewModel.MaxDateValue));

                SecondaryAxis = new NumericalAxis
                {
                    LabelStyle     = axisLabelStyle,
                    AxisLineStyle  = axisLineStyle,
                    MajorTickStyle = new ChartAxisTickStyle {
                        StrokeColor = ColorConstants.LightNavyBlue
                    },
                    ShowMajorGridLines = false
                };
                SecondaryAxis.SetBinding(NumericalAxis.MinimumProperty, nameof(TrendsViewModel.DailyViewsClonesMinValue));
                SecondaryAxis.SetBinding(NumericalAxis.MaximumProperty, nameof(TrendsViewModel.DailyViewsClonesMaxValue));

                BackgroundColor = Color.Transparent;

                ChartPadding = new Thickness(0, 5, 0, 0);
                Margin       = Device.RuntimePlatform is Device.iOS ? new Thickness(0, 5, 0, 15) : new Thickness(0, 5, 0, 0);
            }
예제 #4
0
            public GitHubTrendsChart()
            {
                AutomationId = TrendsPageAutomationIds.TrendsChart;

                TotalViewsSeries = new TrendsAreaSeries("Views", nameof(DailyViewsModel.LocalDay), nameof(DailyViewsModel.TotalViews), nameof(BaseTheme.TotalViewsColor), TrendsPageAutomationIds.TotalViewsSeries);
                TotalViewsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyViewsList));

                TotalUniqueViewsSeries = new TrendsAreaSeries("Unique Views", nameof(DailyViewsModel.LocalDay), nameof(DailyViewsModel.TotalUniqueViews), nameof(BaseTheme.TotalUniqueViewsColor), TrendsPageAutomationIds.TotalUniqueViewsSeries);
                TotalUniqueViewsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyViewsList));

                TotalClonesSeries = new TrendsAreaSeries("Clones", nameof(DailyClonesModel.LocalDay), nameof(DailyClonesModel.TotalClones), nameof(BaseTheme.TotalClonesColor), TrendsPageAutomationIds.TotalClonesSeries);
                TotalClonesSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyClonesList));

                TotalUniqueClonesSeries = new TrendsAreaSeries("Unique Clones", nameof(DailyClonesModel.LocalDay), nameof(DailyClonesModel.TotalUniqueClones), nameof(BaseTheme.TotalUniqueClonesColor), TrendsPageAutomationIds.TotalUniqueClonesSeries);
                TotalUniqueClonesSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyClonesList));

                this.SetBinding(IsVisibleProperty, nameof(TrendsViewModel.IsChartVisible));

                ChartBehaviors = new ChartBehaviorCollection
                {
                    new ChartZoomPanBehavior(),
                    new ChartTrackballBehavior()
                };

                Series = new ChartSeriesCollection
                {
                    TotalViewsSeries,
                    TotalUniqueViewsSeries,
                    TotalClonesSeries,
                    TotalUniqueClonesSeries
                };

                var chartLegendLabelStyle = new ChartLegendLabelStyle();

                chartLegendLabelStyle.SetDynamicResource(ChartLegendLabelStyle.TextColorProperty, nameof(BaseTheme.ChartAxisTextColor));

                Legend = new ChartLegend
                {
                    AutomationId           = TrendsPageAutomationIds.TrendsChartLegend,
                    DockPosition           = LegendPlacement.Bottom,
                    ToggleSeriesVisibility = true,
                    IconWidth  = 20,
                    IconHeight = 20,
                    LabelStyle = chartLegendLabelStyle
                };

                var axisLabelStyle = new ChartAxisLabelStyle
                {
                    FontSize = 14
                };

                axisLabelStyle.SetDynamicResource(ChartAxisLabelStyle.TextColorProperty, nameof(BaseTheme.ChartAxisTextColor));

                var axisLineStyle = new ChartLineStyle();

                axisLineStyle.SetDynamicResource(ChartLineStyle.StrokeColorProperty, nameof(BaseTheme.ChartAxisLineColor));

                PrimaryAxis = new DateTimeAxis
                {
                    AutomationId   = TrendsPageAutomationIds.TrendsChartPrimaryAxis,
                    IntervalType   = DateTimeIntervalType.Days,
                    Interval       = 1,
                    RangePadding   = DateTimeRangePadding.Round,
                    LabelStyle     = axisLabelStyle,
                    AxisLineStyle  = axisLineStyle,
                    MajorTickStyle = new ChartAxisTickStyle {
                        StrokeColor = Color.Transparent
                    },
                    ShowMajorGridLines = false
                };
                PrimaryAxis.SetBinding(DateTimeAxis.MinimumProperty, nameof(TrendsViewModel.MinDateValue));
                PrimaryAxis.SetBinding(DateTimeAxis.MaximumProperty, nameof(TrendsViewModel.MaxDateValue));

                var secondaryAxisMajorTickStyle = new ChartAxisTickStyle();

                secondaryAxisMajorTickStyle.SetDynamicResource(ChartAxisTickStyle.StrokeColorProperty, nameof(BaseTheme.ChartAxisLineColor));

                SecondaryAxis = new NumericalAxis
                {
                    AutomationId       = TrendsPageAutomationIds.TrendsChartSecondaryAxis,
                    LabelStyle         = axisLabelStyle,
                    AxisLineStyle      = axisLineStyle,
                    MajorTickStyle     = secondaryAxisMajorTickStyle,
                    ShowMajorGridLines = false
                };
                SecondaryAxis.SetBinding(NumericalAxis.MinimumProperty, nameof(TrendsViewModel.DailyViewsClonesMinValue));
                SecondaryAxis.SetBinding(NumericalAxis.MaximumProperty, nameof(TrendsViewModel.DailyViewsClonesMaxValue));

                BackgroundColor = Color.Transparent;

                ChartPadding = new Thickness(0, 5, 0, 0);
            }