From c7064ec2239caead852ef81b01c08aedb3b27590 Mon Sep 17 00:00:00 2001 From: Dilyan Traykov Date: Wed, 25 Jan 2023 14:18:04 +0200 Subject: [PATCH 1/6] Draw line elements when they contain only two points. --- .../CartesianChart/Indicators/BollingerBandsIndicator.cs | 2 +- .../CartesianChart/Indicators/LineIndicatorBase.cs | 2 +- .../CartesianChart/Indicators/StochasticFastIndicator.cs | 2 +- .../Series/Categorical/CategoricalStrokedSeries.cs | 2 +- .../CartesianChart/Series/Scatter/ScatterLineSeries.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/BollingerBandsIndicator.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/BollingerBandsIndicator.cs index 0b1cbe26..ae05c0b5 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/BollingerBandsIndicator.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/BollingerBandsIndicator.cs @@ -122,7 +122,7 @@ internal override void UpdateUICore(ChartLayoutContext context) this.lowerBandRenderer.Render(this.drawWithComposition); - if (this.drawWithComposition && this.lowerBandRenderer.renderPoints.Count > 2) + if (this.drawWithComposition && this.lowerBandRenderer.renderPoints.Count >= 2) { foreach (DataPointSegment dataSegment in ChartSeriesRenderer.GetDataSegments(this.lowerBandRenderer.renderPoints)) { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/LineIndicatorBase.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/LineIndicatorBase.cs index 80681a6b..16608e76 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/LineIndicatorBase.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/LineIndicatorBase.cs @@ -136,7 +136,7 @@ internal override void UpdateUICore(ChartLayoutContext context) this.renderer.Render(this.drawWithComposition); - if (this.drawWithComposition && this.renderer.renderPoints.Count > 2) + if (this.drawWithComposition && this.renderer.renderPoints.Count >= 2) { foreach (DataPointSegment dataSegment in ChartSeriesRenderer.GetDataSegments(this.renderer.renderPoints)) { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/StochasticFastIndicator.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/StochasticFastIndicator.cs index 578642d5..598fc901 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/StochasticFastIndicator.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Indicators/StochasticFastIndicator.cs @@ -135,7 +135,7 @@ internal override void UpdateUICore(ChartLayoutContext context) this.signalRenderer.Render(this.drawWithComposition); - if (this.drawWithComposition && this.signalRenderer.renderPoints.Count > 2) + if (this.drawWithComposition && this.signalRenderer.renderPoints.Count >= 2) { foreach (DataPointSegment dataSegment in ChartSeriesRenderer.GetDataSegments(this.signalRenderer.renderPoints)) { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/CategoricalStrokedSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/CategoricalStrokedSeries.cs index 92984998..2d28a29d 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/CategoricalStrokedSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/CategoricalStrokedSeries.cs @@ -153,7 +153,7 @@ internal override void UpdateUICore(ChartLayoutContext context) { this.renderer.Render(this.drawWithComposition); - if (this.drawWithComposition && this.renderer.renderPoints.Count > 2) + if (this.drawWithComposition && this.renderer.renderPoints.Count >= 2) { foreach (DataPointSegment dataSegment in ChartSeriesRenderer.GetDataSegments(this.renderer.renderPoints)) { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterLineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterLineSeries.cs index cfdca988..5b2b8031 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterLineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterLineSeries.cs @@ -168,7 +168,7 @@ internal override void UpdateUICore(ChartLayoutContext context) { this.renderer.Render(this.drawWithComposition); - if (this.drawWithComposition && this.renderer.renderPoints.Count > 2) + if (this.drawWithComposition && this.renderer.renderPoints.Count >= 2) { foreach (DataPointSegment dataSegment in ChartSeriesRenderer.GetDataSegments(this.renderer.renderPoints)) { From fd9bfde7902771d139daaaaf19bf4671da116d0a Mon Sep 17 00:00:00 2001 From: Dilyan Traykov Date: Wed, 1 Feb 2023 15:02:13 +0200 Subject: [PATCH 2/6] Expose SplineTension property for spline series. --- .../Series/Categorical/SplineAreaSeries.cs | 30 ++++++++++++++++- .../Series/Categorical/SplineSeries.cs | 32 +++++++++++++++++-- .../Series/Scatter/ScatterSplineAreaSeries.cs | 30 ++++++++++++++++- .../Series/Scatter/ScatterSplineSeries.cs | 30 ++++++++++++++++- .../Cartesian/Spline/SplineAreaRenderer.cs | 4 ++- .../Cartesian/Spline/SplineRenderer.cs | 4 ++- .../Polar/Polar/PolarSplineRenderer.cs | 4 ++- .../Polar/Radar/RadarSplineRenderer.cs | 4 ++- .../Visualization/Common/SplineHelper.cs | 29 +++++++++-------- .../Series/PolarSplineAreaSeries.cs | 30 ++++++++++++++++- .../PolarChart/Series/PolarSplineSeries.cs | 30 ++++++++++++++++- .../Series/RadarSplineAreaSeries.cs | 30 ++++++++++++++++- .../PolarChart/Series/RadarSplineSeries.cs | 32 +++++++++++++++++-- 13 files changed, 262 insertions(+), 27 deletions(-) diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs index 907a8e0e..279283fa 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs @@ -1,6 +1,7 @@ using System; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -9,6 +10,12 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class SplineAreaSeries : AreaSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(SplineAreaSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -17,9 +24,30 @@ public SplineAreaSeries() this.DefaultStyleKey = typeof(SplineAreaSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + SplineAreaSeries series = (SplineAreaSeries)d; + SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override LineRenderer CreateRenderer() { - return new SplineAreaRenderer(); + return new SplineAreaRenderer() + { + splineTension = this.SplineTension + }; } /// diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs index b7344a2b..986512bc 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs @@ -1,14 +1,21 @@ using System; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { /// - /// Visualizes a collection of data points using a smooth shape. + /// Visualizes a collection of data points using a smooth shape. /// public class SplineSeries : LineSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(SplineSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -17,9 +24,30 @@ public SplineSeries() this.DefaultStyleKey = typeof(SplineSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + SplineSeries series = (SplineSeries)d; + SplineRenderer renderer = (SplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override LineRenderer CreateRenderer() { - return new SplineRenderer(); + return new SplineRenderer() + { + splineTension = this.SplineTension + }; } /// diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs index 7f614719..8ad68b7a 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs @@ -2,6 +2,7 @@ using Telerik.Charting; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -10,6 +11,12 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class ScatterSplineAreaSeries : ScatterAreaSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(ScatterSplineAreaSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -18,9 +25,30 @@ public ScatterSplineAreaSeries() this.DefaultStyleKey = typeof(ScatterSplineAreaSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ScatterSplineAreaSeries series = (ScatterSplineAreaSeries)d; + SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override LineRenderer CreateRenderer() { - return new SplineAreaRenderer(); + return new SplineAreaRenderer() + { + splineTension = this.SplineTension + }; } /// diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs index 64ac5673..567012b7 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs @@ -2,6 +2,7 @@ using Telerik.Charting; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -10,6 +11,12 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class ScatterSplineSeries : ScatterLineSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(ScatterSplineSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -18,9 +25,30 @@ public ScatterSplineSeries() this.DefaultStyleKey = typeof(ScatterSplineSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ScatterSplineSeries series = (ScatterSplineSeries)d; + SplineRenderer renderer = (SplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override LineRenderer CreateRenderer() { - return new SplineRenderer(); + return new SplineRenderer() + { + splineTension = this.SplineTension + }; } /// diff --git a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineAreaRenderer.cs b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineAreaRenderer.cs index 6ea3eb8f..63f4ab8c 100644 --- a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineAreaRenderer.cs +++ b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineAreaRenderer.cs @@ -7,6 +7,8 @@ namespace Telerik.UI.Xaml.Controls.Chart { internal class SplineAreaRenderer : AreaRenderer { + internal double splineTension; + protected override IEnumerable GetTopPoints(DataPointSegment segment) { // return the first point since spline segmentation skips it @@ -15,7 +17,7 @@ protected override IEnumerable GetTopPoints(DataPointSegment segment) IChartView view = this.model.GetChartArea().view; double scaleFactor = Math.Abs(view.ZoomWidth - view.ZoomHeight) / 2; - foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor)) + foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor, this.splineTension)) { yield return point; } diff --git a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineRenderer.cs b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineRenderer.cs index 7dfecbe5..a12e2861 100644 --- a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineRenderer.cs +++ b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Cartesian/Spline/SplineRenderer.cs @@ -7,6 +7,8 @@ namespace Telerik.UI.Xaml.Controls.Chart { internal class SplineRenderer : LineRenderer { + internal double splineTension; + protected internal override IEnumerable GetPoints(DataPointSegment segment) { // return the first point since spline segmentation skips it @@ -15,7 +17,7 @@ protected internal override IEnumerable GetPoints(DataPointSegment segmen IChartView view = this.model.GetChartArea().view; double scaleFactor = Math.Abs(view.ZoomWidth - view.ZoomHeight) / 2; - foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor)) + foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor, this.splineTension)) { yield return point; } diff --git a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Polar/PolarSplineRenderer.cs b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Polar/PolarSplineRenderer.cs index b66f51ef..bd435888 100644 --- a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Polar/PolarSplineRenderer.cs +++ b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Polar/PolarSplineRenderer.cs @@ -8,6 +8,8 @@ namespace Telerik.UI.Xaml.Controls.Chart { internal class PolarSplineRenderer : PolarLineRenderer { + internal double splineTension; + protected internal override IEnumerable GetPoints(DataPointSegment segment) { // return the first point since spline segmentation skips it @@ -16,7 +18,7 @@ protected internal override IEnumerable GetPoints(DataPointSegment segmen IChartView view = this.model.GetChartArea().view; double scaleFactor = Math.Abs(view.ZoomWidth - view.ZoomHeight) / 2; - foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor, this.isClosed)) + foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor, this.splineTension, this.isClosed)) { yield return point; } diff --git a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Radar/RadarSplineRenderer.cs b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Radar/RadarSplineRenderer.cs index 2b37f5df..bed76b2c 100644 --- a/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Radar/RadarSplineRenderer.cs +++ b/Controls/Chart/Chart.UWP/Visualization/Common/Renderers/Polar/Radar/RadarSplineRenderer.cs @@ -8,6 +8,8 @@ namespace Telerik.UI.Xaml.Controls.Chart { internal class RadarSplineRenderer : RadarLineRenderer { + internal double splineTension; + protected internal override IEnumerable GetPoints(DataPointSegment segment) { // return the first point since spline segmentation skips it @@ -16,7 +18,7 @@ protected internal override IEnumerable GetPoints(DataPointSegment segmen IChartView view = this.model.GetChartArea().view; double scaleFactor = Math.Abs(view.ZoomWidth - view.ZoomHeight) / 2; - foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor, this.isClosed)) + foreach (Point point in SplineHelper.GetSplinePoints(this.renderPoints, segment, scaleFactor, this.splineTension, this.isClosed)) { yield return point; } diff --git a/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs b/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs index 8c9c0b86..100159d0 100644 --- a/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs +++ b/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs @@ -8,10 +8,10 @@ namespace Telerik.UI.Xaml.Controls.Chart internal static class SplineHelper { // TODO: Should we expose these as public properties for Spline and SplineArea series? - private const double DefaultTension = 0.5d; + internal const double DefaultTension = 0.5d; private const double DefaultTolerance = 5d; - public static IEnumerable GetSplinePoints(IList dataPoints, DataPointSegment dataSegment, double scaleFactor, bool isClosedShape = false) + public static IEnumerable GetSplinePoints(IList dataPoints, DataPointSegment dataSegment, double scaleFactor, double tension = DefaultTension, bool isClosedShape = false) { double tolerance = DefaultTolerance; if (scaleFactor > 2) @@ -29,7 +29,7 @@ public static IEnumerable GetSplinePoints(IList dataPoints, Da Point firstPoint = dataPoints[dataSegment.StartIndex].Center(); Point secondPoint = dataPoints[dataSegment.EndIndex].Center(); - foreach (Point segmentedPoint in Segment(startPoint, firstPoint, secondPoint, endPoint, tolerance)) + foreach (Point segmentedPoint in Segment(startPoint, firstPoint, secondPoint, endPoint, tolerance, tension)) { yield return segmentedPoint; } @@ -48,7 +48,8 @@ public static IEnumerable GetSplinePoints(IList dataPoints, Da dataPoints[i].Center(), dataPoints[i + 1].Center(), dataPoints[i + 2].Center(), - tolerance); + tolerance, + tension); } else if (i == dataSegment.EndIndex - 1) { @@ -57,7 +58,8 @@ public static IEnumerable GetSplinePoints(IList dataPoints, Da dataPoints[i].Center(), dataPoints[i + 1].Center(), endPoint, - tolerance); + tolerance, + tension); } else { @@ -66,7 +68,8 @@ public static IEnumerable GetSplinePoints(IList dataPoints, Da dataPoints[i].Center(), dataPoints[i + 1].Center(), dataPoints[i + 2].Center(), - tolerance); + tolerance, + tension); } foreach (Point point in segmentedPoints) @@ -76,7 +79,7 @@ public static IEnumerable GetSplinePoints(IList dataPoints, Da } } - public static IEnumerable GetSplinePointsConnectingAbsoluteFirstLastDataPoints(IList dataPoints, double scaleFactor) + public static IEnumerable GetSplinePointsConnectingAbsoluteFirstLastDataPoints(IList dataPoints, double scaleFactor, double tension = DefaultTension) { DataPoint firstPoint = dataPoints[0]; DataPoint lastPoint = dataPoints[dataPoints.Count - 1]; @@ -99,18 +102,18 @@ public static IEnumerable GetSplinePointsConnectingAbsoluteFirstLastDataP // return the first point since spline segmentation skips it yield return lastPoint.Center(); - foreach (Point point in Segment(previousSignificantPointBeforeAbsoluteLast.Center(), lastPoint.Center(), firstPoint.Center(), nextSignificantPointAfterAbsoluteFirst.Center(), tolerance)) + foreach (Point point in Segment(previousSignificantPointBeforeAbsoluteLast.Center(), lastPoint.Center(), firstPoint.Center(), nextSignificantPointAfterAbsoluteFirst.Center(), tolerance, tension)) { yield return point; } } - private static IEnumerable Segment(Point pt0, Point pt1, Point pt2, Point pt3, double tolerance) + private static IEnumerable Segment(Point pt0, Point pt1, Point pt2, Point pt3, double tolerance, double tension) { - double sX1 = DefaultTension * (pt2.X - pt0.X); - double sY1 = DefaultTension * (pt2.Y - pt0.Y); - double sX2 = DefaultTension * (pt3.X - pt1.X); - double sY2 = DefaultTension * (pt3.Y - pt1.Y); + double sX1 = tension * (pt2.X - pt0.X); + double sY1 = tension * (pt2.Y - pt0.Y); + double sX2 = tension * (pt3.X - pt1.X); + double sY2 = tension * (pt3.Y - pt1.Y); double ax = sX1 + sX2 + (2 * pt1.X) - (2 * pt2.X); double ay = sY1 + sY2 + (2 * pt1.Y) - (2 * pt2.Y); diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs index 821d4695..41fdf5f4 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -11,6 +12,12 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class PolarSplineAreaSeries : PolarAreaSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(PolarSplineAreaSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -19,9 +26,30 @@ public PolarSplineAreaSeries() this.DefaultStyleKey = typeof(PolarSplineAreaSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + PolarSplineAreaSeries series = (PolarSplineAreaSeries)d; + PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override PolarLineRenderer CreateRenderer() { - return new PolarSplineRenderer(); + return new PolarSplineRenderer() + { + splineTension = this.SplineTension + }; } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs index 5ec4468f..2477c380 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -11,6 +12,12 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class PolarSplineSeries : PolarLineSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(PolarSplineSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -19,9 +26,30 @@ public PolarSplineSeries() this.DefaultStyleKey = typeof(PolarSplineSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + PolarSplineSeries series = (PolarSplineSeries)d; + PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override PolarLineRenderer CreateRenderer() { - return new PolarSplineRenderer(); + return new PolarSplineRenderer() + { + splineTension = this.SplineTension + }; } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs index 5ba522e4..bf383273 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -13,6 +14,12 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class RadarSplineAreaSeries : RadarAreaSeries { + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(RadarSplineAreaSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + /// /// Initializes a new instance of the class. /// @@ -21,9 +28,30 @@ public RadarSplineAreaSeries() this.DefaultStyleKey = typeof(RadarSplineAreaSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RadarSplineAreaSeries series = (RadarSplineAreaSeries)d; + RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override RadarLineRenderer CreateRenderer() { - return new RadarSplineRenderer(); + return new RadarSplineRenderer() + { + splineTension = this.SplineTension + }; } /// diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs index a3b7cf3c..6646adb6 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart { @@ -13,7 +14,13 @@ namespace Telerik.UI.Xaml.Controls.Chart /// public class RadarSplineSeries : RadarLineSeries { - /// + /// + /// Identifies the property. + /// + public static readonly DependencyProperty SplineTensionProperty = + DependencyProperty.Register("SplineTension", typeof(double), typeof(RadarSplineSeries), new PropertyMetadata(SplineHelper.DefaultTension, OnSplineTensionChanged)); + + /// /// Initializes a new instance of the class. /// public RadarSplineSeries() @@ -21,9 +28,30 @@ public RadarSplineSeries() this.DefaultStyleKey = typeof(RadarSplineSeries); } + /// + /// Gets or sets the that is used to determine the tension of the additional spline points. + /// The default value is 0.5d. + /// + public double SplineTension + { + get { return (double)GetValue(SplineTensionProperty); } + set { SetValue(SplineTensionProperty, value); } + } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RadarSplineSeries series = (RadarSplineSeries)d; + RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } + internal override RadarLineRenderer CreateRenderer() { - return new RadarSplineRenderer(); + return new RadarSplineRenderer() + { + splineTension = this.SplineTension + }; } /// From a31cb9ebf241df37dc597c267b509d25e0003d80 Mon Sep 17 00:00:00 2001 From: Dilyan Traykov Date: Wed, 1 Feb 2023 15:28:08 +0200 Subject: [PATCH 3/6] Fix StyleCop warnings. --- .../Series/Categorical/SplineAreaSeries.cs | 25 ++++++++-------- .../Series/Categorical/SplineSeries.cs | 25 ++++++++-------- .../Series/Scatter/ScatterSplineAreaSeries.cs | 25 ++++++++-------- .../Series/Scatter/ScatterSplineSeries.cs | 25 ++++++++-------- .../Series/PolarSplineAreaSeries.cs | 20 ++++++------- .../PolarChart/Series/PolarSplineSeries.cs | 20 ++++++------- .../Series/RadarSplineAreaSeries.cs | 29 ++++++++----------- .../PolarChart/Series/RadarSplineSeries.cs | 29 ++++++++----------- 8 files changed, 92 insertions(+), 106 deletions(-) diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs index 279283fa..dd02f66a 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs @@ -1,7 +1,6 @@ -using System; -using Telerik.UI.Automation.Peers; -using Windows.UI.Xaml.Automation.Peers; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation.Peers; namespace Telerik.UI.Xaml.Controls.Chart { @@ -30,16 +29,8 @@ public SplineAreaSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - SplineAreaSeries series = (SplineAreaSeries)d; - SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override LineRenderer CreateRenderer() @@ -55,5 +46,13 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new SplineAreaSeriesAutomationPeer(this); } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + SplineAreaSeries series = (SplineAreaSeries)d; + SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs index 986512bc..ed38a6f1 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs @@ -1,7 +1,6 @@ -using System; -using Telerik.UI.Automation.Peers; -using Windows.UI.Xaml.Automation.Peers; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation.Peers; namespace Telerik.UI.Xaml.Controls.Chart { @@ -30,16 +29,8 @@ public SplineSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - SplineSeries series = (SplineSeries)d; - SplineRenderer renderer = (SplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override LineRenderer CreateRenderer() @@ -55,5 +46,13 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new SplineSeriesAutomationPeer(this); } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + SplineSeries series = (SplineSeries)d; + SplineRenderer renderer = (SplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs index 8ad68b7a..1ebb868e 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs @@ -1,8 +1,7 @@ -using System; -using Telerik.Charting; +using Telerik.Charting; using Telerik.UI.Automation.Peers; -using Windows.UI.Xaml.Automation.Peers; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation.Peers; namespace Telerik.UI.Xaml.Controls.Chart { @@ -31,16 +30,8 @@ public ScatterSplineAreaSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - ScatterSplineAreaSeries series = (ScatterSplineAreaSeries)d; - SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override LineRenderer CreateRenderer() @@ -56,5 +47,13 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new ScatterSplineAreaSeriesAutomationPeer(this); } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ScatterSplineAreaSeries series = (ScatterSplineAreaSeries)d; + SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs index 567012b7..ad3837c5 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs @@ -1,8 +1,7 @@ -using System; -using Telerik.Charting; +using Telerik.Charting; using Telerik.UI.Automation.Peers; -using Windows.UI.Xaml.Automation.Peers; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation.Peers; namespace Telerik.UI.Xaml.Controls.Chart { @@ -31,16 +30,8 @@ public ScatterSplineSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - ScatterSplineSeries series = (ScatterSplineSeries)d; - SplineRenderer renderer = (SplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override LineRenderer CreateRenderer() @@ -56,5 +47,13 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new ScatterSplineSeriesAutomationPeer(this); } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ScatterSplineSeries series = (ScatterSplineSeries)d; + SplineRenderer renderer = (SplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs index 41fdf5f4..0120131f 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs @@ -32,16 +32,8 @@ public PolarSplineAreaSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - PolarSplineAreaSeries series = (PolarSplineAreaSeries)d; - PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override PolarLineRenderer CreateRenderer() @@ -51,5 +43,13 @@ internal override PolarLineRenderer CreateRenderer() splineTension = this.SplineTension }; } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + PolarSplineAreaSeries series = (PolarSplineAreaSeries)d; + PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs index 2477c380..4cf90295 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs @@ -32,16 +32,8 @@ public PolarSplineSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - PolarSplineSeries series = (PolarSplineSeries)d; - PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override PolarLineRenderer CreateRenderer() @@ -51,5 +43,13 @@ internal override PolarLineRenderer CreateRenderer() splineTension = this.SplineTension }; } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + PolarSplineSeries series = (PolarSplineSeries)d; + PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs index bf383273..b8e6e6e0 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Telerik.UI.Automation.Peers; -using Windows.UI.Xaml.Automation.Peers; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation.Peers; namespace Telerik.UI.Xaml.Controls.Chart { @@ -34,16 +29,8 @@ public RadarSplineAreaSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RadarSplineAreaSeries series = (RadarSplineAreaSeries)d; - RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override RadarLineRenderer CreateRenderer() @@ -59,5 +46,13 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new RadarSplineAreaSeriesAutomationPeer(this); } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RadarSplineAreaSeries series = (RadarSplineAreaSeries)d; + RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs index 6646adb6..dd875065 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Telerik.UI.Automation.Peers; -using Windows.UI.Xaml.Automation.Peers; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; +using Windows.UI.Xaml.Automation.Peers; namespace Telerik.UI.Xaml.Controls.Chart { @@ -34,16 +29,8 @@ public RadarSplineSeries() /// public double SplineTension { - get { return (double)GetValue(SplineTensionProperty); } - set { SetValue(SplineTensionProperty, value); } - } - - private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - RadarSplineSeries series = (RadarSplineSeries)d; - RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; - series.InvalidateCore(); + get { return (double)this.GetValue(SplineTensionProperty); } + set { this.SetValue(SplineTensionProperty, value); } } internal override RadarLineRenderer CreateRenderer() @@ -59,5 +46,13 @@ protected override AutomationPeer OnCreateAutomationPeer() { return new RadarSplineSeriesAutomationPeer(this); } + + private static void OnSplineTensionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RadarSplineSeries series = (RadarSplineSeries)d; + RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; + renderer.splineTension = (double)e.NewValue; + series.InvalidateCore(); + } } } From 6cf85fbbbb9700d7b3b58f6aaa99e303f6b949b6 Mon Sep 17 00:00:00 2001 From: Dilyan Traykov Date: Wed, 1 Feb 2023 18:28:57 +0200 Subject: [PATCH 4/6] Coerce value and introduce constants. --- .../CartesianChart/Series/Categorical/SplineAreaSeries.cs | 5 +++-- .../CartesianChart/Series/Categorical/SplineSeries.cs | 5 +++-- .../CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs | 3 ++- .../CartesianChart/Series/Scatter/ScatterSplineSeries.cs | 3 ++- .../Chart/Chart.UWP/Visualization/Common/SplineHelper.cs | 2 ++ .../Visualization/PolarChart/Series/PolarSplineAreaSeries.cs | 3 ++- .../Visualization/PolarChart/Series/PolarSplineSeries.cs | 3 ++- .../Visualization/PolarChart/Series/RadarSplineAreaSeries.cs | 5 +++-- .../Visualization/PolarChart/Series/RadarSplineSeries.cs | 5 +++-- 9 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs index dd02f66a..9242bdc2 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs @@ -1,4 +1,5 @@ -using Telerik.UI.Automation.Peers; +using Telerik.Core; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; using Windows.UI.Xaml.Automation.Peers; @@ -51,7 +52,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { SplineAreaSeries series = (SplineAreaSeries)d; SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs index ed38a6f1..626be04b 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs @@ -1,4 +1,5 @@ -using Telerik.UI.Automation.Peers; +using Telerik.Core; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; using Windows.UI.Xaml.Automation.Peers; @@ -51,7 +52,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { SplineSeries series = (SplineSeries)d; SplineRenderer renderer = (SplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs index 1ebb868e..bc6330a7 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs @@ -1,4 +1,5 @@ using Telerik.Charting; +using Telerik.Core; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; using Windows.UI.Xaml.Automation.Peers; @@ -52,7 +53,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { ScatterSplineAreaSeries series = (ScatterSplineAreaSeries)d; SplineAreaRenderer renderer = (SplineAreaRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs index ad3837c5..3cb837b9 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs @@ -1,4 +1,5 @@ using Telerik.Charting; +using Telerik.Core; using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; using Windows.UI.Xaml.Automation.Peers; @@ -52,7 +53,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { ScatterSplineSeries series = (ScatterSplineSeries)d; SplineRenderer renderer = (SplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs b/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs index 100159d0..5521195b 100644 --- a/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs +++ b/Controls/Chart/Chart.UWP/Visualization/Common/SplineHelper.cs @@ -9,6 +9,8 @@ internal static class SplineHelper { // TODO: Should we expose these as public properties for Spline and SplineArea series? internal const double DefaultTension = 0.5d; + internal const double MinTension = 0d; + internal const double MaxTension = 1d; private const double DefaultTolerance = 5d; public static IEnumerable GetSplinePoints(IList dataPoints, DataPointSegment dataSegment, double scaleFactor, double tension = DefaultTension, bool isClosedShape = false) diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs index 0120131f..46cddf79 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Telerik.Core; using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart @@ -48,7 +49,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { PolarSplineAreaSeries series = (PolarSplineAreaSeries)d; PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs index 4cf90295..9bb64e0d 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Telerik.Core; using Windows.UI.Xaml; namespace Telerik.UI.Xaml.Controls.Chart @@ -48,7 +49,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { PolarSplineSeries series = (PolarSplineSeries)d; PolarSplineRenderer renderer = (PolarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs index b8e6e6e0..45d36976 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs @@ -1,4 +1,5 @@ -using Telerik.UI.Automation.Peers; +using Telerik.Core; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; using Windows.UI.Xaml.Automation.Peers; @@ -51,7 +52,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { RadarSplineAreaSeries series = (RadarSplineAreaSeries)d; RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs index dd875065..16d4752c 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs @@ -1,4 +1,5 @@ -using Telerik.UI.Automation.Peers; +using Telerik.Core; +using Telerik.UI.Automation.Peers; using Windows.UI.Xaml; using Windows.UI.Xaml.Automation.Peers; @@ -51,7 +52,7 @@ private static void OnSplineTensionChanged(DependencyObject d, DependencyPropert { RadarSplineSeries series = (RadarSplineSeries)d; RadarSplineRenderer renderer = (RadarSplineRenderer)series.renderer; - renderer.splineTension = (double)e.NewValue; + renderer.splineTension = RadMath.CoerceValue((double)e.NewValue, SplineHelper.MinTension, SplineHelper.MaxTension); series.InvalidateCore(); } } From 8c92b2f02b623f06f899b48f0fc5562f8a1003e2 Mon Sep 17 00:00:00 2001 From: Dilyan Traykov Date: Thu, 2 Feb 2023 10:40:00 +0200 Subject: [PATCH 5/6] Elaborate on property description. --- .../CartesianChart/Series/Categorical/SplineAreaSeries.cs | 3 ++- .../CartesianChart/Series/Categorical/SplineSeries.cs | 3 ++- .../CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs | 3 ++- .../CartesianChart/Series/Scatter/ScatterSplineSeries.cs | 3 ++- .../Visualization/PolarChart/Series/PolarSplineAreaSeries.cs | 3 ++- .../Visualization/PolarChart/Series/PolarSplineSeries.cs | 3 ++- .../Visualization/PolarChart/Series/RadarSplineAreaSeries.cs | 3 ++- .../Visualization/PolarChart/Series/RadarSplineSeries.cs | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs index 9242bdc2..2f1d0176 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineAreaSeries.cs @@ -26,7 +26,8 @@ public SplineAreaSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs index 626be04b..0aa71dbb 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Categorical/SplineSeries.cs @@ -26,7 +26,8 @@ public SplineSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs index bc6330a7..b44adce5 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineAreaSeries.cs @@ -27,7 +27,8 @@ public ScatterSplineAreaSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs index 3cb837b9..6699bd43 100644 --- a/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/CartesianChart/Series/Scatter/ScatterSplineSeries.cs @@ -27,7 +27,8 @@ public ScatterSplineSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs index 46cddf79..1bd9566b 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineAreaSeries.cs @@ -29,7 +29,8 @@ public PolarSplineAreaSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs index 9bb64e0d..93b19a43 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/PolarSplineSeries.cs @@ -29,7 +29,8 @@ public PolarSplineSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs index 45d36976..225659b7 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineAreaSeries.cs @@ -26,7 +26,8 @@ public RadarSplineAreaSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { diff --git a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs index 16d4752c..c2417fd9 100644 --- a/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs +++ b/Controls/Chart/Chart.UWP/Visualization/PolarChart/Series/RadarSplineSeries.cs @@ -26,7 +26,8 @@ public RadarSplineSeries() /// /// Gets or sets the that is used to determine the tension of the additional spline points. - /// The default value is 0.5d. + /// The default value is 0.5d. The tension works with relative values between 0 and 1. + /// Values outside this range will be coerced internally. /// public double SplineTension { From 215bf4c6c729a66a42158c4eac850a9e13e68cea Mon Sep 17 00:00:00 2001 From: Polya Pelova Date: Wed, 15 Mar 2023 12:07:58 +0200 Subject: [PATCH 6/6] Update NuGet version. --- BuildTools/BuildNuGet.bat | 2 +- BuildTools/BuildNuget.UWP.proj | 2 +- BuildTools/Nuspecs.UWP/Package.UniversalWindowsPlatform.nuspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BuildTools/BuildNuGet.bat b/BuildTools/BuildNuGet.bat index 832432c3..258834e5 100644 --- a/BuildTools/BuildNuGet.bat +++ b/BuildTools/BuildNuGet.bat @@ -1,2 +1,2 @@ SET MSBUILD=%WINDIR%\microsoft.net\framework\v4.0.30319\MSBuild.exe -%MSBUILD% BuildNuget.UWP.proj /property:Version=1.0.2.10 \ No newline at end of file +%MSBUILD% BuildNuget.UWP.proj /property:Version=1.0.2.11 \ No newline at end of file diff --git a/BuildTools/BuildNuget.UWP.proj b/BuildTools/BuildNuget.UWP.proj index 78bcca11..317e936a 100644 --- a/BuildTools/BuildNuget.UWP.proj +++ b/BuildTools/BuildNuget.UWP.proj @@ -15,7 +15,7 @@ - 1.0.2.10 + 1.0.2.11 $([System.IO.Path]::GetFullPath('$(DeployDirectory)')) $(BinariesTargetDirectory) diff --git a/BuildTools/Nuspecs.UWP/Package.UniversalWindowsPlatform.nuspec b/BuildTools/Nuspecs.UWP/Package.UniversalWindowsPlatform.nuspec index 9ebce47a..eb91901a 100644 --- a/BuildTools/Nuspecs.UWP/Package.UniversalWindowsPlatform.nuspec +++ b/BuildTools/Nuspecs.UWP/Package.UniversalWindowsPlatform.nuspec @@ -12,7 +12,7 @@ images\uwp.png true UI for Universal Windows Platform is a toolset for building Universal Windows Platform apps for the Windows Store and the enterprise. The library is designed to offer the same user experience, functionality and behavior on Windows devices of all form factors. - For full release notes see https://github.com/telerik/UI-For-UWP/releases/tag/1.0.2.10 + For full release notes see https://github.com/telerik/UI-For-UWP/releases/tag/1.0.2.11 UWP Windows Telerik Controls XAML C# en-US