1

The question I have seems to be simple but I can't find an answer around the Internet for that and even trying around did not help me.

I just want to change the color of a Legend (from a Series). I know how to change the text color but I need to change the color of that marker.

 chart1.Legends["1"].ForeColor = Color.Transparent;
 chart1.Legends["1"].BackColor = Color.Transparent;

does not help

Is this possible?

Thank you!

EDIT:

enter image description here

I want to change the blue color to another. Hope this is more clear now.

Canox
  • 557
  • 1
  • 7
  • 20

1 Answers1

0

The markers show the ChartType and the Color of all the Series.

Unfortunately the default LegendItems anre hidden and can't be changed, only expanded.

So your best bet, except avoiding the issue by picking a a different green, (if that is why you want to change the blue) would be to clear or disable the default Legend and create a new one from scratch.

For this you can style all sorts of things including setting MarkerStyles and also Bitmaps you create on the fly..

Here and here are two examples that show you how to do it..

And here is one with a rather extended custom Legend

Instead of creating a new Legend you can also hide the LegendItem for a Series

series1.IsVisibleInLegend = true;

and add a new one but it will be added at the end..

Here is an example of adding a simple LegendItem:

void AddLegendItem(Legend L, Series s, Color mc)
{
    LegendItem lit = new LegendItem();

    lit.BorderColor = mc;
    lit.Color = mc;
    lit.SeriesName = s.Name;
    lit.Name = s.Name;
    L.CustomItems.Add(lit);
 }
Community
  • 1
  • 1
TaW
  • 53,122
  • 8
  • 69
  • 111
  • Thank you! I just also found an easy answer. Just have to change the color of the series the label is bound to to transparent – Canox Nov 24 '16 at 15:09
  • Hm, well that will also hide the DataPoints, though. Do you use Markers to display the data instead? Also your question quite clearly ask for changing the legenditemmarker color blue to another! – TaW Nov 24 '16 at 15:18
  • No I'm just using Labels. But the color comes from the chart color. – Canox Nov 24 '16 at 15:37