调整asp.net图表中的字体轴样式和大小?

发布于 2024-09-15 20:53:12 字数 1430 浏览 6 评论 0原文

有谁知道我需要更改哪些属性来减小轴数字的字体大小并更改字体样式?还需要知道如何添加 x 和 y 标签。

<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>

Does anyone know the properties that I need to change to decrease the font size of the axes numbers and change the font style? Also need to know how to add x and y labels.

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離人涙 2024-09-22 20:53:12

查看 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;

Take a look at the LabelStyle class.

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

For example to add an X axis with this LabelStyle you can do:

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

And setting label auto fit style to prevent label scaling may be useful too:

Chart.ChartAreas.["MyChart"].AxisY.LabelAutoFitStyle = LabelAutoFitStyles.None;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文