Page 1 of 1

Background LegendBoxes

Posted: Wed Jul 31, 2019 8:18 am
by denkhe
I would like to change the background- color of a LegendBox from black to white (see attachment) but could not find a way to do this. Dos anybody know how this is done?

Re: Background LegendBoxes

Posted: Wed Jul 31, 2019 9:55 am
by Arction_LasseP
Hello,

The background color and style of a LegendBox can be customized as follows:

Code: Select all

_chart.ViewXY.LegendBoxes[0].Fill.Style = RectFillStyle.ColorOnly;     // LegendBox filled with color. A bitmap or transparent background can be set also 
_chart.ViewXY.LegendBoxes[0].Fill.GradientFill = GradientFill.Solid;  // Use gradient or solid color
_chart.ViewXY.LegendBoxes[0].Fill.Color = Colors.White;                  // Setting the actual background color
_chart.ViewXY.LegendBoxes[0].BorderColor = Colors.Gray;                // The color of the LegendBox border
If the background should be white, it might be necessary to change at least the font color of the series titles as well as checkbox colors if you are using them.

Code: Select all

_chart.ViewXY.LegendBoxes[0].SeriesTitleColor = Colors.Black;
_chart.ViewXY.LegendBoxes[0].CheckBoxColor = Colors.Black;
_chart.ViewXY.LegendBoxes[0].CheckMarkColor = Colors.Blue;
Hope this helps.
Lasse

Re: Background LegendBoxes

Posted: Wed Jul 31, 2019 11:59 am
by denkhe
Thanks a lot! I am almost there :D

Two issues remain:
  • 1. Is there a way to get rid of the small black line under the squares?
    2. The text "Meistereien" seems to have a shadow and does not look sharp. Is there a way to change this?

Re: Background LegendBoxes

Posted: Wed Jul 31, 2019 1:00 pm
by Arction_LasseP
Hi,

About the remaining issues, the second one should be easy to solve, assuming that the "Meistereien" -text is the title of the X-axis. The following will disable the shadow:

Code: Select all

_chart.ViewXY.XAxes[0].Title.Shadow.Style = TextShadowStyle.Off;
Title.Shadow.Style = TextShadowStyle.Off can also be use with several other texts such as series titles.

The first issue is another story. The squares with the lines are series icons indicating the series type (BarSeries, PointLineSeries etc.). As the small black line belongs to the BarSeries icon, it cannot be removed. The icons themselves can be disabled via:

Code: Select all

_chart.ViewXY.LegendBoxes[0].ShowIcons = false;
The only workaround for this is to set ShowInLegendBox = false to the actual series shown in chart, and then create dummy series with different kind of icons, in this case Bands as their icon is just a square. Set them to use the same colors as the respective BarSeries but disable their visibility so that they are not shown in the chart but only in the LegendBox. However, this approach is rather complicated for a such a small issue. Whether it is worth it is of course entirely up to you.

Best regards,
Lasse

Re: Background LegendBoxes

Posted: Wed Jul 31, 2019 2:27 pm
by denkhe
Works for me :D
Thank you!