c# - 在 ASP.NET 图表控件中水平对齐图表区域

标签 c# asp.net .net charts mschart

我在一个图表控件内有两个图表区域 Chartarea1 和 Chartarea2。

但是这是垂直对齐的,我想水平对齐。我使用了 AlignmentOrientation="Horizo​​ntal"但没有帮助。

我得到的输出如下:

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>

任何帮助将不胜感激。

最佳答案

您可以控制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

关于c# - 在 ASP.NET 图表控件中水平对齐图表区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37567878/

相关文章:

c# - MVC 代码优先 : One-to-many relationship between own model and SimpleMembership user

asp.net - 数据库或文件中的配置值?

c# - 如何在 ASP.NET Web API 异步 Controller 方法中返回对象列表

c# - 通过中继器迭代

asp.net - 如何将验证器分配给按钮

c# - Swashbuckle - 从另一个项目的模型向 Swagger UI 添加模型和示例值

c# - 如何在没有时间的情况下获取当前日期?

c# - Web Api 调用未在 JSON 响应中返回 __type

c# - 如何检查模型列表中的重复条目?

c# - Microsoft Access 中的 bool 列和使用 linq 过滤数据