在ChartArea上设置Postion属性时,MSC在轴上没有值 [英] MSChart no values on axes when setting Postion property on ChartArea

查看:136
本文介绍了在ChartArea上设置Postion属性时,MSC在轴上没有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hy,

我开始使用MSChart开发项目中的图表。我需要显示一个带有范围栏的折线图。我明白这两种类型的系列不能在同一个ChartArea中。没关系,我尝试将每一个放在它的图表区域上,我尝试用
覆盖它们,使它们看起来像在同一个图表中。

I began developing a chart in my project using MSChart. i need to display a line chart with a range bar over it. I understood that these two types of series cannot be in the same ChartArea. That's ok, I tried putting each one in it's on chartarea and I tried to overlay them so that their appear like in the same chart.

问题是,如果我尝试使用下面的代码覆盖图表区域

The problem is that if i try to overlay the chartareas using the code below


ChartArea1.Position = new ElementPosition(10, 10, 80, 80);
ChartArea1.InnerPlotPosition = new ElementPosition(0, 0, 100, 100);
ChartArea2.Position.FromRectangleF(ChartArea1.Position.ToRectangleF());
ChartArea2.InnerPlotPosition.FromRectangleF(ChartArea1.InnerPlotPosition.ToRectangleF());

推荐答案

标签不可见,因为在设置ChartArea时你没有留下任何空间.InnerPlotPosition为(0,0,100,100)。 绘图区域占据整个图表区域。将InnerPlotPosition设置为(10,10,80,80) 以
为例。

The labels are not visible because you're not leaving any room for them when setting the ChartArea.InnerPlotPosition to (0, 0, 100, 100). The plot area is taking up the whole chart area. Set the InnerPlotPosition also to (10, 10, 80, 80) for example.

如果图表区域位置设置为自动,则不会获得值直到Chart.PrePaint事件并且不幸地改变位置不再有效。因此,您无法使用一个区域的自动计算值来调整另一个区域的

If the chart area positions are set to auto, they won't get values until the Chart.PrePaint event and unfortunately changing the position there has no effect anymore. So you can't use the automatically calculated values of one area to adjust the position of another.

但是,如果每个图表区域上的标签完全相同,可以将InnerPlotPosition保留为自动并依赖图表控件为标签留出足够的空间。您可以通过在每个图表区域设置轴min,max和interval 相同的
来完成此操作。 (请注意,  X轴是条形图中的垂直轴)虽然如果每个系列上的数据非常不同,这可能不是一个好的解决方法。

However, if the labels on each chart area are exactly the same, you can leave the InnerPlotPosition to Auto and depend on the chart control to leave enough room for the labels. You can do this by setting the axes min, max and interval the same on each chart area. (Note that the X axis is the vertical one in a bar chart) Though if the data on each series are very different, this may not be a good workaround.


这篇关于在ChartArea上设置Postion属性时,MSC在轴上没有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆