How can I align the innerPlots?

前端 未结 1 1503
半阙折子戏
半阙折子戏 2021-01-27 23:47

I have 2 charts: chart1 and chart2.

I want both charts to have same innerPlotSize and location.

But cha

相关标签:
1条回答
  • 2021-01-28 00:11

    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:

    0 讨论(0)
提交回复
热议问题