从图表控件中删除白色和不必要的空间 [英] Remove white and unnecessary space from Chart control
问题描述
我有一个图表,我已将它添加到面板,但正如你可以看到在图片中,图表不填充整个面板。它有很多的空白,我用红色突出显示。
I have a chart and I've added it to a panel but as you can see in the picture, the chart does not fill the whole panel. it has a lot of white space that I highlighted in red.
如何删除我的图表左侧,右侧和底部的这个空间,以便它填充面板?
How can I remove this space on the left, right and bottom of my chart so that it fills the panel?
我尝试停靠它,我也将其margin属性更改为false,但是这些解决方案都无效。
I tried docking it and I also changed its margin property to false but these solutions did not work.
我的图表是.NET WinForms图表:
My chart is .NET WinForms chart:
推荐答案
您可以手动设置 ChartArea
的 ElementPosition
this:
You can manually set the ChartArea
's ElementPosition
like this:
ChartArea CA = chart1.ChartAreas[0];
CA.Position = new ElementPosition(0, 0, 100, 100);
这意味着:将其设置为左上角,并将其填充到 100%
。
This means: Set it to the Top Left and make it fill the chart to 100%
.
标签需要剩余的空格;您还可以使用小于0%和/或大于100%的数字进一步调整。
The remaining white space is needed for the labels; you can tweak it further still by using numbers less than 0% and/or greater than 100%.
请注意,它们不是像素,而是百分比,因此它们将始终与图表控件的整个 ClientSize
相关!
Do note that they are not pixels but percent, so they will always relate to the whole ClientSize
of the chart control!
之前和之后:
这篇关于从图表控件中删除白色和不必要的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!