简体   繁体   English

Microsoft WinForms图表控件-设置Y轴标签的位置

[英]Microsoft WinForms Chart Control - Set Position of Y-Axis Label

I have a Y-Axis Label as shown here: 我有一个Y轴标签,如下所示:

在此处输入图片说明

I am trying to position the label closer to the chart, is there any facility to do this? 我正在尝试将标签放置在离图表更近的地方,是否有这样做的设施?

I could add a Winforms Label and position it accordingly but just in case there is a better way. 我可以添加Winforms标签并相应地放置它,但以防万一有更好的方法。

If you are talking about the AxisY.Title AvGkW you can't position it other than aligning it near, center, far . 如果您在谈论AxisY.Title AvGkW ,则只能将其对齐near, center, far

But you can add as many Titles to your Chart as you want, dock them to all four corners of the earth, um, Chart , style them and set their offset.. 但是您可以根据需要向Chart添加任意多个Titles ,将它们停靠在地球的所有四个角处,例如um, Chart ,设置其样式并设置其偏移量。

After you have added your Title like this: 像这样添加Title

Title TT = new Title( yourTitleText, Docking.Left, yourFont, yourcolor);
TT.Docking = Docking.Left;
yourChart.Titles.Add(TT);

You can move it left and right like this: 您可以像这样左右移动它:

TT.DockingOffset = yourOffset;

It isn't in the specs here on MSDN but as usual it is in 1/100 of the Chart.Size , so setting it to 50 moves the Title into the middle of the ChartArea .. It is an int32 strangely! 它不在MSDN上的规范中,但通常它位于Chart.Size 1/100中,因此将其设置为50会将Title移动到ChartArea的中间..奇怪的是,它是int32

You will have to play with the number depending on the size of the Y-Labels and the position of the Y-Axis . 您将不得不根据Y-Labels的大小和Y-Axis的位置来玩数字游戏。 Values of 2-7 are OK here.. 2-7值在这里可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM