Zadalaxmi
Zadalaxmi

Reputation: 421

chart x-axis data is not visible when more than 10 point

chart x-axis data is not visible when more than 10 point:

chart.ChartAreas.Add("chart1");
                chart.Series.Add("s1");
                for (int i = 0; i < dtRpt.Rows.count; i++)
                {
                    string i1=dtRpt.Rows[i]["vchCompetency"].ToString();
                    float i2 = float.Parse(dtRpt.Rows[i]["Average"].ToString(), CultureInfo.InvariantCulture.NumberFormat); 
                    chart.Series[0].Points.AddXY(i1, i2);
                }

Its my chart code;how to overcome by this problem ;any other method is there. i tried for chartarea.AxisX.IntervalType its not working for string value.Any help me to resolve this problem.

Upvotes: 1

Views: 1264

Answers (1)

user3165588
user3165588

Reputation:

OT: Why not use the DataBindTable or DataBindCrossTable? Its cleaner and faster.

It's better practice to set the DataType of axis

Chart1.Series[0].XValueType = ChartValueType.[type]

instead of passing everything as a string. That way the chart control don't have to guess and usually this create less problems.

(Actually you retrieved the value as a string from the DataTable and casted into float - wicked!)

You might wanna check the Chart1.AxisX(or Y).Interval property instead of Chart1.AxisX(or Y).IntervalType to display more specific chart. Usually the Interval is set by default accordingly to the amount of data to be shown.

Upvotes: 1

Related Questions