0
votes

I'm new in C# development and have some problem that hope I can find the answer here for. My chart has data source from Excel and chart with default values shows correctly, however I would like to have Axis-X label to be scale (from 1 to 100 or more) instead of column value. This is how sample data looks like:

enter image description here

So in my chart, Axis X has labels like: "test1 test2 test3 test4 test5 test6 test7"

But I would like to have scale which present number of instances from lowest to highest number, like:

1 2 3 4 5 6 7

I hope somebody can help with an example or direction of what I should set in the Axis-X properties to achieve this goal.

Thanks,

Rado

1
Welcome. Please post the code you have tried, and tell us the resulting errorCory
You ca set the yourChartArea.XAxis.Minimum and .Maximum values.TaW

1 Answers

0
votes

Just add your datapoints to Series with:

chart1.Series[0].Points.AddY(yourYValue);

or

chart1.Series[0].Points.DataBindY(yourListOfYValues);

instead of(i assume your using one of these, some code would be helpful):

chart1.Series[0].Points.AddXY(yourXValue,yourYValue);

or

chart1.Series[0].Points.DataBindXY(yourXValue, yourListOfYValues);

The chart control should then set your x-axis-label to 1,2,3... by default. I hope this helps.