Hello,
How do I change the style of the Legend. By default the legend is displayed as BOX filled with the color represented in the chart.My requirement is to have a legend with a horizonal bar like "---------Item1 ---------Item2" where the dotted lines are the colors represented in the chart for Item1 and Item2.
Thanks in advance.
Hi mmahadevan,
As far as I know there is no standard way to change that appearance but I can offer you a workaround to achieve a legend like that on attached image.
You can hook ChartDrawItem event and to search for Legend's boxes and texts and to change their position and appearance. Here's a snippet used to achive the lened on the image.
private void ultraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e) { int newBoxHeight = 3; int newBoxWidth = 30; // 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; box.rect.Width = newBoxWidth; } 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.X += newBoxWidth; // increase according to newBoxHeight in order to center the text text.bounds.Y = text.bounds.Y - 3; // decrease according to new box space } }
What namespace are you using that include the definition for 'Box' and 'Text'? Thanks.