Note: similar to the axis, the series should also have ClipLabels property which will control whether the labels will be clipped or not.
How to reproduce: zoom and pan along the chart
public Form1()
{
InitializeComponent();
this.radChartView1.CreateRenderer += radChartView1_CreateRenderer;
this.radChartView1.ShowPanZoom = true;
BarSeries barSeries = new BarSeries();
Random rand = new Random();
for (int i = 1; i < 10; i++)
{
barSeries.DataPoints.Add(new CategoricalDataPoint(rand.Next(100), i));
}
barSeries.ShowLabels = true;
this.radChartView1.Series.Add(barSeries);
}
Workaround:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.radChartView1.CreateRenderer += radChartView1_CreateRenderer;
this.radChartView1.ShowPanZoom = true;
BarSeries barSeries = new BarSeries();
Random rand = new Random();
for (int i = 1; i < 10; i++)
{
barSeries.DataPoints.Add(new CategoricalDataPoint(rand.Next(100), i));
}
barSeries.ShowLabels = true;
this.radChartView1.Series.Add(barSeries);
}
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++)
{
BarLabelElementDrawPart labelPart = this.DrawParts[i] as BarLabelElementDrawPart;
if (labelPart != null)
{
this.DrawParts[i] = new CustomLabelElementDrawPart((BarSeries)labelPart.Element, this);
}
}
}
}
public class CustomLabelElementDrawPart : BarLabelElementDrawPart
{
public CustomLabelElementDrawPart(ChartSeries owner, IChartRenderer renderer)
: base(owner, renderer)
{ }
public override void Draw()
{
Graphics graphics = this.Renderer.Surface as Graphics;
CartesianSeries cartesianSeries = this.Element as CartesianSeries;
if (cartesianSeries != null)
{
CartesianArea area = (CartesianArea)cartesianSeries.GetType().GetField("area", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cartesianSeries);
RectangleF clipRect = (RectangleF)area.GetType().GetMethod("GetCartesianClipRect", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(area, new object[] { });//.GetCartesianClipRect();
graphics.SetClip(clipRect);
}
base.Draw();
graphics.ResetClip();
}
}