0

I have a winform with 3 textboxes as options and 3 buttons as the option selection. When I fill them I pass the text to chart series. After that I click on a button, and I add a value to each "option" as a percentage.

Option 1: II Option 2: IIIII Option 3: I

But every time I click on a button I got this:

enter image description here

I want to consider in the same bar (different series). This is the code:

    private void btnOpt1_Click(object sender, EventArgs e)
    {          
        opt1++;
        avg1 = (opt1 * 100) / total;
        crtStats.Series["Option 1"].Points.AddXY("Options", avg1);            
    }

What can I do?

Thanks.

TaW
  • 53,122
  • 8
  • 69
  • 111
  • What do you want to achieve? – Coding Freak Jan 05 '17 at 19:03
  • `AddXY("Options", avg1)` Adding X-Values as strings is always a bad idea which will result in all sorts of problems. Strings are converted to double resulting in x-values of `0` for all points. Most likely your issue.. - What outputs do you want when clicking a few times? – TaW Jan 05 '17 at 19:03
  • The output I want is just to have one bar for each serie not to be creating a bar by every click. For example now if I click 5 times on Option 1 get 5 blue bars. I want just to have one bar considering the 5 clicks. – Juan Jose Garcia Jan 05 '17 at 19:07
  • If you don't want to add new DataPoints don't do it! You can change the YValue[0] of a DataPoint if you know its Series and index in the Points collection, if that is what you want. [See here](http://stackoverflow.com/questions/41370297/c-sharp-add-to-y-value-on-chart/41370503#41370503) – TaW Jan 05 '17 at 19:25

0 Answers0