Profile Picture

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

Posted By Kevin Harrison 14 Years Ago

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

Author
Message
Kevin Harrison
Posted 14 Years Ago
View Quick Profile
Forum Guru

Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 52, Visits: 1

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



bob milanov
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)Supreme Being (152 reputation)

Group: Forum Members
Last Active: 6 Months Ago
Posts: 153, Visits: 11

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?

 



Kevin Harrison
Posted 14 Years Ago
View Quick Profile
Forum Guru

Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 52, Visits: 1

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



Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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?...



Best Regards,
Nevron Support Team



Kevin Harrison
Posted 14 Years Ago
View Quick Profile
Forum Guru

Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 52, Visits: 1

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



Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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.



Best Regards,
Nevron Support Team



Kevin Harrison
Posted 14 Years Ago
View Quick Profile
Forum Guru

Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)Forum Guru (52 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 52, Visits: 1
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?

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic