如何使用c#在图表控件中对齐中心图例 [英] how to align the center legends in chart control using c#

查看:266
本文介绍了如何使用c#在图表控件中对齐中心图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了图表控制与传说。我的问题是传说将移动到图表控件的中心对齐



i我正在使用.aspx代码

i implemented chart control with legends.here my issue is legends will move to center alignmentment of chart control

i am using .aspx code

<asp:Chart ID="Chart2" runat="server" Height="640px" Width="640px"  Visible="false"

            BorderSkin-BorderColor="#559933" Palette="Chocolate"

            BorderlineDashStyle="DashDotDot" TextAntiAliasingQuality="Normal"

            BackImageAlignment="BottomLeft">

    <Titles>
        <asp:Title ShadowOffset="1" Name="Items" ForeColor="Red" Font="25"/>
    </Titles>
    <%--<Legends>

        <asp:Legend  Alignment="Center" Docking="Bottom" LegendStyle="Table" />
    </Legends>--%>

    <Series>

       <asp:Series Name="Default" IsValueShownAsLabel="True" LabelForeColor="Black" BorderDashStyle="NotSet"

        IsXValueIndexed="true" IsVisibleInLegend="false"  Palette="Pastel"

            ToolTip="#valx"></asp:Series>

    </Series>
    <ChartAreas>

      <asp:ChartArea Name="ChartArea1" BorderWidth="0"

            AlignmentOrientation="None" BackGradientStyle="Center" BorderColor="Azure" >
           </asp:ChartArea>
     </ChartAreas>
    <Annotations>
    </Annotations>
<BorderSkin BorderColor="85, 153, 51"></BorderSkin>
</asp:Chart>





并使用此.cs代码



and using this .cs code

dt_chart = objLOUPeDAL.GetChart(snlcompanyname, reporttypeflag, snlstatelob, foryears, forperformance, Chartlobgrouplist);
Chart1.Visible = true;
ChartArea area = new ChartArea();
string[] x = new string[dt_chart.Rows.Count];
int[] y = new int[dt_chart.Rows.Count];
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisX.Title = "";
Chart1.ChartAreas[0].AxisX.Interval = 1;
Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#,0,.0";
Legend legend1 = new Legend("Legend1");
LegendItem legendItem1 = new LegendItem("Under Performance", Color.Red, "");
legendItem1.BorderColor = Color.Red;
 LegendItem legendItem2 = new LegendItem("Out Performance", Color.Green, "");
legendItem2.BorderColor = Color.Green;
LegendItem legendItem3 = new LegendItem("", Color.Transparent, "");
legendItem3.BorderColor = Color.Transparent;
legend1.CustomItems.Add(legendItem1);
legend1.CustomItems.Add(legendItem2);
legend1.CustomItems.Add(legendItem3);
legend1.Docking = Docking.Bottom;
this.Chart1.Legends.Add(legend1);
Chart1.Series[0].ToolTip = "#VAL";
Chart1.Series[0].ShadowOffset = 2;
Chart1.Series[0].XValueType = ChartValueType.Double;
Chart1.ChartAreas["ChartArea1"].BorderWidth = 8;
Chart1.Series[0].LabelToolTip = dt_chart.Rows.ToString();
Chart1.Series[0]["PieLabelStyle"] = "outside";
Chart1.Series[0]["PieLineColor"] = "Black";
Chart1.Series[0]["PieStartAngle"] = "-90";
Chart1.Series[0].Label = "#VALY{#,0,.0}";



请与我分享任何想法







添加标签。

[/编辑]

推荐答案

这篇关于如何使用c#在图表控件中对齐中心图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆