To reproduce: Add a RadChartView to a Form. Use the following code: this.Chart.AreaType = ChartAreaType.Pie; this.Chart.ShowLegend = true; PieSeries series = new PieSeries(); series.DataPoints.Add(new PieDataPoint(50, "Germany")); series.DataPoints.Add(new PieDataPoint(70, "United States")); series.DataPoints.Add(new PieDataPoint(40, "France")); series.DataPoints.Add(new PieDataPoint(25, "United Kingdom")); series.ShowLabels = true; this.Chart.Series.Add(series); Workaround: Private Sub LegendElement_VisualItemCreating(sender As Object, e As LegendItemElementCreatingEventArgs) Dim pieElement As PiePointElement = DirectCast(e.LegendItem.Element, PiePointElement) Dim dataPoint As PieDataPoint = DirectCast(pieElement.DataPoint, PieDataPoint) e.LegendItem.Title = dataPoint.Name End Sub
Use attached to reproduce. If you add 163 points the axis will start from 3. There should be an option to start from 0.
Use attached to reproduce. Workaround: private void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e) { e.Renderer = new CustomCartesianRenderer(e.Area as CartesianArea); } public class CustomCartesianRenderer : CartesianRenderer { public CustomCartesianRenderer(CartesianArea area) : base(area) { } protected override void Initialize() { base.Initialize(); for (int i = 0; i < this.DrawParts.Count; i++) { LineSeriesDrawPart linePart = this.DrawParts[i] as LineSeriesDrawPart; if (linePart != null) { this.DrawParts[i] = new CustomLineSeriesDrawPart((LineSeries)linePart.Element, this); } } } } public class CustomLineSeriesDrawPart : LineSeriesDrawPart { public CustomLineSeriesDrawPart(LineSeriesBase series, IChartRenderer renderer) : base(series, renderer) { } protected override PointF[] GetPointsPositionsArray() { List<DataPoint> points = new List<DataPoint>(this.Element.DataPoints); PointF[] result = new PointF[points.Count]; for (int i = 0; i < points.Count; i++) { result[i] = new PointF(this.OffsetX + (float)points[i].LayoutSlot.X, this.OffsetY + (float)points[i].LayoutSlot.Y); } return result; } }
To reproduce: - Add a polar chart with a selection controller. - Click near the bottom right corner of the point (10 pixels away) - The point is selected. Workaround: private void Chart_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e) { e.Renderer = new MyPolarRenderer(e.Area as PolarArea); } class MyPolarRenderer : PolarRenderer { public MyPolarRenderer(PolarArea area) : base(area) { } protected override void Initialize() { base.Initialize(); for (int i = 0; i < this.DrawParts.Count; i++) { PolarPointSeriesDrawPart linePart = this.DrawParts[i] as PolarPointSeriesDrawPart; if (linePart != null) { this.DrawParts[i] = new MyDrawpart((PolarPointSeries)linePart.Element, this); } } } } class MyDrawpart : PolarPointSeriesDrawPart { public MyDrawpart(PolarPointSeries series, IChartRenderer renderer) : base(series, renderer) { } public override DataPoint HitTest(Point location) { if (this.Element.PointSize.Width == 0 || this.Element.PointSize.Height == 0) { return null; } for (int i = 0; i < this.Element.DataPoints.Count; i++) { RadRect slot = this.Element.DataPoints[i].LayoutSlot; float pointHalfWidth = this.Element.PointSize.Width / 2; float pointHalfHeight = this.Element.PointSize.Height / 2; RectangleF dataPointBounds = new RectangleF((float)(slot.X - pointHalfWidth), (float)(slot.Y - pointHalfHeight), this.Element.PointSize.Width, this.Element.PointSize.Height); if (dataPointBounds.Contains(location.X, location.Y)) { return this.Element.DataPoints[i]; } } return null; } }
Add Point and Figure Series to RadChartView
To reproduce: - The total amount should go bellow 0 with the last point: var ws = new WaterfallSeries(); ws.ShowLabels = true; ws.DataPoints.Add(new Telerik.Charting.WaterfallDataPoint(10.0, false, false)); ws.DataPoints.Add(new Telerik.Charting.WaterfallDataPoint(2.0, false, false)); ws.DataPoints.Add(new Telerik.Charting.WaterfallDataPoint(3.0, false, false)); ws.DataPoints.Add(new Telerik.Charting.WaterfallDataPoint(-20.0, false, false)); radChartView1.Series.Add(ws); Workaround: Set the minimum: var verticalAxis = radChartView1.Axes[1] as LinearAxis; verticalAxis.Minimum = -10;
How to reproduce: Check the attached project Workaround: Create a separate custom MACD indicator and add it to the chart, uncomment the commented code in the attached project Friend Class MacdCustomIndicator Inherits MacdIndicator Private customBorderColor As Color Public Property BorderColor() As Color Get Return customBorderColor End Get Set(ByVal value As Color) customBorderColor = value Me.ChildIndicator.BorderColor = value End Set End Property Sub New() Dim customMacdInnerIndicator = New CustomMacdInnerIndicator(Me) Me.GetType().BaseType.GetField("childIndicator", BindingFlags.Instance Or BindingFlags.NonPublic).SetValue(Me, customMacdInnerIndicator) End Sub End Class Friend Class CustomMacdInnerIndicator Inherits MacdInnerIndicator Public Sub New(owner As MacdIndicator) MyBase.New(owner) End Sub Public Overrides Function GetProcessedValue(currentIndex As Integer) As Double Dim macd As Double = Me.CalculateMacdValue(currentIndex, LongPeriod, ShortPeriod) Me.Cache(macdValues).Add(currentIndex, macd) Return macd End Function End Class
How to reproduce: the issue can be observed when opening a form with a RadChartView which is not visible located in RadScrollablePanel. The panel will scroll to the chart which is not desired Workaround: public partial class RadForm1 : Telerik.WinControls.UI.RadForm { public RadForm1() { InitializeComponent(); this.radScrollablePanel1.AllowAutomaticScrollToControl = false; } protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); this.radScrollablePanel1.HorizontalScrollbar.Value = 0;; } }
Add Kagi Series to RadChartView
Use attached to reproduce (comment the custom strategy). Workaround: in the attched project.
How to reproduce: private void UpdateChart() { this.radChartView1.Series.Clear(); // Create two series for the bar chart. BarSeries requiredBarSeries = new BarSeries { ShowLabels = true, CombineMode = ChartSeriesCombineMode.Cluster, NumberOfColors = 2, }; BarSeries actualBarSeries = new BarSeries { ShowLabels = true, CombineMode = ChartSeriesCombineMode.Cluster, NumberOfColors = 2, }; // Add the data. AddDataPoint(requiredBarSeries, .0333d, "Germany", "Required"); AddDataPoint(actualBarSeries, .050d, "Germany", "Actual"); AddDataPoint(requiredBarSeries, .0333d, "United States", "Required"); AddDataPoint(actualBarSeries, .050d, "United States", "Actual"); AddDataPoint(requiredBarSeries, .00d, "France", "Required"); AddDataPoint(actualBarSeries, .050d, "France", "Actual"); AddDataPoint(requiredBarSeries, 0.0d, "United Kingdom", "Required"); AddDataPoint(actualBarSeries, .050d, "United Kingdom", "Actual"); AddDataPoint(requiredBarSeries, 0.955d, "Russia", "Required"); // Change the following value to .95d to see // the issue. AddDataPoint(actualBarSeries, .15d, "Russia", "Actual"); this.radChartView1.Series.Add(requiredBarSeries); this.radChartView1.Series.Add(actualBarSeries); CategoricalAxis horizontalAxis = radChartView1.Axes[0] as CategoricalAxis; horizontalAxis.LabelFitMode = AxisLabelFitMode.MultiLine; } private void AddDataPoint(BarSeries series, double val, string category, string label) { series.DataPoints.Add(new CategoricalDataPoint { Value = val, Label = String.Format("{0}\n{1:P2}", label, val), Category = category }); } Workaround: create a custom SmartLabelsController public RadForm1() { InitializeComponent(); SmartLabelsController labelsController = new CustomSmartLabelsController(); this.radChartView1.Controllers.Add(labelsController); // Set up the chart } public class CustomSmartLabelsController : SmartLabelsController { protected override SmartLabelsStrategyBase GetDefaultStrategy(ChartArea area) { SmartLabelsStrategyBase strategy = base.GetDefaultStrategy(area); if (strategy is VerticalAdjusmentLabelsStrategy) { strategy = new CustomVerticalAdjusmentLabelsStrategy(); Dictionary<Type, List<Type>> strategies = typeof(SmartLabelsController).GetField("strategySeries", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this) as Dictionary<Type, List<Type>>; strategies.Remove(typeof(VerticalAdjusmentLabelsStrategy)); strategies.Add(typeof(CustomVerticalAdjusmentLabelsStrategy), new List<Type> { typeof(BarSeries), typeof(LineSeriesBase) }); } return strategy; } } public class CustomVerticalAdjusmentLabelsStrategy : VerticalAdjusmentLabelsStrategy { public override void CalculateLocations(ChartSeriesCollection series, Rectangle plotArea) { if (series.Count == 0) { return; } List<LabelElement> labels = new List<LabelElement>(); List<int> overlaps = new List<int>(); foreach (ChartSeries chartSeries in series) { if (!chartSeries.ShowLabels || !chartSeries.IsVisible) { continue; } foreach (DataPointElement point in chartSeries.Children) { LabelElement label = (LabelElement)point.Children[0]; Rectangle labelRect = ChartRenderer.ToRectangle(label.GetLayoutSlot()); labelRect.X += (int)(series[0].View.Viewport.X + ((IChartView)series[0].View).PlotOriginX); labelRect.Y += (int)(series[0].View.Viewport.Y + ((IChartView)series[0].View).PlotOriginY); if (chartSeries.View.GetArea<CartesianArea>().Orientation == Orientation.Vertical) { labelRect.Y -= this.DistanceToLabel; } else { labelRect.X += this.DistanceToLabel; } labelRect.Inflate(0, this.DistanceBetweenLabels); label.SmartRectangle = labelRect; labels.Add(label); } } CartesianSeries cartesianSeries = (CartesianSeries)series[0]; if (cartesianSeries != null) { this.RestrictWithinAxes(labels, cartesianSeries); } LabelElement labelToMove = this.GetElementWithMostOverlaps(labels, series); int counter = 0; while (labelToMove != null && counter < labels.Count) { Rectangle firstDirectionRect; Rectangle secondDirectionRect; int firstMoveCost; int secondMoveCost; Rectangle dataPointLayout = ChartRenderer.ToRectangle(labelToMove.DataPoint.LayoutSlot); dataPointLayout.X += (int)labelToMove.View.Viewport.X; dataPointLayout.Y += (int)labelToMove.View.Viewport.Y; if (cartesianSeries.View.GetArea<CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical) { firstDirectionRect = this.GetBestPositionInUpwardDirection(labels, labelToMove, cartesianSeries); secondDirectionRect = this.GetBestPositionInDownwardDirection(labels, labelToMove, cartesianSeries); firstMoveCost = Math.Abs(labelToMove.SmartRectangle.Y - firstDirectionRect.Y); secondMoveCost = Math.Abs(labelToMove.SmartRectangle.Y - secondDirectionRect.Y); } else { firstDirectionRect = this.GetBestPositionInLeftDirection(labels, labelToMove, cartesianSeries); secondDirectionRect = this.GetBestPositionInRightDirection(labels, labelToMove, cartesianSeries); firstMoveCost = Math.Abs(dataPointLayout.X - firstDirectionRect.X); secondMoveCost = Math.Abs(dataPointLayout.X - secondDirectionRect.X); } if (!dataPointLayout.IntersectsWith(secondDirectionRect) && firstMoveCost > secondMoveCost) { labelToMove.SmartRectangle = secondDirectionRect; } else { labelToMove.SmartRectangle = firstDirectionRect; } labelToMove = this.GetElementWithMostOverlaps(labels, series); counter++; } this.FinalPositionsOptimization(labels); foreach (LabelElement label in labels) { Rectangle rect = label.SmartRectangle; rect.Inflate(0, -this.DistanceBetweenLabels); Rectangle dataPointLayout = ChartRenderer.ToRectangle(label.DataPoint.LayoutSlot); dataPointLayout.X += (int)cartesianSeries.View.Viewport.X; dataPointLayout.Y += (int)cartesianSeries.View.Viewport.Y; int delta = 1; if (dataPointLayout.Y > label.SmartRectangle.Y) { delta = -1; } rect.Y += delta * this.DistanceToLabel; label.SmartRectangle = rect; } } }
Add Renko Series to RadChartView
Add HLC (high-low-close) Series to RadChartView
Hi Team,
Can you please share sample or demo code for candlestick graph (C# winform).
Thanks
Use attached to reproduce.
- Click at least 7 times.
Workaround: Crete new series instance each time.
Hi team,
We need a ChartView with multiple series and multiple Y-axis. The axis color of each Y-axis should be automatically painted according to the palette setting (thank you for the brilliant work - it's very intuitive). However, if clear the series and re-assign a new set of series, the border color of the first axis changes to black, regardless which palette is active. If the palette is set to a new one, the border color can be re-painted correctly. See screenshot as attached.
How to reproduce: Please refer to the attached project for a demo of reproduction. Click the first button to populate new random data. The border color of the first axis should change to black after clicking the button twice and more times. Clicking the second button will force the palette to change and the border color will become normal.
Thank you, team.
Best,
Yusi
Currently the axis data flows from left to right starting with the smallest values and increasing. There should be a way to verse this flow and the most left values to be the biggest.
Currently, RadChartView offers exporting to a Bitmap in one of the following formats: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.imageformat?view=netframework-4.8
It would be nice to have export functionality to a vector image.