Hi,
Is it possible to change spacing between two labels rows inside a legend of an ultrachart. I wanted to increase the vertical spacing between two label rows inside the legendn as its inadequate and the two labels rows are nearly getting merged.
Thanks in advance
Hi maheshpanse,
You can handle ChartDrawItem event and to change position, width and height of any primitive drawn on the chart. You need Text and Box primitives in the case with Legend labels. Here's a sample how to change these parameters. Note that Box's Column property can contain -1 that describes external box of the legend.
private void ultraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e) { int newBoxHeight = 25; // try if it is a Box primitive which belongs to legend and it is not the external legend's box Box box = e.Primitive as Box; if (box != null && !string.IsNullOrEmpty(box.Path) && box.Path.EndsWith("Legend") != false && box.Column != -1) { box.rect.Height = newBoxHeight; if (box.Column != 0) { box.rect.Y = box.rect.Y + newBoxHeight * box.Column; } } Text text = e.Primitive as Text; // try if it is a Text primitive which belongs to legend and it is not the external legend's text if (text != null && !string.IsNullOrEmpty(text.Path) && text.Path.EndsWith("Legend") != false && text.Column != -1) { text.bounds.Y += 8; // increase according to newBoxHeight in order to center the text if (text.Column != 0) { text.bounds.Y = text.bounds.Y + newBoxHeight * text.Column; } } }
Please add screen shot of the problem legend in the case this sample will not help you.
Hi Anton,
Thanks for your reply.
With the product version currently with me I am not able to find the ChartDrawItemEventArgs. I have 3.0.2 V3 release with me and need to stick with the same for some reason.
Is there any way out of this.
Thanks
I am trying to do something similar here. I used the sample code from above (I'm using version 2008.2). The code looks something like the following..
if (!String.IsNullOrEmpty(box.Path) && box.Path.EndsWith("Legend") && (-1 != box.Column))
{ ....do something with the legend box
}
{
.... do something with legend text
Looking at the code in debug, when I get the Text Primitive the text column is always -1 and the path is always null. Am I getting the wrong primitive type here or something?
You can try looking at:
http://news.infragistics.com/forums/p/5297/23905.aspx#23905
I looked at the item you referenced however it did not actually address my question.
Which chart type you are using? I've been trying your code with ColumnChart and it seems to work.
I'm using a column chart
works fine for me as well. what (4-part) version number is the dll you're using? maybe downloading the latest hotfix will resolve this problem.