0

I am working with charts. I have a simple chart with 2 columns, one green and one red:

enter image description here

I would like to have the green column to turn yellow when its value exceeds 60.

How could I achieve that?

I have made the chart by manually add 2 datapoint (one for each serie) so there is not code that is generating this chart so far.

Kiyana
  • 1
  • 1
  • What chart control is it? – Equalsk Mar 07 '17 at 12:44
  • 3
    Please show the code you are currently using to render the chart! – Georg Patscheider Mar 07 '17 at 12:44
  • 1
    This is not easy. Short of using a stacked chart as a workaround with all its problems you will need to ownerdraw the columns. Other charttypes, like point, line or spline are simple to draw but columns are not. Here [is an example](http://stackoverflow.com/questions/40801190/let-column-charts-overlap-in-chart-control/40804678?s=1|0.5463#40804678) of doing it although not for the purpose of using two colors but of controlling width and overlapping.. Also: We need to see relevant code; here is is quite unclear if you have one or, more likely two series, which can make a big difference!!! – TaW Mar 07 '17 at 13:31
  • Thank you for the info TaW. I will leave this for now as this was a bit more complicated than I can handle at the moment. – Kiyana Mar 08 '17 at 10:58
  • Indeed, complicated. The in a way simplest workaround would be to overlay the chartarea with a second one which holds the very same series and datapoints, but with the y-values at the lower lime (e.g. 60) .. If you want to I can show you an example but I would think twice if it is worth it.. – TaW Mar 08 '17 at 16:29

1 Answers1

-1

You can set custom palette colors on the fly. Because ms charts don't have a great way to change the color of the column chart, this is a little work around you can use.

Color[] colorSet = new Color[]
{
    Color.Yellow,
    Color.Red
};

chart1.PaletteCustomColors = colorSet;
chart1.Palette = ChartColorPalette.None;
Baddack
  • 1,947
  • 1
  • 24
  • 33