public StarsTrendsChart(IMainThread mainThread) : base(mainThread, TrendsPageAutomationIds.StarsChart) { var primaryAxisLabelStyle = new ChartAxisLabelStyle { FontSize = 9, FontFamily = FontFamilyConstants.RobotoRegular, Margin = new Thickness(2, 4, 2, 0) }.DynamicResource(ChartLabelStyle.TextColorProperty, nameof(BaseTheme.ChartAxisTextColor)); var axisLineStyle = new ChartLineStyle() { StrokeWidth = 1.51 }.DynamicResource(ChartLineStyle.StrokeColorProperty, nameof(BaseTheme.ChartAxisLineColor)); PrimaryAxis = new DateTimeAxis { IntervalType = DateTimeIntervalType.Months, Interval = 1, RangePadding = DateTimeRangePadding.Round, LabelStyle = primaryAxisLabelStyle, AxisLineStyle = axisLineStyle, MajorTickStyle = new ChartAxisTickStyle { StrokeColor = Color.Transparent }, ShowMajorGridLines = false, }; PrimaryAxis.SetBinding(DateTimeAxis.MinimumProperty, nameof(TrendsViewModel.MinDailyStarsDate)); PrimaryAxis.SetBinding(DateTimeAxis.MaximumProperty, nameof(TrendsViewModel.MaxDailyStarsDate)); var secondaryAxisMajorTickStyle = new ChartAxisTickStyle().DynamicResource(ChartAxisTickStyle.StrokeColorProperty, nameof(BaseTheme.ChartAxisLineColor)); var secondaryAxisLabelStyle = new ChartAxisLabelStyle { FontSize = 12, FontFamily = FontFamilyConstants.RobotoRegular, }.DynamicResource(ChartLabelStyle.TextColorProperty, nameof(BaseTheme.ChartAxisTextColor)); SecondaryAxis = new NumericalAxis { LabelStyle = secondaryAxisLabelStyle, AxisLineStyle = axisLineStyle, MajorTickStyle = secondaryAxisMajorTickStyle, ShowMajorGridLines = false, }.Bind(NumericalAxis.MinimumProperty, nameof(TrendsViewModel.MinDailyStarsValue)) .Bind(NumericalAxis.MaximumProperty, nameof(TrendsViewModel.MaxDailyStarsValue)) .Bind(NumericalAxis.IntervalProperty, nameof(TrendsViewModel.StarsChartYAxisInterval)); StarsSeries = new TrendsAreaSeries(TrendsChartTitleConstants.StarsTitle, nameof(DailyStarsModel.LocalDay), nameof(DailyStarsModel.TotalStars), nameof(BaseTheme.CardStarsStatsIconColor)); StarsSeries.SetBinding(ChartSeries.ItemsSourceProperty, nameof(TrendsViewModel.DailyStarsList)); StarsSeries.PropertyChanged += HandleStarSeriesPropertyChanged; Series = new ChartSeriesCollection { StarsSeries }; this.SetBinding(IsVisibleProperty, nameof(TrendsViewModel.IsStarsChartVisible)); }
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); }