I’m trying to make a pie chart that uses values from a user from text box’s. I’m using c# windows forms chart control.
The problem is where to assign the text box’s as values.
- Is it done in code? if so what do I call?
- Is it done in the control properties? if so what do I do?
- Is it a bit of both? is so, well same as both above.
I’ve attempted to make one using the properties wizard but I cant see where to assign the values for it to process, the data source seem to only allow objects and connections to Dbos.
I’m hoping this is a really simple process I’m overlooking.
Yes I’ve checked MSDN but not a lot of info on the specifics I require. Yes I’ve checked google but again there is either no info or info on building my own from scratch (which I have done, but looks really bad)
this is some code ive tried
double[] yValues = { 10, 8, 7, 12};
string[] xNames = { "Greater than 200", "Between 200-100", "Between 100-50", "Below 50" };
chart1.Series[0].Points.DataBindXY(xNames, yValues);
chart1.Series[1].Points.DataBindXY(xNames, yValues);
chart1.Series[2].Points.DataBindXY(xNames, yValues);
chart1.Series[3].Points.DataBindXY(xNames, yValues);
it errors at series[2], saying the index was out of range. Im guessing it something to do with how the chart is currently set up
::UPDATED::
Ok so i was right i didnt assign enough series to the chart (silly me). Ive managed to get it up and running…..unfortunatly the image display looks like…..a letter(wierd).
Its a box with a cross in the middle all equal aswell. I would at least think its would display proportional to the values i sent. so is this a set up OR is there something im doing wrong in my code?
I would suggest something like this.
Where you would plug your y values directly from your textboxes.