Hi,
I have a SatckedColumn chart which can be seen in 2D or 3D. I have used ClipTextAxisLabelLayoutBehavior behavior to make series label clipped. It is working as expected in 2D chart but in 3D, it is colliding with the legend.
I have attached both the 2D and 3D charts. The code I am using is:
myInfraChart.ChartType = ChartType.StackColumnChart;
NumericSeries num1Series = new NumericSeries();num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(10), "Alice 123456123456123456123456123456123456123456123456", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(20), "Bob 123456123456123456123456123456123456123456123456", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(30), "Carol", false));num1Series.Label = "Characters that are huge but very lovely and Characters that are huge but very lovely again!";myInfraChart.Series.Add(num1Series);
ClipTextAxisLabelLayoutBehavior alb = new ClipTextAxisLabelLayoutBehavior();alb.ClipText = true;alb.Enabled = true;alb.EnableRollback = false;alb.HideText = false;alb.Trimming = StringTrimming.EllipsisCharacter;alb.UseOnlyToPreventCollisions = false;
myInfraChart.Axis.X.Labels.SeriesLabels.Layout.Behavior = AxisLabelLayoutBehaviors.UseCollection;myInfraChart.Axis.X.Labels.SeriesLabels.Layout.BehaviorCollection.Clear();myInfraChart.Axis.X.Labels.SeriesLabels.Layout.BehaviorCollection.Add(alb);
myInfraChart.Legend.Visible = true;myInfraChart.Legend.Location = LegendLocation.Bottom;
Please let me know what I may be missing.
Thanks.
Hi Max,
Sure I will try out things suggested by you. And yes these long labels are not realistic!. Though we can have many clipped labels.
The thing is that I am looking for a general solution for all charts that will give me clipped labels, clipped legends with tooltips and that work for both 2D and 3D.
You can do a number of simple things. You can increase the height of the Chart, while increasing the SpanPercentage of the Legend, followed by setting a Top margin on the Legend.You can set the 3d rotation, so that the chart takes up less vertical space.You can also use shorter labels, especially if you know what the labels are going to be. And, while for the image above, long labels illustrate the overlap, they don't represent a realistic use case. Hopefully, we're in agreement on that.
Please let me know how to solve the above scenario.
I understand your point. But how to clip text of labels then for 3D charts.
This is the modified code and the generated chart.
myInfraChart.ChartType = ChartType.Stack3DColumnChart;NumericSeries num1Series = new NumericSeries();num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(10), "Alice 123456123456123456123456123456123456123456123456", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(20), "Bob 123456123456123456123456123456123456123456123456", false));num1Series.Points.Add(new NumericDataPoint(Convert.ToDouble(30), "Carol", false));num1Series.Label = "Characters that are huge but very lovely and Characters that are huge but very lovely again!";myInfraChart.Series.Add(num1Series);myInfraChart.Legend.Visible = true;myInfraChart.Legend.Location = LegendLocation.Bottom;
Sorry, all axis layout behaviors only apply to 2d charts. This is mainly for performance reasons due to the 3d chart's ability to scale and rotate.