To reproduce: LineSeries lineSeries = new LineSeries(); lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan")); lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr")); lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul")); lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct")); lineSeries.LegendTitle = "Series A asdafsafasfd fgsdfg sdfs dfg dafsvsd"; this.radChartView1.Series.Add(lineSeries); LineSeries lineSeries2 = new LineSeries(); lineSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Jan")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Apr")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(17, "Jul")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(22, "Oct")); lineSeries2.LegendTitle = "Series B sdf asdf adfasdfas dfadsf asdf sadf awef"; this.radChartView1.Series.Add(lineSeries2); LineSeries lineSeries3 = new LineSeries(); lineSeries3.DataPoints.Add(new CategoricalDataPoint(13, "Jan")); lineSeries3.DataPoints.Add(new CategoricalDataPoint(14, "Apr")); lineSeries3.DataPoints.Add(new CategoricalDataPoint(12, "Jul")); lineSeries3.DataPoints.Add(new CategoricalDataPoint(25, "Oct")); lineSeries3.LegendTitle = "Series C sdf asdf adfasdfas dfadsf asdf sadf awef"; this.radChartView1.Series.Add(lineSeries3); this.radChartView1.ShowLegend = true; this.radChartView1.ChartElement.LegendPosition = Telerik.WinControls.UI.LegendPosition.Bottom; radChartView1.ChartElement.LegendElement.StackElement.Orientation = Orientation.Horizontal; Workaround: specify minimum height for the legend radChartView1.ChartElement.LegendElement.MinSize = new Size(0, 50);
To reproduce: LegendItem item = new LegendItem(); item.Element.BorderColor = Color.Black; item.Element.BackColor = Color.Yellow; item.Title = "Custom item"; this.radChartView1.ChartElement.LegendElement.Items.Add(item); Workaround: class MyLegendItem : LegendItem { string title = ""; protected override void SetLegendTitle(string title) { base.SetLegendTitle(title); if (this.Element is LegendItemStyleElement) { this.title = title; } } protected override string GetLegendTitle() { if (this.Element is LegendItemStyleElement) { return title; } return base.GetLegendTitle(); } }
To reproduce: Add a RadChartView and use the following code: public Form1() { InitializeComponent(); this.radChartView1.ShowTrackBall = true; this.radChartView1.ShowLegend = true; Random rand = new Random(); var lineSeries = new LineSeries(); for (int i = 0; i < 1000; i++) { lineSeries.DataPoints.Add(new CategoricalDataPoint(i, rand.Next(0, rand.Next(5, 20)))); } radChartView1.Series.Add(lineSeries); } Workaround: change the LegendPosition: this.radChartView1.ChartElement.LegendPosition = LegendPosition.Bottom;
To reproduce: Public Sub New() InitializeComponent() Me.RadChartView1.ShowTitle = True Me.RadChartView1.ChartElement.TitleElement.TextWrap = True Me.RadChartView1.Title = "This is a very long chart title that can't fit in a single line" Dim barSeries As New BarSeries("Performance", "RepresentativeName") barSeries.Name = "Q1" barSeries.DataPoints.Add(New CategoricalDataPoint(177, "Harley")) barSeries.DataPoints.Add(New CategoricalDataPoint(128, "White")) barSeries.DataPoints.Add(New CategoricalDataPoint(143, "Smith")) barSeries.DataPoints.Add(New CategoricalDataPoint(111, "Jones")) barSeries.DataPoints.Add(New CategoricalDataPoint(118, "Marshall")) Me.RadChartView1.Series.Add(barSeries) End Sub Private Sub radButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim filePath As String = "..\..\..\exprtedChart.png" Me.RadChartView1.ExportToImage(filePath, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Png) Process.Start(filePath) End Sub Workaround: titleSize must consider the chart's width Public Sub New() InitializeComponent() AddHandler Me.RadChartView1.CreateRenderer, AddressOf CreateRenderer Me.RadChartView1.ShowTitle = True Me.RadChartView1.ChartElement.TitleElement.TextWrap = True Me.RadChartView1.Title = "This is a very long chart title that can't fit in a single line" Dim barSeries As New BarSeries("Performance", "RepresentativeName") barSeries.Name = "Q1" barSeries.DataPoints.Add(New CategoricalDataPoint(177, "Harley")) barSeries.DataPoints.Add(New CategoricalDataPoint(128, "White")) barSeries.DataPoints.Add(New CategoricalDataPoint(143, "Smith")) barSeries.DataPoints.Add(New CategoricalDataPoint(111, "Jones")) barSeries.DataPoints.Add(New CategoricalDataPoint(118, "Marshall")) Me.RadChartView1.Series.Add(barSeries) End Sub Private Sub radButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Dim filePath As String = "..\..\..\exprtedChart.png" Using fs As New FileStream(filePath, FileMode.Create, FileAccess.Write) ExportToImage(Me.RadChartView1, fs, Me.RadChartView1.Size, System.Drawing.Imaging.ImageFormat.Png) End Using Process.Start(filePath) End Sub Public Sub ExportToImage(chart As RadChartView, stream As Stream, size As Size, imageFormat As ImageFormat) If Not chart.IsLoaded Then chart.LoadElementTree() End If Dim bmp As New Bitmap(size.Width, size.Height) Dim graphics__1 As Graphics = Graphics.FromImage(bmp) graphics__1.Clear(Color.White) Dim titleSize As SizeF = graphics__1.MeasureString(chart.Title, chart.ChartElement.TitleElement.Font, chart.Width) If chart.ChartElement.TitleElement.TextOrientation = Orientation.Vertical Then Dim swap As Single = titleSize.Height titleSize.Height = titleSize.Width titleSize.Width = swap End If Dim titleRect As New RadRect(0, 0, titleSize.Width, titleSize.Height) Dim legendRect As New RadRect(0, 0, size.Width, size.Height) Dim chartRect As RadRect = legendRect Select Case chart.ChartElement.TitlePosition Case TitlePosition.Top, TitlePosition.Bottom titleRect.Width = size.Width Exit Select Case TitlePosition.Right, TitlePosition.Left titleRect.Height = size.Height Exit Select End Select chartRect.X += chart.View.Margin.Left chartRect.Y += chart.View.Margin.Top chartRect.Width -= chart.View.Margin.Horizontal chartRect.Height -= chart.View.Margin.Vertical If chart.ShowTitle Then Select Case chart.ChartElement.TitlePosition Case TitlePosition.Top legendRect.Y += titleRect.Height chartRect.Y += titleRect.Height legendRect.Height -= titleRect.Height chartRect.Height -= titleRect.Height Exit Select Case TitlePosition.Right titleRect.X = size.Width - chart.ChartElement.TitleElement.Size.Width titleRect.Height = size.Height legendRect.Width -= titleRect.Width chartRect.Width -= titleRect.Width Exit Select Case TitlePosition.Bottom titleRect.Y = size.Height - chart.ChartElement.TitleElement.Size.Height titleRect.Width = size.Width legendRect.Height -= titleRect.Height chartRect.Height -= titleRect.Height Exit Select Case TitlePosition.Left titleRect.Height = size.Height legendRect.X += titleRect.Width chartRect.X += titleRect.Width legendRect.Width -= titleRect.Width chartRect.Width -= titleRect.Width Exit Select End Select End If If chart.ShowLegend Then Select Case chart.ChartElement.LegendPosition Case LegendPosition.Right If chart.ChartElement.TitlePosition = TitlePosition.Right Then legendRect.X = titleRect.X - chart.ChartElement.LegendElement.Size.Width Else legendRect.X = size.Width - chart.ChartElement.LegendElement.Size.Width End If legendRect.Width = chart.ChartElement.LegendElement.Size.Width chartRect.Width -= legendRect.Width + chart.View.Margin.Right Exit Select Case LegendPosition.Bottom If chart.ChartElement.TitlePosition = TitlePosition.Bottom Then legendRect.Y = titleRect.Y - chart.ChartElement.LegendElement.Size.Height Else legendRect.Y = size.Height - chart.ChartElement.LegendElement.Size.Height End If legendRect.Height = chart.ChartElement.LegendElement.Size.Height chartRect.Height -= legendRect.Height Exit Select Case LegendPosition.Left legendRect.Width = chart.ChartElement.LegendElement.Size.Width chartRect.X += legendRect.Width + chart.View.Margin.Left chartRect.Width -= legendRect.Width + chart.View.Margin.Left Exit Select Case LegendPosition.Top legendRect.Height = chart.ChartElement.LegendElement.Size.Height chartRect.Y += legendRect.Height chartRect.Height -= legendRect.Height Exit Select Case LegendPosition.Float legendRect.Width = chart.ChartElement.LegendElement.Size.Width legendRect.Height = chart.ChartElement.LegendElement.Size.Height Dim xRatio As Double = size.Width / Me.Size.Width Dim yRatio As Double = size.Height / Me.Size.Height legendRect.X = (chart.ChartElement.LegendOffset.X * xRatio) + (If((chart.ChartElement.TitlePosition = TitlePosition.Left), titleRect.Right, 0.0)) legendRect.Y = (chart.ChartElement.LegendOffset.Y * yRatio) + (If((chart.ChartElement.TitlePosition = TitlePosition.Top), titleRect.Bottom, 0.0F)) Exit Select End Select End If If chart.ShowLegend Then Dim xTransform As Single = CSng(legendRect.X) - chart.ChartElement.LegendElement.ControlBoundingRectangle.X + _ (CSng(legendRect.Width) - chart.ChartElement.LegendElement.ControlBoundingRectangle.Width) / 2.0F Dim yTransform As Single = CSng(legendRect.Y) - chart.ChartElement.LegendElement.ControlBoundingRectangle.Y + _ (CSng(legendRect.Height) - chart.ChartElement.LegendElement.ControlBoundingRectangle.Height) / 2.0F graphics__1.TranslateTransform(xTransform, yTransform) chart.ChartElement.LegendElement.Paint(New RadGdiGraphics(graphics__1), _ chart.ChartElement.LegendElement.ControlBoundingRectangle, 0.0F, New SizeF(1.0F, 1.0F), True) graphics__1.ResetTransform() End If Dim radGraphics As New RadGdiGraphics(graphics__1) If chart.ShowTitle Then radGraphics.DrawString(chart.Title, GetTitleDrawRectangle(ChartRenderer.ToRectangleF(titleRect), _ titleSize, chart.ChartElement.TitleElement.TextAlignment), chart.ChartElement.TitleElement.Font, _ chart.ChartElement.TitleElement.ForeColor, chart.ChartElement.TitleElement.TextParams.CreateStringFormat(), _ chart.ChartElement.TitleElement.TextOrientation, _ chart.ChartElement.TitleElement.FlipText) End If chart.View.Layout(chartRect) renderer.Draw(graphics__1) bmp.Save(stream, imageFormat) chart.View.Layout() End Sub Private Function GetTitleDrawRectangle(drawArea As RectangleF, textRect As SizeF, textAlignment As ContentAlignment) As RectangleF Select Case textAlignment Case ContentAlignment.BottomCenter Return New RectangleF(New PointF(drawArea.X + (drawArea.Width - textRect.Width) / 2.0F, drawArea.Bottom - textRect.Height), textRect) Case ContentAlignment.BottomLeft Return New RectangleF(New PointF(drawArea.X, drawArea.Bottom - textRect.Height), textRect) Case ContentAlignment.BottomRight Return New RectangleF(New PointF(drawArea.Right - textRect.Width, drawArea.Bottom - textRect.Height), textRect) Case ContentAlignment.MiddleCenter Return New RectangleF(New PointF(drawArea.X + (drawArea.Width - textRect.Width) / 2.0F, drawArea.Y + (drawArea.Height - textRect.Height) / 2.0F), textRect) Case ContentAlignment.MiddleLeft Return New RectangleF(New PointF(drawArea.X, drawArea.Y + (drawArea.Height - textRect.Height) / 2.0F), textRect) Case ContentAlignment.MiddleRight Return New RectangleF(New PointF(drawArea.Right - textRect.Width, drawArea.Y + (drawArea.Height - textRect.Height) / 2.0F), textRect) Case ContentAlignment.TopCenter Return New RectangleF(New PointF(drawArea.X + (drawArea.Width - textRect.Width) / 2, drawArea.Y), textRect) Case ContentAlignment.TopLeft Return New RectangleF(drawArea.Location, textRect) Case ContentAlignment.TopRight Return New RectangleF(New PointF(drawArea.Right - textRect.Width, drawArea.Y), textRect) Case Else Return New RectangleF(drawArea.Location, textRect) End Select End Function Dim renderer As CartesianRenderer Private Sub CreateRenderer(sender As Object, e As ChartViewCreateRendererEventArgs) e.Renderer = New CartesianRenderer(DirectCast(e.Area, CartesianArea)) renderer = e.Renderer End Sub
Steps to reproduce: 1. Add RadChartView with two BarSeries 2. Set the Name property of series 3. Set the SelectionMode property to SingleDataPoint 4. Subscribe to the SelectedPointChanging/SelectedPointChanged events. 5. Run the form and select points from different series. The OldSelectedSeries/NewSelectedSeries properties always return the name of the first series now matter which series is selected. Workaround: void radChartView1_SelectedPointChanged(object sender, ChartViewSelectedPointChangedEventArgs e) { BarSeries series = (e.NewSelectedPoint).Presenter as BarSeries; if (series.Name == "Q1") { Console.WriteLine(series.Name); } else if (series.Name == "Q2") { Console.WriteLine(series.Name); } }
Introduce gantt like series as in RadChart: http://docs.telerik.com/devtools/winforms/chart/understanding-radchart-types/gantt-charts
so that Y increases as you move down the screen. (Even) microsoft chart component supports this.
To reproduce: use the following code snippet public Form1() { InitializeComponent(); ScatterLineSeries scatterSeries = new ScatterLineSeries(); scatterSeries.DataPoints.Add(new ScatterDataPoint(15, 19)); scatterSeries.DataPoints.Add(new ScatterDataPoint(18, 10)); scatterSeries.DataPoints.Add(new ScatterDataPoint(13, 15)); scatterSeries.DataPoints.Add(new ScatterDataPoint(10, 8)); scatterSeries.DataPoints.Add(new ScatterDataPoint(5, 2)); scatterSeries.PointSize = new SizeF(8, 8); this.radChartView1.Series.Add(scatterSeries); ScatterLineSeries scatterSeries2 = new ScatterLineSeries(); scatterSeries2.DataPoints.Add(new ScatterDataPoint(2, 24)); scatterSeries2.DataPoints.Add(new ScatterDataPoint(7, 12)); scatterSeries2.DataPoints.Add(new ScatterDataPoint(15, 10)); scatterSeries2.DataPoints.Add(new ScatterDataPoint(18, 22)); scatterSeries2.DataPoints.Add(new ScatterDataPoint(20, 20)); scatterSeries2.Shape = new RoundRectShape(1); scatterSeries2.PointSize = new SizeF(8, 8); this.radChartView1.Series.Add(scatterSeries2); ChartTooltipController toolTipController = new ChartTooltipController(); radChartView1.Controllers.Add(toolTipController); } Workaround: use custom renderer public Form1() { InitializeComponent(); this.radChartView1.CreateRenderer += radChartView1_CreateRenderer; } 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++) { ScatterSeriesDrawPart scatterPart = this.DrawParts[i] as ScatterSeriesDrawPart; if (scatterPart != null) { this.DrawParts[i] = new CustomScatterSeriesDrawPart((ScatterLineSeries)scatterPart.Element, this); } } } } public class CustomScatterSeriesDrawPart : ScatterLineSeriesDrawPart { public CustomScatterSeriesDrawPart(ScatterLineSeries series, IChartRenderer renderer) : base(series, renderer) { } public override DataPoint HitTest(Point location) { 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 scatterBounds = new RectangleF((float)(this.OffsetX + slot.X - pointHalfWidth), (float)(this.OffsetY + slot.Y - pointHalfHeight), this.Element.PointSize.Width, this.Element.PointSize.Height); if (scatterBounds.Contains(location.X, location.Y)) { return this.Element.DataPoints[i]; } } return null; } }
To reproduce: You need a RadChartView with some series. You need to add a new View - radChartView1.Views.AddNew("Bigger"); You also need to add a DrillDownController: DrillDownController drillcontrol = new DrillDownController(); radChartView1.Controllers.Add(drillcontrol); radChartView1.ShowDrillNavigation = true; On the Drill event of RadChartView you need to reload the chart. This must clear the axes on the current view (determined by the drill level) and add new ones. You will see that the legend will not update. Additional details can be found in the attached project. Workaround: Re-add the legend items manually: private void radChartView1_Drill(object sender, DrillEventArgs e) { if (e.Level == 0) BiggerView = false; else BiggerView = true; ReloadChart(); this.radChartView1.ChartElement.LegendElement.StackElement.Children.Clear(); ChartView currentView = this.radChartView1.Views[BiggerView ? 1 : 0]; foreach (ChartSeries series in currentView.Series) { LegendItem item = new LegendItem(series) { Title = series.Name }; LegendItemElement element = new LegendItemElement(item); this.radChartView1.ChartElement.LegendElement.StackElement.Children.Add(element); } }
How can I achieve the same behaviour as with the obsolete RadChart plotting the area between the maxima of a sine.
With significant number of points in pie series and with very small values as data points, the default chart strategy for positioning smart labels overlaps the values. Note: the smart labels overlapping can be reproduced with DonutSeries as well.
To reproduce: Use the following code with RadChartView: this.Chart.Series.Add(new LineSeries()); for (int i = 0; i < 50; i++) { if (i == 10) { this.Chart.Series[0].DataPoints.Add(new CategoricalDataPoint(1)); continue; } this.Chart.Series[0].DataPoints.Add(new CategoricalDataPoint(0)); } this.Chart.ShowGrid = true; You will see that the point will not be rendered correctly and will be taller than 1.
Add the ability a user to be able to use a Custom DashStyle in the following scenario: this.Chart.ShowLegend = true; this.Chart.Series.Add(new LineSeries() { LegendTitle = "DDDD" }); this.Chart.ChartElement.LegendElement.Items[0].Element.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Custom; for (int i = 0; i < 10; i++) { this.Chart.Series[0].DataPoints.Add(i); } The following article describes how to use a Custom DashStyle: How to: Draw a Custom Dashed Line
To reproduce: Setup the following RadChartView: this.Chart.ShowLegend = true; this.Chart.Series.Add(new LineSeries() { LegendTitle = "DDDD" }); this.Chart.ChartElement.LegendElement.Items[0].Element.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; for (int i = 0; i < 10; i++) { this.Chart.Series[0].DataPoints.Add(i); } You will see that although that you have changed the BorderDashStyle of the Element, the LineSerie will be drawn normally.
When one adds data points with negative and positive values, the negative ones should go below the 0, for example, with the following data: AreaSeries areaSeries = new AreaSeries(); areaSeries.DataPoints.Add(new CategoricalDataPoint(5, "Jan")); areaSeries.DataPoints.Add(new CategoricalDataPoint(-10, "Apr")); Resolution: To use the functionality one should set the StartPositionAxis and StartPositionValue properties of an axis. The first property is the axis along which the current axis will be aligned. The second is the value where the current axis should be positioned. Here is a sample code: AreaSeries areaSeries = new AreaSeries(); areaSeries.DataPoints.Add(new CategoricalDataPoint(13, "Jan")); areaSeries.DataPoints.Add(new CategoricalDataPoint(20, "Apr")); areaSeries.DataPoints.Add(new CategoricalDataPoint(-15, "Jul")); areaSeries.DataPoints.Add(new CategoricalDataPoint(16, "Oct")); this.radChartView1.Series.Add(areaSeries); areaSeries.HorizontalAxis.StartPositionAxis = areaSeries.VerticalAxis; areaSeries.HorizontalAxis.StartPositionValue = 0;