public Form1() { InitializeComponent(); 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 areaSeries2 = new AreaSeries(); areaSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Jan")); areaSeries2.DataPoints.Add(new CategoricalDataPoint(25, "Apr")); areaSeries2.DataPoints.Add(new CategoricalDataPoint(27, "Jul")); areaSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Oct")); this.radChartView1.Series.Add(areaSeries2); this.radChartView1.ShowTrackBall = true; this.radChartView1.Series.First().IsVisible = false; } Please refer to the attached sample video. Workaround 1: remove the series instead of hiding it. Workaround 2: 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) { } private int renderPass = 0; public override void Draw(object context) { if (renderPass < 2) { if (this.Area.View.Owner.Control.Site == null) { for (int i = 0; i < this.Area.Series.Count; i++) { if (this.Area.Series[i].IsVisible && !this.Area.Series[i].Model.IsArrangeValid) { this.Area.View.Layout(); renderPass++; return; } } } } FieldInfo fi = typeof(ChartRenderer).GetField("surface", BindingFlags.Instance | BindingFlags.NonPublic); if (context != null) { fi.SetValue(this, context); } Initialize(); for (int i = 0; i < this.DrawParts.Count; i++) { this.DrawParts[i].Draw(); } } }
To reproduce: - Enable the Trackball. - Add 2 series to the chart. - Remove and add back the first one. - Move the mouse over the chart. Workaround: class MyChartTrackballController : ChartTrackballController { protected override string GetPointText(DataPoint point) { if (point.Presenter != null) { return base.GetPointText(point); } else { CategoricalDataPoint p = point as CategoricalDataPoint; if (p!= null) { return p.Value.ToString(); } } return ""; } }
To reproduce: public RadForm1() { InitializeComponent(); LineSeries lineSeries = new LineSeries(); lineSeries.DataPoints.Add(new CategoricalDataPoint(40, "Jan")); lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr")); lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul")); lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct")); lineSeries.ShowLabels = true; this.radChartView1.Series.Add(lineSeries); LineSeries lineSeries2 = new LineSeries(); lineSeries2.DataPoints.Add(new CategoricalDataPoint(13, "Jan")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Apr")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(17, "Jul")); lineSeries2.DataPoints.Add(new CategoricalDataPoint(22, "Oct")); lineSeries2.ShowLabels = true; this.radChartView1.Series.Add(lineSeries2); ((CartesianArea)this.radChartView1.View.Area).ShowGrid = true; int i = 1; foreach (DataPointElement dpe in this.radChartView1.Series[0].Children) { dpe.IsVisible = false; AnimatedPropertySetting setting = new AnimatedPropertySetting(); setting.StartValue = false; setting.EndValue = true; setting.Property = UIChartElement.IsVisibleProperty; setting.ApplyDelay = 40 + 40 * i; setting.NumFrames = 2; setting.ApplyValue(dpe); i++; }i = 1; foreach (DataPointElement dpe in this.radChartView1.Series[1].Children) { dpe.IsVisible = false; AnimatedPropertySetting setting = new AnimatedPropertySetting(); setting.StartValue = false; setting.EndValue = true; setting.Property = UIChartElement.IsVisibleProperty; setting.ApplyDelay = 60 + 60 * i; setting.NumFrames = 2; setting.ApplyValue(dpe); i++; } } Workaround: Perform the animation in the Shown event.
To reproduce: protected override void OnLoad(EventArgs e) { base.OnLoad(e); radChartView1 = new RadChartView(); radChartView1.Parent = this; this.radChartView1.AreaType = ChartAreaType.Pie; 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.radChartView1.Series.Add(series); (series.Children[0] as PiePointElement).RadiusAspectRatio = 1.2f; } Workaround: protected override void OnLoad(EventArgs e) { base.OnLoad(e); radChartView1 = new RadChartView(); radChartView1.Parent = this; this.radChartView1.AreaType = ChartAreaType.Pie; 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.radChartView1.Series.Add(series); (series.Children[0] as PiePointElement).RadiusAspectRatio = 1.2f; this.radChartView1.CreateRenderer += new ChartViewCreateRendererEventHandler(radChartView1_CreateRenderer); } void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e) { e.Renderer = new CustomPieRenderer(e.Area as PieArea); } public class CustomPieRenderer : PieRenderer { public CustomPieRenderer(PieArea area) : base(area) { } protected override void Initialize() { base.Initialize(); for (int i = 0; i < this.DrawParts.Count; i++) { PieSeriesDrawPart piePart = this.DrawParts[i] as PieSeriesDrawPart; if (piePart != null) { this.DrawParts[i] = new CustomPieSeriesDrawPart((PieSeries)piePart.Element, this); } } } } class CustomPieSeriesDrawPart : PieSeriesDrawPart { public CustomPieSeriesDrawPart(PieSeries series, IChartRenderer renderer) : base(series, renderer) { } public override void DrawSeriesParts() { //base.DrawSeriesParts(); PieSeriesModel model = this.Element.Model as PieSeriesModel; float diameter = CalculateDiameter(); if (diameter > 0) { DrawPieSegments(model, diameter); } } private float CalculateDiameter() { PieSeriesModel model = this.Element.Model as PieSeriesModel; double diameter = Math.Min((float)model.LayoutSlot.Width, (float)model.LayoutSlot.Height) * ((PieSeries)Element).RadiusFactor; return (float)diameter; } private void DrawPieSegments(PieSeriesModel model, float diameter) { Graphics gr = ((PieRenderer)this.Renderer).Graphics; RadGdiGraphics radGraphics = new RadGdiGraphics(gr); for (int i = 0; i < model.DataPoints.Count; i++) { PiePointElement childElement = (PiePointElement)this.Element.Children[i]; PieDataPoint piePoint = (PieDataPoint)childElement.DataPoint; float finalDiameter = diameter * childElement.RadiusAspectRatio; GraphicsPath path = ConstructGraphicsPath(piePoint, model.LayoutSlot, finalDiameter); UpdatePointPaths(piePoint, path); System.Drawing.RectangleF rect = GetPieSectionRect(piePoint, model.LayoutSlot, finalDiameter); childElement.GradientAngle = (float)(piePoint.StartAngle + piePoint.SweepAngle / 2); FillPrimitiveImpl fill = new FillPrimitiveImpl(childElement, null); fill.PaintFill(radGraphics, path, rect); BorderPrimitiveImpl border = new BorderPrimitiveImpl(childElement, null); border.PaintBorder(radGraphics, null, path, rect); } } protected System.Drawing.RectangleF GetPieSectionRect(PieDataPoint point, RadRect modelLayoutSlot, float diameter) { System.Drawing.RectangleF result; float x = (float)(modelLayoutSlot.X + (modelLayoutSlot.Width - diameter) / 2); float y = (float)(modelLayoutSlot.Y + (modelLayoutSlot.Height - diameter) / 2); result = new System.Drawing.RectangleF(x, y, Math.Max(diameter, 1f), Math.Max(diameter, 1f)); if (point.OffsetFromCenter > 0) { System.Drawing.PointF offset = GetOffset(point.StartAngle + (point.SweepAngle / 2), (diameter / 2) * (point.OffsetFromCenter)); result.X += offset.X; result.Y += offset.Y; } return result; } private System.Drawing.PointF GetOffset(double angle, double radius) { double angleInRad = angle * RadMath.DegToRadFactor; double x = (Math.Cos(angleInRad) * radius); double y = (Math.Sin(angleInRad) * radius); return new System.Drawing.PointF((float)x, (float)y); } }
To reproduce: Enable the smart labels and export the chart using custom size: this.radChartView1.ExportToImage(@"C:\df.png", new Size(1100,1100), System.Drawing.Imaging.ImageFormat.Png); Workaround: class MyPieRenderer : PieRenderer { public MyPieRenderer(PieArea area) : base(area) { } protected override void Initialize() { base.Initialize(); var area = this.View; SmartLabelsController smartController = null; for (int i = 0; i < area.View.Controllers.Count; i++) { smartController = area.View.Controllers[i] as SmartLabelsController; if (smartController != null) { RadRect viewport = area.View.Viewport; viewport.X -= area.View.Margin.Left; viewport.Y -= area.View.Margin.Top; viewport.Width += area.View.Margin.Horizontal; viewport.Height += area.View.Margin.Vertical; Rectangle plotArea = new Rectangle((int)viewport.X, (int)viewport.Y, (int)viewport.Width, (int)viewport.Height); smartController.CalculateLabelsPositions(area.View.Series, plotArea); break; } } } } // change like this void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e) { e.Renderer = new MyPieRenderer((PieArea)e.Area); }
To reproduce - Add step-line series with two data points. Workaround: 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++) { SteplineDrawPart linePart = this.DrawParts[i] as SteplineDrawPart; if (linePart != null) { this.DrawParts[i] = new CustomDrawPart((SteplineSeries)linePart.Element, this); } } } } public class CustomDrawPart : SteplineDrawPart { public CustomDrawPart(LineSeriesBase series, IChartRenderer renderer) : base(series, renderer) { } protected override System.Drawing.Drawing2D.GraphicsPath GetLinePaths(PointF[] points) { //return base.GetLinePaths(points); GraphicsPath path = new GraphicsPath(); if (points.Length > 1) { if (this.Element is LineSeries && ((LineSeries)this.Element).Spline) { path.AddCurve(points, ((LineSeries)this.Element).SplineTension); } else { bool isVertical = this.Element.View.GetArea<CartesianArea>().Orientation == System.Windows.Forms.Orientation.Vertical; for (int i = 1; i < points.Length; i++) { PointF x = points[i - 1]; PointF y = points[i]; if (isVertical) { path.AddLine(x.X, x.Y, y.X, x.Y); path.AddLine(y.X, x.Y, y.X, y.Y); } else { path.AddLine(x.X, x.Y, x.X, y.Y); path.AddLine(x.X, y.Y, y.X, y.Y); } } } } else { return null; } return path; } } //change like this void radChartView1_CreateRenderer(object sender, ChartViewCreateRendererEventArgs e) { e.Renderer = new CustomCartesianRenderer((CartesianArea)e.Area); }
To reproduce: - Add line series with large point size and null points. - Hover a near a point which is close to null point (the line break). Workaround: public class MyChartTooltipController : ChartTooltipController { protected override ActionResult OnMouseMove(MouseEventArgs e) { for (int i = 0; i < this.Area.Series.Count; i++) { DataPoint point = this.Area.Series[i].HitTest(e.X, e.Y); DataPoint hoveredPoint = typeof(ChartTooltipController).GetField("hoveredPoint", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this) as DataPoint; ToolTip toolTip = typeof(ChartTooltipController).GetField("toolTip", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this) as ToolTip; if (point != null && hoveredPoint != point) { hoveredPoint = point; var result = typeof(CategoricalDataPoint).GetMethod("GetTooltipValue", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(hoveredPoint, null); if (result == null) { return new ChartRefreshResult(); } } } return base.OnMouseMove(e); } }
Having issues withVS2013 & 2015 Q1 Winforms RadChartView control 1. WYSIWYG in design time does not refresh properly after changing axis collection parameters, unless close and reopen the parent winform or custom control 2. by changing an axis collection parameter , seem to end up with multiple extra axes series (originally had axisX, AxisY, and after a minor param change ended up with axis 0 thru 5 (6 in total) and all series where now using axis4 & axis5 not my original axis? 3. I can't see to toggle display on/off of series in winforms via the legend, yet in wpf web it is possible? will this feature be added later? attached is example of WYSIWYG not working improvement Suggestions: I would love to have a major and minor grid (similar to ref: http://thumbs.dreamstime.com/z/screen-digital-oscilloscope-two-types-signal-33269502.jpg) as most of my work is measurement and scientific in nature. I would like to ensure the ratio of X-Y is fixed so that on resize of the control the grid does not skew or stretch and I loose 1:1 aspect ratio I look forward to your feedback ;)
By making IsVisibleInLegend = false at design time, get exception during compile (see attached) and also exceptions at run time Aim: I need to be able to hide certain chart text from legend
RadChartView Control: corrupts legend when set Series IsVisibleInLegend = False in Properties at design time Simply added a few extra series , and then tried to turn them off in the legend screen shot shows too many legent items for the series in the properties window
when overlay a radlabel on a radchartview, chartview constantly refreshes label backcolor set to transparent tried to recreate this with a sample cs project but wouldn't reproduce! video has two instances of the same user control on the form notice that right hand instance does not update when radlabel is added attached is video of it working fine, then add label ontop , then see it misbehaving with fast refresh flicker! not only that it also prevents other items in the user controls from updating and the other user control on the form from updating have attached sample c# project (but cant reproduce)
Workaround: create a custom BarSeriesDrawPart and override the Draw method public class CustomBarSeriesDrawPart : BarSeriesDrawPart { public CustomBarSeriesDrawPart(BarSeries series, IChartRenderer renderer) : base(series, renderer) { } public override void Draw() { bool shouldDraw = IsElementValid(); if (shouldDraw) { Graphics graphics = this.Renderer.Surface as Graphics; GraphicsState state = graphics.Save(); Region clipRegion = graphics.Clip; CartesianSeries cartesianSeries = this.Element as CartesianSeries; if (cartesianSeries != null) { FieldInfo fi = cartesianSeries.GetType().GetField("area", BindingFlags.NonPublic | BindingFlags.Instance); CartesianArea area = fi.GetValue(cartesianSeries) as CartesianArea; MethodInfo mi = area.GetType().GetMethod("GetCartesianClipRect", BindingFlags.NonPublic | BindingFlags.Instance); mi.Invoke(area, null); RectangleF clipRect = (RectangleF)mi.Invoke(area, null); graphics.Clip = new Region(clipRect); } DrawSeriesParts(); graphics.Clip = clipRegion; graphics.Restore(state); } } }
How to reproduce: public Form1() { InitializeComponent(); DataTable source = new DataTable(); source.Columns.Add("PreviousGoal", typeof(decimal)); source.Columns.Add("CurrentCategory", typeof(System.DateTime)); source.LoadDataRow(new object[] { null, "6/1/15" }, true); source.LoadDataRow(new object[] { null, "6/2/15" }, true); source.LoadDataRow(new object[] { null, "6/3/15" }, true); source.LoadDataRow(new object[] { null, "6/4/15" }, true); source.LoadDataRow(new object[] { null, "6/5/15" }, true); this.radChartView1.DataSource = source; SteplineSeries previousGoalSeries = new SteplineSeries(); previousGoalSeries.DataSource = source; previousGoalSeries.ValueMember = "PreviousGoal"; this.radChartView1.Series.Add(previousGoalSeries); SteplineSeries previousGoalSeries1 = new SteplineSeries(); previousGoalSeries1.DataSource = source; previousGoalSeries1.ValueMember = "CurrentCategory"; this.radChartView1.Series.Add(previousGoalSeries1); this.radChartView1.ShowTrackBall = true; } Workaround: add the series with null values last public partial class Form1 : Form { public Form1() { InitializeComponent(); DataTable source = new DataTable(); source.Columns.Add("PreviousGoal", typeof(decimal)); source.Columns.Add("CurrentCategory", typeof(System.DateTime)); source.LoadDataRow(new object[] { null, "6/1/15" }, true); source.LoadDataRow(new object[] { null, "6/2/15" }, true); source.LoadDataRow(new object[] { null, "6/3/15" }, true); source.LoadDataRow(new object[] { null, "6/4/15" }, true); source.LoadDataRow(new object[] { null, "6/5/15" }, true); this.radChartView1.DataSource = source; SteplineSeries previousGoalSeries1 = new SteplineSeries(); previousGoalSeries1.DataSource = source; previousGoalSeries1.ValueMember = "CurrentCategory"; this.radChartView1.Series.Add(previousGoalSeries1); SteplineSeries previousGoalSeries = new SteplineSeries(); previousGoalSeries.DataSource = source; previousGoalSeries.ValueMember = "PreviousGoal"; this.radChartView1.Series.Add(previousGoalSeries); this.radChartView1.ShowTrackBall = true; } }
To reproduce: this.radChartView1.AreaType = ChartAreaType.Pie; 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")); for (int i = 0; i < 50; i++) { series.DataPoints.Add(new PieDataPoint(1, "Item " + i)); } series.ShowLabels = true; series.DrawLinesToLabels = true; this.radChartView1.Series.Add(series); this.radChartView1.ShowSmartLabels = true;
To reproduce: - Add a pie chart using the property builder and set the palette as well. Workaround - Set the palette in code: this.radChartView1.Area.View.Palette = KnownPalette.Metro;