1

图表 x 轴数据超过 10 点时不可见:

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);
                }

这是我的图表代码;如何解决这个问题;还有其他方法。我试过chartarea.AxisX.IntervalType它不适用于字符串值。任何帮助我解决这个问题。

4

1 回答 1

1

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.

于 2014-04-04T10:50:15.447 回答