How can I align the innerPlots?

筅森魡賤 提交于 2019-12-02 10:35:54

This will align the InnerPlotPositions of two Charts:

    // align the controls:
    yourChart1.Left = yourChart2.Left;
    yourChart1.Size = yourChart2.Size;


    // get the numbers of the current innerplotpositions
    RectangleF ri1 = yourChart1.ChartAreas[0].InnerPlotPosition.ToRectangleF();
    RectangleF ri2 = yourChart2.ChartAreas[0].InnerPlotPosition.ToRectangleF();

    if (ri1.Width < ri2.Width)
    {
        yourChart2.ChartAreas[0].InnerPlotPosition =
            new ElementPosition(ri1.Left, ri2.Top, ri1.Width, ri2.Height);
    }
    else 
    {
        yourChart1.ChartAreas[0].InnerPlotPosition =
            new ElementPosition(ri2.Left, ri1.Top, ri2.Width, ri1.Height);
    }

Before and after:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!