Dot-Net

具有 ASP.NET 圖表類型“列”的 MS 圖表不顯示軸 x 標籤,如果圖表中有超過 9 個條形圖

  • March 13, 2016

我有一個 MS Chart 圖表類型列的問題。如果圖表中有超過 9 個條形,則軸 x 標籤將無法正確顯示,其中一些會消失。

這是我對圖表的標記:

<asp:Chart ID="chtNBAChampionships" runat="server">
  <Series>
     <asp:Series Name="Championships" YValueType="Int32" Palette="Berry"   ChartType="Column" ChartArea="MainChartArea" IsValueShownAsLabel="true">
        <Points>
           <asp:DataPoint AxisLabel="Celtics" YValues="17" />
           <asp:DataPoint AxisLabel="Lakers" YValues="15" />
           <asp:DataPoint AxisLabel="Bulls" YValues="6" />
           <asp:DataPoint AxisLabel="Spurs" YValues="4" />
           <asp:DataPoint AxisLabel="76ers" YValues="3" />
           <asp:DataPoint AxisLabel="Pistons" YValues="3" />
           <asp:DataPoint AxisLabel="Warriors" YValues="3" />
           <asp:DataPoint AxisLabel="Mara" YValues="4" />
           <asp:DataPoint AxisLabel="Saza" YValues="9" />
           <asp:DataPoint AxisLabel="Buha" YValues="6" />

        </Points>
     </asp:Series>
  </Series>
  <ChartAreas>
     <asp:ChartArea Name="MainChartArea">
     </asp:ChartArea>
  </ChartAreas>
</asp:Chart>

只有 9 條它可以工作,但我不知道為什麼超過 9 條它會失敗。有什麼方法可以使圖表正常工作嗎?另外,如果可能的話,如何使每個條具有不同的顏色?

我有同樣的問題,但我在頁面載入時使用 c#。

我通過添加這個解決了它

   Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;

Chart2.ChartAreas

.AxisX.Interval = 1;

引用自:https://stackoverflow.com/questions/2435540