Nevron Forum

Map legends - is it possible to change the border / remove the title etc.

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

By Kevin Harrison 1 - Monday, March 11, 2013

It seems that the legend created for maps is very fixed in its appearance, completely unlike legends for charts. We frequently create Reports where maps and charts are displayed side-by-side, so the inconsistency between the legend formatting becomes quite obvious (we prefer our chart legends to have no borders and have the same background as the rest of the chart area).

Is there some way to control the map legend appearance that I have missed?

Thanks

Kevin

By Nevron Support - Monday, March 11, 2013

It depends on the type of map legend you are using. For example if you create the map legend as a table shape, you can then freely modify the style of the table shape in order to customize your map's legend.
By Kevin Harrison 1 - Monday, March 11, 2013

Sorry, I have no idea what you mean. The code I am using is:

 

NMapLegendRange mapLegend = (NMapLegendRange)nevronMap.GetLegend(fillRuleRange);

mapLegend.Title = this.MapDefinition.LegendTitle;

mapLegend.RangeFormatString = "<= {1:" + numberStringFormat + "}";

mapLegend.LastFormatString = "> {0:" + numberStringFormat + "}";

Panel legendControl = new Panel();

legendControl.Name = LegendPanelControlName;

legendControl.Dock = DockStyle.Top;

 

// Create the legend

mapLegend.Create((Panel)legendControl);

 

There seems to be no way for me to change the appearance of the legend, just call Create()

By Kevin Harrison 1 - Wednesday, May 15, 2013

Can someone answer this please?

Thanks

Kevin

By Nevron Support - Wednesday, May 15, 2013

Hi,

From the source code you have provided we can see that you create your legend in a panel. To achive your requirements (i.e. to remove the border and change the background) you need to modify some properties of the panel after you have created the legend:

mapLegend.Create((Panel)legendControl);

 

legendControl.BorderStyle = BorderStyle.None;

legendControl.BackColor = Color.Red;

 

The code above will remove the border of the panel and make its background red.

By Kevin Harrison 1 - Thursday, May 16, 2013

Thanks, that works, but it now looks odd with no border and the same background as the rest of the panel, because the title and its underline is just "floating" there. Is there (or can there be added) an option not to display a legend title?

If I don't set a title, then "Legend" is added by default. If I set the title to null, then I get no title, but I still have the horizontal line separating the title from the legend.

By Kevin Harrison 1 - Sunday, July 14, 2013

Can someone reply please?

Thanks

Kevin

By Nevron Support - Monday, July 15, 2013

Hi Kevin and thank you for the feedback. We have added support for this feature to Nevron Diagram for .NET and it will be included in the next service pack of the product. All you'll have to do if you do not want a title for your legend will be to set the Title property of the map legend to null or to the empty string.
By Kevin Harrison 1 - Monday, July 15, 2013

Great service as usual. Thanks.