Align chart areas horizontally in ASP.NET chart control

时间:2016-06-01 11:52:36

标签: c# asp.net .net charts mschart

I have two chart areas Chartarea1 and Chartarea2 inside a single chart control.

But this is getting aligned vertically, I want to align it horizontally. I used AlignmentOrientation="Horizontal" but of no help.

I am getting output as below:

enter image description here

但我需要输出为: enter image description here

<asp:Chart ID="chartTest" runat="server" EnableViewState="true" Visible="false" Width="650px"><Titles><asp:Title Text="Test" Font="Arial, 11pt, style=Bold" /></Titles><Series><!--have few series here --></Series><ChartAreas><asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="false"><Area3DStyle Enable3D="false" WallWidth="3" LightStyle="Realistic"></Area3DStyle></asp:ChartArea><asp:ChartArea Name="ChartArea2" Area3DStyle-Enable3D="false"><Area3DStyle Enable3D="false" WallWidth="3" LightStyle="Realistic"></Area3DStyle></asp:ChartArea></ChartAreas></asp:Chart>

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:4)

您可以控制ChartArea的位置和尺寸:

    protected void Page_Load(object sender, EventArgs e)
    {
        Chart1.ChartAreas[0].Position.Auto = false;
        Chart1.ChartAreas[0].Position.X = 0;
        Chart1.ChartAreas[0].Position.Y = 0;
        Chart1.ChartAreas[0].Position.Height = 25;
        Chart1.ChartAreas[0].Position.Width = 25;

        Chart1.ChartAreas[1].Position.Auto = false;
        Chart1.ChartAreas[1].Position.X = 25;
        Chart1.ChartAreas[1].Position.Y = 0;
        Chart1.ChartAreas[1].Position.Height = 25;
        Chart1.ChartAreas[1].Position.Width = 25;
    }

enter image description here