开发者

ASP.NET Chart: How to change font in Chart's Title?

开发者 https://www.devze.com 2023-03-13 12:28 出处:网络
The title of my pie chart is rather small. How do I change the font size or even the typeface of the TITLE of the chart? Tha开发者_如何学Cnks.Steve\'s answer is correct, alternatively it can be done i

The title of my pie chart is rather small. How do I change the font size or even the typeface of the TITLE of the chart? Tha开发者_如何学Cnks.


Steve's answer is correct, alternatively it can be done in C# like this:

yourChart.Titles.Add(
    new Title(
        "Gross National Rickrolls", 
        Docking.Top, 
        new Font("Verdana", 8f, FontStyle.Bold), 
        Color.Black
    )
);

Documentation on:

  • the Chart.Titles collection
  • the Title Class itself
  • the Font Class used above (from the System.Drawing)


Here's a standalone chart with a custom title:

<asp:Chart ID="Chart1" runat="server">
    <Titles>
        <asp:Title Font="Times New Roman, 12pt, style=Bold, Italic" Name="Title1" 
            Text="Hello World">
        </asp:Title>
    </Titles>
    <series>
        <asp:Series ChartArea="ChartArea1" ChartType="Pie" Name="Series1">
            <Points>
                <asp:DataPoint XValue="5" YValues="5" />
                <asp:DataPoint XValue="4" YValues="4" />
                <asp:DataPoint XValue="3" YValues="3" />
            </Points>
        </asp:Series>
    </series>
    <chartareas>
        <asp:ChartArea Name="ChartArea1">
        </asp:ChartArea>
    </chartareas>
</asp:Chart>
0

精彩评论

暂无评论...
验证码 换一张
取 消