Nevron Forum

Legend text size -can it be restricted to a maximum value?

https://www.nevron.com/Forum/Topic4159.aspx

By Kevin Harrison - Thursday, September 9, 2010

I have charts with two panels, one for the chart and one for the legend.  These resize correctly as the chart size is changed.  However, the legend font size increases in proportion and starts to look odd when it gets too big.  Is there a way to limit the maximum legend text size, or can you suggest an alternative way to handle this situation?

Thanks

Kevin

By Blagovest Milanov 1 - Friday, September 10, 2010

Hi Kevin,

What is the legend bound mode you use? In general using legend.BoundsMode = BoundsMode.Fit will keep the legend size constant during resize, while using BoundsMode.Stretch will resize the legend so that it completely fills its content area. Also can you post the layout relevant code - probably we can come up with some suggestions?

 

By Kevin Harrison - Friday, September 10, 2010

Hi Bob

I'm using BoundsMode.Fit.  I am creating a panel for the chart and a separate one for the legend, using NRelativeUnit.ParentPercentage units to define their positions.  This works great for preventing overlapping of the chart and the legend as the chart control size reduces (which was the reason I did this).  However, beyond a certain chart control size the legend text size is just too big.  I want it to reach a certain size, but stop scaling if the chart control size is increased any further.

As an aside, when the size gets too small, I would ideally like the legend (and any title) to automatically not be displayed at all, so more of the limited space is taken up by the chart (automatic decluttering!).

Regards

Kevin

By Nevron Support - Monday, September 13, 2010

Hi Kevin,

I see - probably in this case it will be better to use docking - that way the legend will first occupy some space and then the chart will have to fit in the rest - the following code snippet for example also produces a chart that does not overlap with the legend however in this case the legend size remains constant:

   nChartControl1.Panels.Clear();

   NLabel label = new NLabel();
   label.Text = "Some Header";
   label.Dock = DockStyle.Top;
   label.DockMargins = new NMarginsL(10, 10, 10, 0);
   nChartControl1.Panels.Add(label);

   NDockPanel dockPanel = new NDockPanel();
   dockPanel.DockMargins = new NMarginsL(10, 10, 10, 10);
   dockPanel.PositionChildPanelsInContentBounds = true;
   nChartControl1.Panels.Add(dockPanel);

   NLegend legend = new NLegend();
   legend.Dock = DockStyle.Right;
   legend.DockMargins = new NMarginsL(10, 0, 0, 0);
   dockPanel.ChildPanels.Add(legend);

   dockPanel.Dock = DockStyle.Fill;
   NCartesianChart chart = new NCartesianChart();
   dockPanel.ChildPanels.Add(chart);
   chart.BoundsMode = BoundsMode.Stretch;
   chart.Dock = DockStyle.Fill;
   chart.DisplayOnLegend = legend;

   NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
   bar.Values.Add(10);
   bar.Values.Add(20);
   bar.Values.Add(30);

Hope this helps - is this approach good for your case?...

By Kevin Harrison - Wednesday, November 17, 2010

The problem with a constant legend size is that you can't resize the chart and see more of a legend with a long string.  It would be useful for me to limit the maximum font size of the legend, but I can't see any way to do this?

Alternatively, it would be great if the user could resize the chart and legend areas, by dragging markers placed at the intersection of the chart and legend areas (and potentially the title area as well).  Is this feasible?

Thanks

Kevin

By Nevron Support - Thursday, November 18, 2010

Hi Kevin,

We will try to extend the legend layout for the next release so that it can flow the legend items. Dragging the bounds of the chart panels (legend, titlte, charts) will also probably be present as it is indeed a very useful feature.

By Kevin Harrison - Thursday, November 25, 2010

I have implemented the docking panel suggestion earlier in this thread, but have found that it significantly slows down redraws when the chart control is resized, particularly for 3D charts.  Please can you suggest ways to maximise the rendering speed?
By Nevron Support - Monday, November 29, 2010

Hi Kevin,

This is most likely related to the rendering speed of the chart itself (in case it has many data points). Can you post a sample configuration that is significantly slower - the speed can depend on many factors - such as point shape, applied jittering steps etc.