2010-08-24 181 views
3

有誰知道我需要改變的屬性,以減少軸號的字體大小和更改字體樣式?還需要知道如何添加x和y標籤。在asp.net圖表中調整字體軸的樣式和大小?

<asp:Chart runat="server" ID="Chart1" Width="340px" Height="265px"> 
    <Series> 
     <asp:Series Name="scatter" MarkerSize="4" ChartType="Point" Color="Green" MarkerStyle="Circle"> 
     </asp:Series> 
    </Series> 
    <ChartAreas> 
     <asp:ChartArea Name="ChartArea1" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid" 
      BackSecondaryColor="White" BackColor="LightGreen" ShadowColor="Transparent" BackGradientStyle="TopBottom"> 
      <Area3DStyle Rotation="10" Perspective="10" Inclination="15" IsRightAngleAxes="False" 
       WallWidth="0" IsClustered="False" /> 
      <AxisY LineColor="64, 64, 64, 64"> 
       <LabelStyle Font="Trebuchet MS, 5pt" /> 
       <MajorGrid LineColor="64, 64, 64, 64" /> 
      </AxisY> 
      <AxisX LineColor="64, 64, 64, 64"> 
       <LabelStyle Font="Arial, 3pt" /> 
       <MajorGrid LineColor="64, 64, 64, 64" /> 
      </AxisX> 
     </asp:ChartArea> 
    </ChartAreas> 
    <Series> 
     <asp:Series Name="Line" ChartType="Line" BorderWidth="3" 
      MarkerStyle="None" BorderColor="180, 26, 59, 105" Color="DarkBlue"> 
     </asp:Series> 
    </Series> 
</asp:Chart> 
+0

做你有這個運氣嗎?我有似乎相同的問題:( – 2011-04-28 06:24:25

回答

7

看看LabelStyle這個類。

Axis.LabelStyle = new LabelStyle() { Font = new Font("Verdana", 7.5f) } 

例如與此LabelStyle加一個X軸,你可以這樣做:

Chart.ChartAreas["MyChart"].AxisX = new Axis { LabelStyle = new LabelStyle() { Font = new Font("Verdana", 7.5f) } } 

和設置標籤自動調整風格以防止標籤縮放可能是太有用:

Chart.ChartAreas.["MyChart"].AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None;