خرید بک لینک

Vote count: 0

I created a column chart in my application which look like this:

Column chart with positive and negative colors

As you can see the positive values are green and the negative values are red. I need to represent this in the legend. I just don't know how.

What I already tried:

I added CustomItems to the Legend. Here is the code:

Legend currentLegend = chart.Legends.FindByName(chart.Series[series].Legend);
if (currentLegend != null)
{
    currentLegend.LegendStyle   = LegendStyle.Table;
    LegendItem li               = new LegendItem();
    li.Name                     = series;
    li.Color                    = Color.Red;
    li.BorderColor              = Color.Transparent;
    currentLegend.CustomItems.Add(li);
}

This results in the following representation:

Column chart with legend representing positive and negative color

I could live with that. But as soon as I add further series to the chart the order of the elements gets destroyed. Here is an example:

enter image description here

I would like to have one of the two options:

  1. keep the positive and negative color together
  2. or an even better solution could be to have just one tile in the legend which is double colored. Something like this:

enter image description here

Could you please help me solving this issue?

Many thanks in advance!

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 26 فروردين 1395 ساعت: 12:08

صفحه بندی