4

Change asp chart legend label width

Aspx

<asp:Chart ID="Chart1" runat="server" Width="600px">
    <Series>
        <asp:Series Name="Series1" ChartType="Pie" IsValueShownAsLabel="True" Legend="Legend1">
        </asp:Series>
    </Series>
    <ChartAreas>
        <asp:ChartArea Name="ChartArea1" AlignmentOrientation="All">
            <AxisX TitleAlignment="Near">
            </AxisX>
        </asp:ChartArea>
    </ChartAreas>
    <Legends>
        <asp:Legend  Name="Legend1" >
        </asp:Legend>
    </Legends>
</asp:Chart>

Code behind

Chart1.Titles.Add(new Title("Completed/Pending Count Anaysis",Docking.Top,new Font("Verdana", 12f, FontStyle.Bold),Color.Black));
Chart1.Series[0].XValueMember = "COLUMN_NAME";
Chart1.Series[0].YValueMembers = "H_COUNT";
Chart1.Series[0].ChartType = SeriesChartType.Pie;
Chart1.Series[0].IsValueShownAsLabel = false;

Chart1.Series[0].Label = "#PERCENT";
Chart1.Series[0].LabelFormat = "{0:0%}";
Chart1.Series[0].LegendText = "#VALX #PERCENT{P2}";

Chart1.Series["Series1"]["PieLabelStyle"] = "outside";
Chart1.Series[0]["PieStartAngle"] = "45";
Chart1.Series[0].LabelForeColor = Color.Black;

Chart1.Legends["Legend1"].Docking = Docking.Bottom;
Chart1.Legends["Legend1"].IsDockedInsideChartArea = false;

Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Inclination = 30;
Chart1.DataSource = ds;

Any one have an idea how to fix this?

Nishantha
  • 6,065
  • 6
  • 33
  • 51

0 Answers0