简单的图表x轴值未出现

时间:2014-04-03 12:13:11

标签: c# charts

Chart chart = new Chart();               
dtRpt = dv.ToTable();
            chart.Height = 400;
            chart.Width = 400;
            chart.DataSource = dtRpt;
            chart.ChartAreas.Add("chart1");
            chart.Series.Add("s1");
            chart.Series[0].XValueMember = "vchCompetency";
            chart.Series[0].YValueMembers = "Average";
            return chart;






 [1]: http://i.stack.imgur.com/ogPUh.png

表:

vchCompetency sub      id    grd     Average                 Average1
Animals EVS 172 3   98.8695652173913    97.8260869565217
Birds   EVS 172 3   0   0
Data        Maths   172 3   0   0
Family  EVS 172 3   0   0
Food    EVS 172 3   0   0
Maps    EVS 172 3   81.7345426139159    81.6073713217203
Measurement Maths   172 3   58.6932108218479    58.1929555895865
Money   Maths   172 3   97.9021739130435    97.6630434782609
Numbers Maths   172 3   0   0
Patterns    Maths   172 3   0   0
Plants  EVS 172 3   0   0
Shelter EVS 172 3   0   0
Travel  EVS 172 3   0   0
Water   EVS 172 3   0   0

对于动态图表给出问题并不显示所有x轴值;任何人都帮我解决............................ .................................................. ..

1 个答案:

答案 0 :(得分:0)

找到了答案:

 Chart chart = new Chart();               
    dtRpt = dv.ToTable();
    chart.Height = 400;
    chart.Width = 400;
    chart.DataSource = dtRpt;
    chart.ChartAreas.Add("chart1");
    chart.Series.Add("s1");
    chart.Series[0].XValueMember = "vchCompetency";
    chart.Series[0].YValueMembers = "Average";
    chart.ChartAreas["chart1"].AxisX.Interval = 0.5;
    chart.ChartAreas["chart1"].AxisX.Minimum = 0;
    chart.ChartAreas["chart1"].AxisX.Maximum = dtRpt.rows.count;

    return chart;