private static void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, ChartLineDashStyle style) { Assert.AreEqual(color, lineStyle.Color); Assert.AreEqual(width, lineStyle.Width); Assert.AreEqual(style, lineStyle.DashStyle); Assert.IsTrue(lineStyle.IsEditable); }
protected override void SetSeriesStyle(ChartLineData data, LineSeries series) { ChartLineStyle style = data.Style; series.Color = ChartDataHelper.Convert(style.Color); series.StrokeThickness = style.Width; series.LineStyle = ChartDataHelper.Convert(style.DashStyle); }
private void ZoomLineStyle(ZoomBoundsInfo infos, ChartLineStyle lineStyle) { if (lineStyle.Thickness > 0 && !_zoomedLineStyles.Contains(lineStyle)) { lineStyle.Thickness = infos.Zoom(lineStyle.Thickness); _zoomedLineStyles.Add(lineStyle); } }
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)); }
/// <summary> /// Creates a new instance of <see cref="ChartLineData"/>. /// </summary> /// <param name="name">The name of the <see cref="ChartLineData"/>.</param> /// <param name="style">The style of the data.</param> /// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is /// <c>null</c> or only whitespace.</exception> /// <exception cref="ArgumentNullException">Thrown when <paramref name="style"/> /// is <c>null</c>.</exception> public ChartLineData(string name, ChartLineStyle style) : base(name) { if (style == null) { throw new ArgumentNullException(nameof(style)); } Style = style; }
/// <summary> /// Creates a new instance of <see cref="ChartMultipleLineData"/>. /// </summary> /// <param name="name">The name of the <see cref="ChartMultipleLineData"/>.</param> /// <param name="style">The style of the data.</param> /// <exception cref="ArgumentException">Thrown when <paramref name="name"/> is /// <c>null</c> or only whitespace.</exception> /// <exception cref="ArgumentNullException">Thrown when <paramref name="style"/> /// is <c>null</c>.</exception> public ChartMultipleLineData(string name, ChartLineStyle style) : base(name) { if (style == null) { throw new ArgumentNullException(nameof(style)); } Style = style; Lines = new List <Point2D[]>(); }
public void Width_SetValidValue_ValueSet(int validValue) { // Setup var lineStyle = new ChartLineStyle(); // Call lineStyle.Width = validValue; // Assert Assert.AreEqual(validValue, lineStyle.Width); }
public void Width_SetInvalidValue_ThrowsArgumentOutOfRangeException(int invalidValue) { // Setup var lineStyle = new ChartLineStyle(); // Call TestDelegate test = () => lineStyle.Width = invalidValue; // Assert const string message = "De waarde voor lijndikte moet in het bereik [0, 48] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(test, message); }
public void Constructor_WithStyle_ExpectedValue() { // Setup var style = new ChartLineStyle(); // Call var data = new ChartLineData("test data", style); // Assert Assert.AreEqual("test data", data.Name); CollectionAssert.IsEmpty(data.Points); Assert.IsInstanceOf <PointBasedChartData>(data); Assert.AreSame(style, data.Style); }
public void Constructor_WithStyle_SetsProperties() { // Setup Color color = Color.AliceBlue; const int width = 3; const ChartLineDashStyle style = ChartLineDashStyle.Solid; // Call var lineStyle = new ChartLineStyle { Color = color, Width = width, DashStyle = style, IsEditable = true }; // Assert Assert.AreEqual(color, lineStyle.Color); Assert.AreEqual(width, lineStyle.Width); Assert.AreEqual(style, lineStyle.DashStyle); Assert.IsTrue(lineStyle.IsEditable); }
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)); }
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); }
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); }
/// <summary> /// Configures the style for line series. /// </summary> /// <param name="style">The style. The default is normal.</param> /// <example> /// <code lang="CS"> /// <%= Html.Kendo().Chart() /// .Name("Chart") /// .Series(series => series /// .Line(s => s.Sales) /// .Style(ChartLineStyle.Step); /// ) /// %> /// </code> /// </example> public ChartLineSeriesBuilder <T> Style(ChartLineStyle style) { Series.Style = style; return(this); }