Change the font style of Pie Chart by setting Font Property in Series in ASP.Net

Last Reply 10 months ago By Rucha

Posted 10 months ago

 

    public void CreateChartFastMoving()
    {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["InvoiceApp"].ToString());
            con.Open();
            DataTable dsbox = new DataTable();
            SqlCommand cmd = new SqlCommand("DisplayTopSellingProductUserSide", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dsbox);
            Chart1.DataSource = dsbox;
     	    Chart1.ChartAreas[0].AxisX.LabelStyle.Font = new System.Drawing.Font("Arial", 12f, FontStyle.Bold);
            Chart1.DataBind();       
    }

Hello,

I am getting trouble to apply font style in asp.net chart control.

I want to change the font style of pie chart which shows productname using asp chart control.

I apply following for that.

"Chart1.ChartAreas[0].AxisX.LabelStyle.Font = new System.Drawing.Font("Arial", 12f, FontStyle.Bold);"

But it do not aafect it shows default font.

What can i do?Please suggest.

Thanks in advance.

You are viewing reply posted by: Rucha 10 months ago.
Posted 10 months ago

Hello Kalpesh,

Thanks you so much for your fast reply.

But it doesnt work.

Finally i got answer.

 Set font property in series like below.

 Font="Times New Roman, 11pt, style=Bold, Italic"

 

 <Series>
                        <asp:Series Name="TopSellingProduct" XValueMember="ProductName" YValueMembers="TotalQty"
                            IsVisibleInLegend="true" ChartType="Pie"  Label="#VALX(#VAL)"  CustomProperties="BarLabelStyle=Right" IsValueShownAsLabel="True"  Font="Times New Roman, 11pt, style=Bold, Italic" >
                        </asp:Series>
                    </Series>

Thanks