3

I am trying to change colors in my bar chart based on values of tool run length if the number goes over 2,000 i need the datapoint to turn red. any suggestions would be helpful here is my code

SqlDataAdapter graph = new SqlDataAdapter("SELECT machi[ne, tool, Sum(length)][1] as length FROM CHART WHERE Machine Like'" + comboBox2.Text + "' and tool Like '%p2'  group by tool,machine order by length desc", CON);
        DataTable graphdata = new DataTable();
        graph.Fill(graphdata);
        chart1.DataSource = graphdata;

        chart1.ChartAreas["ChartArea1"].AxisX.Title = comboBox1.Text;

        chart1.Series["Series1"].XValueMember = "tool";
        chart1.Series["Series1"].YValueMembers = "length";
Marcus
  • 97
  • 1
  • 11
  • Do you mean the whole column or just the part that goes over the limit? – TaW Mar 17 '17 at 18:06
  • Note that you can't bind the color of a DataPoint. Even if you use the right [DataBind](https://msdn.microsoft.com/en-us/library/dd456766.aspx) method only very few properties allow binding. ToolTip does, Color doesn't.. - So you need to set the Color as suggested in the link's second part! – TaW Mar 17 '17 at 19:18
  • I'm trying to change just the one that goes over the limit – Marcus Mar 18 '17 at 18:22
  • Didn't you ask the same question last week with another user id??? – TaW Mar 18 '17 at 20:09
  • No this is my first time using this service . I noticed it said there is a duplicate question on the site. I'm a bit new to programming so I am a little confused on how to implement the code to make this possible. – Marcus Mar 18 '17 at 20:36
  • OK, the link was for coloring the whole column when the value is over a limit, so I have reopened the question. But: Coloring only the top part is __really hard__. I would __either__ overlay a second chartarea with all the same data, just all values limited by the threshold. __Or__ I would draw all column in code in the postpaint event.. Neither is recommended for beginners. __Other even (a lot) more complicated__ ways would to either use a Stackedcolummn chart or an Area charttype. – TaW Mar 18 '17 at 22:10
  • Thanks for the advise, I will try the overlay idea I didn't think about doing that and it could be a good way to go. – Marcus Mar 19 '17 at 01:04
  • Well, good luck then. See [here](http://stackoverflow.com/questions/30051010/pie-chart-transparency-multiple-pies/30054841?s=1|0.4107#30054841) for overlaying CAs. Call when you run into problems.. – TaW Mar 19 '17 at 02:59

0 Answers0