Hello,
I am using Infragistics2.Win.UltraWinChart.v9.1 version. I am showing a pie chart in a windows application. The pie chart lists out legends over the bottom of the pie chart.
Here my issue is when no.of legends is large, the legend area displays the list of legends that can be fitted and the text "more...". How can we see the remaining legends items on click of the text "more...".? On click of the text "more..." doesnt seem to be working or how to handle the event of onclick of "more..". I want to show all the available legends to the user. Any suggestion or workaround? Please help needed.
Thanks,
Naveen
Naveen,
Currently there is no way to tell the chart to selectively display a range of legend items. I will submit this as a feature request on your behalf.
Michael S.
Thanks Michael...
Then how can we make use of the text "more..."? Is there any event handler for legend's click? Is there any sample code or post for custom legend control?
Regards,
No, the word "more" is not clickable. You would have to create your own legend control, perhaps out of a grid or a listbox and iterate through the datasource and brushes and create a series of icon-text pairs. Brushes can be found in chart.ColorModel.CustomPalette, provided the CustomLinear color model has been used. The data and labels should all be in the datasource.
Let me know if I can be of further assistance.
Thanks for your support Michael,
I could able to meet my requirement by the following code.
Create a custom panel deriving from Panel class. In FillSceneGraph event of chart, get the legend text and the color, create a new instance of the custom panel using the legend and color, then add the instance to a flowlayout panel. Make the default legend of chart invisible.
private void ultraChart2_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e) { LegendLayer legendLayer = e.ChartCore.GetLegendLayer();
flowLayoutPanel1.Controls.Clear();
foreach (Primitive p in e.SceneGraph) { if (p.Path != null && p.Path.IndexOf("Legend") != -1 && p.Row >= 0) { string v_LegendItemText = legendLayer.ChartData.GetRowLabel(p.Row) as string; LegendPanel legend = new LegendPanel(); legend.Text = v_LegendItemText; legend.Color = (p as Box).PE.Fill;
if (v_LegendItemText.Length > 10) legend.FormattedText = v_LegendItemText.Substring(0, 10) + "..."; else legend.FormattedText = v_LegendItemText;
flowLayoutPanel1.Controls.Add(legend); } }
public class LegendPanel : Panel { public LegendPanel() { this.Width = 95; this.Height = 25; }
public override string Text { set;get; }
public string FormattedText { set;get; }
public Color Color { get;set; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e);
Rectangle rect = new Rectangle(5, 5, 15, 14); SolidBrush solidBrush = new SolidBrush(Color.FromArgb(Color.R,Color.G,Color.B)); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rect); e.Graphics.FillRectangle(solidBrush, rect);
e.Graphics.DrawString(FormattedText, new System.Drawing.Font("Verdana", 7F), new SolidBrush(Color.Black), new PointF(30, 5)); }
}
I'm glad you were able to meet your requirements. I will close the case.