To reproduce: BarSeries barSeries = new BarSeries("Performance", "RepresentativeName"); 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")); this.radChartView1.Series.Add(barSeries); LinearAxis verticalAxis = radChartView1.Axes.Get<LinearAxis>(1); verticalAxis.MajorStep = 5; LinearAxisModel axisModel = verticalAxis.Model as LinearAxisModel; AxisScaleBreak scaleBreakItem = new AxisScaleBreak(); scaleBreakItem.Name = "Item1"; scaleBreakItem.From = 80d; scaleBreakItem.To = 120d; verticalAxis.ScaleBreaks.Add(scaleBreakItem);
Use attached to reproduce. Workaround: Use custom renderer: 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++) { CartesianGridLineAnnotationDrawPart linePart = this.DrawParts[i] as CartesianGridLineAnnotationDrawPart; if (linePart != null) { this.DrawParts[i] = new MyCartesianGridLineAnnotationDrawPart((CartesianGridLineAnnotation)linePart.Element, this); } } } } class MyCartesianGridLineAnnotationDrawPart : CartesianGridLineAnnotationDrawPart { public MyCartesianGridLineAnnotationDrawPart(CartesianGridLineAnnotation element, CartesianRenderer renderer) : base(element, renderer) { } public override void Draw() { PropertyInfo modelProperty = typeof(CartesianGridLineAnnotation).GetProperty("Model", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); object model = modelProperty.GetValue(this.Element); PropertyInfo layoutProperty = model.GetType().GetProperty("LayoutSlot", BindingFlags.Public | BindingFlags.Instance); RadRect radRect = (RadRect)layoutProperty.GetValue(model); RectangleF rect = ChartRenderer.ToRectangleF(radRect); rect.Offset(this.ViewportOffsetX, this.ViewportOffsetY); Graphics graphics = this.Renderer.Surface as Graphics; RadGdiGraphics radGraphics = new RadGdiGraphics(graphics); var clipRect = ChartRenderer.ToRectangle(this.Element.View.GetArea<CartesianArea>().AreaModel.PlotArea.LayoutSlot); clipRect.Offset((int)this.ViewportOffsetX,(int) this.ViewportOffsetY); graphics.SetClip(clipRect); GraphicsPath path = new GraphicsPath(); path.AddLine(rect.Location, new PointF(rect.Right, rect.Bottom)); BorderPrimitiveImpl border = new BorderPrimitiveImpl(this.Element, null); border.PaintBorder(radGraphics, null, path, rect); rect.Size = graphics.MeasureString(this.Element.Label, this.Element.Font); rect.Offset(this.Element.PositonOffset.Width + 1, this.Element.PositonOffset.Height + 1); TextParams tp = new TextParams(); tp.font = this.Element.Font; tp.foreColor = this.Element.ForeColor; tp.paintingRectangle = rect; tp.text = this.Element.Label; TextPrimitiveHtmlImpl text = new TextPrimitiveHtmlImpl(); text.PaintPrimitive(radGraphics, 0f, new SizeF(1f, 1f), tp); } }
Use attached to reproduce.
Workaround:
series.DataPoints.Add(new PieDataPoint(0.01, "Germany"));
To reproduce: public RadForm1() { InitializeComponent(); this.radChartView1.AreaType = ChartAreaType.Polar; PolarAreaSeries polarAreaSeries = new PolarAreaSeries(); PolarDataPoint polarPoint = new PolarDataPoint(); polarPoint.Value = 35; polarPoint.Angle = 50; polarAreaSeries.DataPoints.Add(polarPoint); polarPoint = new PolarDataPoint(); polarPoint.Value = 40; polarPoint.Angle = 200; polarAreaSeries.DataPoints.Add(polarPoint); polarPoint = new PolarDataPoint(); polarPoint.Value = 55; polarPoint.Angle = 320; polarAreaSeries.DataPoints.Add(polarPoint); this.radChartView1.Series.Add(polarAreaSeries); this.radChartView1.Axes[0].LabelFitMode = AxisLabelFitMode.Rotate; AxisLabelElement gauche = this.radChartView1.Axes[0].Children[1] as AxisLabelElement; gauche.Text = "IV Gestion des ressources" + Environment.NewLine + "humaines"; this.radChartView1.View.AxisLabelFormatting+=View_AxisLabelFormatting; } Font f = new Font("Arial", 10, FontStyle.Bold); private void View_AxisLabelFormatting(object sender, ChartAxisLabelFormattingEventArgs e) { if (e.LabelElement.Text.Contains("IV")) { e.LabelElement.Font = f; } }
After 1 million the decimal places of the labels are not correct, In your image. the labels on the horizontal axis go 999,992.50 - 999,995.00 - 999,997.5 - 1,000,000.00 - *1,000,003.00(should be 1,000,002.50) - 1,000,005.00 - *1,000,008.00(should be 1,000,007.5)
The same issue can be observed in a DPI-aware application on higher scaling Workaround: set the RadControl.EnableDpiScaling property to false public partial class Form1 : Form { public Form1() { RadControl.EnableDpiScaling = false; InitializeComponent(); 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")); 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")); this.radChartView1.Series.Add(lineSeries2); LassoZoomController lassoZoomController = new LassoZoomController(); radChartView1.Controllers.Add(lassoZoomController); } private void radButton1_Click(object sender, EventArgs e) { this.radChartView1.ExportToImage(@"..\..\image.png", this.radChartView1.Size); } }
To reproduce: DataTable table = new DataTable(); table.Columns.Add("Value", typeof(double)); table.Columns.Add("Name", typeof(string)); table.Rows.Add(1, "John"); table.Rows.Add(3, "Adam"); table.Rows.Add(5, "Peter"); table.Rows.Add(12, "Sam"); table.Rows.Add(6, "Paul"); BarSeries lineSeria = new BarSeries(); radChartView1.Series.Add(lineSeria); lineSeria.ValueMember = "Value"; lineSeria.CategoryMember = "Name"; this.radChartView1.DataSource = table; private void radButton1_Click(object sender, EventArgs e) { this.radChartView1.DataSource = null; } The chart data will be still visible. It is necessary to set explicitly the DataSource of the series: this.radChartView1.Series[0].DataSource = null;
To reproduce: - Add a chart to the form and set series with DataSource - Close and dispose the form Workaround: Set the DataSource property of the series to null prior closing.
To reproduce: run the attached sample project and you will notice that the data points are not properly aligned. Workaround: use equal number of data points for the series.
To reproduce: please refer to the attached sample project and gif file illustrating the behavior on my end. Note: similar to the axis, the series should also have ClipLabels property which will control whether the labels will be clipped or not. Workaround: use custom renderer: Sub New() InitializeComponent() AddHandler Me.RadChartView1.CreateRenderer, AddressOf RadChartView1_CreateRenderer Dim barSeries As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName") barSeries.Name = "Q1" barSeries.ShowLabels = True 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) Dim barSeries2 As New Telerik.WinControls.UI.BarSeries("Performance", "RepresentativeName") barSeries2.Name = "Q2" barSeries2.ShowLabels = True barSeries2.DataPoints.Add(New CategoricalDataPoint(153, "Harley")) barSeries2.DataPoints.Add(New CategoricalDataPoint(141, "White")) barSeries2.DataPoints.Add(New CategoricalDataPoint(130, "Smith")) barSeries2.DataPoints.Add(New CategoricalDataPoint(88, "Jones")) barSeries2.DataPoints.Add(New CategoricalDataPoint(109, "Marshall")) Me.RadChartView1.Series.Add(barSeries2) Dim lassoZoomController As New ChartPanZoomController() RadChartView1.Controllers.Add(lassoZoomController) End Sub Public Class CustomLabelElementDrawPart Inherits BarLabelElementDrawPart Public Sub New(owner As ChartSeries, renderer As IChartRenderer) MyBase.New(owner, renderer) End Sub Public Overrides Sub Draw() If Not Me.Element.ShowLabels Then Return End If Dim graphics As Graphics = TryCast(Me.Renderer.Surface, Graphics) Dim radGraphics As RadGdiGraphics = New RadGdiGraphics(graphics) Dim isSmartLabelsEnabled As Boolean = Me.Element.View.ShowSmartLabels Dim isLineToLabelEnabled As Boolean = Me.Element.DrawLinesToLabels For Each dataPointElement As DataPointElement In Me.Element.Children Dim categoricalDataPoint As CategoricalDataPoint = TryCast(dataPointElement.DataPoint, CategoricalDataPoint) For i As Integer = 0 To dataPointElement.Children.Count - 1 Dim labelElement As LabelElement = TryCast(dataPointElement.Children(i), LabelElement) If labelElement Is Nothing Then Continue For End If labelElement.OnLabelFormatting(New ChartViewLabelFormattingEventArgs(labelElement)) If Not labelElement.IsVisible OrElse String.IsNullOrEmpty(labelElement.Text) Then Continue For End If Dim rect As Rectangle Dim slot As RadRect = labelElement.GetLayoutSlot() If isSmartLabelsEnabled AndAlso labelElement.SmartRectangle <> Rectangle.Empty Then rect = labelElement.SmartRectangle Else slot = AdjustLayoutSlot(slot, labelElement.DataPointElement) rect = ChartRenderer.ToRectangle(slot) End If Dim state As Object = radGraphics.SaveState() Dim horizontalTranslate As Integer = rect.X + rect.Width / 2 Dim verticalTranslate As Integer = rect.Y + rect.Height / 2 Dim clipRect As RectangleF If TypeOf Me.Renderer Is CartesianRenderer Then Dim size As SizeF = graphics.MeasureString("W", Me.Element.Font) Dim plotRect As RadRect = Me.Element.Model.LayoutSlot plotRect.X += Me.ViewportOffsetX plotRect.Y += Me.ViewportOffsetY clipRect = ChartRenderer.ToRectangleF(plotRect) clipRect.Y -= size.Height / 2.0F clipRect.Height += size.Height clipRect.Width += size.Width * 2.0F graphics.SetClip(clipRect) End If Dim angle As Single = CSng(Me.Element.LabelRotationAngle) Mod 360.0F If angle <> 0 Then radGraphics.TranslateTransform(horizontalTranslate, verticalTranslate) radGraphics.RotateTransform(angle) radGraphics.TranslateTransform(-horizontalTranslate, -verticalTranslate) End If If isLineToLabelEnabled Then Me.DrawConnectingLine(radGraphics, labelElement, dataPointElement, isSmartLabelsEnabled AndAlso labelElement.SmartRectangle <> Rectangle.Empty) End If If labelElement.BackgroundShape IsNot Nothing Then labelElement.BackgroundShape.Paint(CType(radGraphics.UnderlayGraphics, Graphics), rect) End If Dim fill As Telerik.WinControls.Primitives.FillPrimitiveImpl = New Telerik.WinControls.Primitives.FillPrimitiveImpl(labelElement, Nothing) fill.PaintFill(radGraphics, 0, System.Drawing.Size.Empty, rect) Dim border As Telerik.WinControls.Primitives.BorderPrimitiveImpl = New Telerik.WinControls.Primitives.BorderPrimitiveImpl(labelElement, Nothing) border.PaintBorder(radGraphics, 0, System.Drawing.Size.Empty, rect) Using brush As Brush = New SolidBrush(labelElement.ForeColor) Dim drawRectangle As RectangleF = New RectangleF() drawRectangle.X = rect.X + labelElement.Padding.Left drawRectangle.Y = rect.Y + labelElement.Padding.Top drawRectangle.Width = rect.Width - labelElement.Padding.Right drawRectangle.Height = rect.Height - labelElement.Padding.Bottom Dim format As StringFormat = New StringFormat() format.Alignment = ContentAlignmentToHorizontalStringAlignment(labelElement.TextAlignment) format.LineAlignment = Me.ContentAlignmentToVerticalStringAlignment(labelElement.TextAlignment) graphics.DrawString(labelElement.Text, labelElement.Font, brush, drawRectangle, format) End Using If angle <> 0 Then radGraphics.ResetTransform() radGraphics.RestoreState(state) End If graphics.ResetClip() Next Next End Sub Public Function ContentAlignmentToVerticalStringAlignment(ByVal contentAlignment As ContentAlignment) As StringAlignment Dim result As StringAlignment Select Case contentAlignment Case contentAlignment.BottomCenter, contentAlignment.BottomLeft, contentAlignment.BottomRight result = StringAlignment.Far Case contentAlignment.TopCenter, contentAlignment.TopLeft, contentAlignment.TopRight result = StringAlignment.Near Case Else result = StringAlignment.Center End Select Return result End Function Private Function ContentAlignmentToHorizontalStringAlignment(ByVal contentAlignment As ContentAlignment) As StringAlignment Dim result As StringAlignment Select Case contentAlignment Case contentAlignment.BottomLeft, contentAlignment.MiddleLeft, contentAlignment.TopLeft result = StringAlignment.Near Case contentAlignment.BottomRight, contentAlignment.MiddleRight, contentAlignment.TopRight result = StringAlignment.Far Case Else result = StringAlignment.Center End Select Return result End Function End Class Private Sub RadChartView1_CreateRenderer(sender As Object, e As ChartViewCreateRendererEventArgs) e.Renderer = New CustomCartesianRenderer(e.Area) End Sub Public Class CustomCartesianRenderer Inherits CartesianRenderer Public Sub New(area As CartesianArea) MyBase.New(area) End Sub Protected Overrides Sub Initialize() MyBase.Initialize() For i As Integer = 0 To Me.DrawParts.Count - 1 Dim label As BarLabelElementDrawPart = TryCast(Me.DrawParts(i), BarLabelElementDrawPart) If (label IsNot Nothing) Then Me.DrawParts(i) = New CustomLabelElementDrawPart(label.Element, Me) End If Next End Sub End Class
Create a chart with a LinesSeries with a DateTimeContinuousAxis axis and set the following properties: DateTimeContinuousAxis horizontalAxis = new DateTimeContinuousAxis(); horizontalAxis.Title = tupleItem.HorizontalAxis; horizontalAxis.AxisType = AxisType.First; horizontalAxis.VerticalLocation = AxisVerticalLocation.Bottom; horizontalAxis.AutomaticBorderColor = false; horizontalAxis.MaximumTicks = 10; horizontalAxis.LabelFormat = "{0:HH:mm:ss.fff}"; You will see that there are less labels than ticks. When the chart is zoomed the labels also disappear from the ticks.
Add Three Line Break Series to RadChartView
Currently, ScatterSeries are able to use NumericAxes only. A good improvement will be to allow using DateTimeContinuousAxes as well.
To reproduce use the following code to initialize the chart: DataTable dt = new DataTable(); dt.Columns.Add("Category", typeof(string)); dt.Columns.Add("Value", typeof(int)); dt.Rows.Add("010010", 5); dt.Rows.Add("000020", 6); dt.Rows.Add("000030", 2); dt.Rows.Add("000040", 11); return dt; BarSeries bs = new BarSeries("Value", "Category"); bs.Palette = new PaletteEntry(Color.BlanchedAlmond); radChartView1.DataSource = dt; radChartView1.Series.Clear(); radChartView1.Series.Add(bs); radChartView1.GetArea<CartesianArea>().Orientation = Orientation.Horizontal; Workaround: CategoricalAxis Axis = radChartView1.Axes.Get<CategoricalAxis>(1); Axis.LabelFormat = "{0:000000}";
Axes should allow custom formatting for each individual label. Consider the following scenario - a chart provides information for each hour of the day. Each label should contain only the hours data, however, when the date changes the label should contain the full date information.
HeightAspectRatio affects the height of BarSeries even when the area has a horizontal orientation
Add null value support for RadChartView