2009-04-30 46 views
2

Chart1显示所有标签,但是一旦我添加了第10项,一半的标签就消失了。为什么标签在ASP.NET图表中消失?

首先标记:

<asp:Chart ID="Chart1" runat="server" Width="700" Height="600"> 
     <series> 
      <asp:Series Name="Series1" ChartType="Bar" /> 
     </series> 
     <chartareas> 
      <asp:ChartArea Name="ChartArea1" /> 
     </chartareas> 
    </asp:Chart> 

    <asp:Chart ID="Chart2" runat="server" Width="700" Height="600"> 
     <series> 
      <asp:Series Name="Series1" ChartType="Bar" /> 
     </series> 
     <chartareas> 
      <asp:ChartArea Name="ChartArea1"/> 
     </chartareas> 
    </asp:Chart> 

而且我们添加一些数据...

Dim labels As New System.Collections.Generic.Dictionary(Of String, Integer) 

    labels.Add("1 thing", 24655) 
    labels.Add("2 thing", 11355) 
    labels.Add("3 thing", 6890) 
    labels.Add("4 thing", 5815) 
    labels.Add("5 thing", 5155) 
    labels.Add("6 thing", 4160) 
    labels.Add("7 thing", 2430) 
    labels.Add("8 thing", 2055) 
    labels.Add("9 thing", 1545) 


    Chart1.Series("Series1").Points.DataBindXY(labels, "Key", labels, "Value") 
    Chart1.DataBind() 

    labels.Add("10 thing", 1530) 

    Chart2.Series("Series1").Points.DataBindXY(labels, "Key", labels, "Value") 
    Chart2.DataBind() 

回答

3

我不得不设置轴的间隔为

Chart2.ChartAreas("ChartArea1").AxisX.Interval = 1 
+0

+1我希望我能给你更多,因为这是一个伟大的地方!这让我疯狂! – James 2009-11-29 21:39:10