Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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? Thanks.

like image 973
user776676 Avatar asked Jun 15 '11 23:06

user776676


2 Answers

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)
like image 162
Molomby Avatar answered Sep 20 '22 07:09

Molomby


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>
like image 30
Steve Wellens Avatar answered Sep 21 '22 07:09

Steve Wellens