本文介绍了如何对齐innerPlot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个图表: chart1 chart2

我希望两个图表都具有相同的 innerPlotSize 位置

I want both charts to have same innerPlotSize and location.

但是 chart1 有第二个yaxis。

But chart1 has a secondary yaxis.

这不起作用:

chart2.ChartAreas[0].AlignWithChartArea = chart1.ChartAreas[0].Name;
chart2.ChartAreas[0].AlignmentStyle = AreaAlignmentStyles.PlotPosition;
chart2.ChartAreas[0].AlignmentOrientation = AreaAlignmentOrientations.Vertical;


推荐答案

这将对齐 InnerPlotPositions 的两个图表

    // 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);
    }

之前和之后:

这篇关于如何对齐innerPlot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 13:31