如何在不使用 AlignToChartArea 的情况下对齐滚动两个图表区域?
我在 Chart
中有两个 ChartArea
对象(System.Windows.Forms.DataVisualization.Charting
是我正在使用的)。
一种是点图,另一种是 RangeBar 图。 RangeBar 图表上的水平轴实际上是 Y 轴,所以我不能只使用这样的东西:
Chart1.ChartAreas["Chart Area 2"].AlignWithChartArea = "Default";
我已经弄清楚如何缩放两个图表并保持它们对齐,但是当我尝试滚动时通过单击水平轴之一上的滚动条来显示这两个图表,我无法完全使其对齐。它们几乎排成一行,但可能相差一秒左右(两张图中的横轴都是时间)。
这就是我所拥有的:
private void theChart_AxisViewChanged(object sender, ViewEventArgs e)
{
if (e.ChartArea == theChart.ChartAreas["MyPointChartArea"])
{
theChart.ChartAreas["MyRangeBarChartArea"].AxisY.ScaleView.Position = e.NewPosition;
theChart.ChartAreas["MyRangeBarChartArea"].AxisY.ScaleView.Size = e.NewSize;
theChart.ChartAreas["MyRangeBarChartArea"].AxisY.ScaleView.SizeType = e.NewSizeType;
}
if (e.ChartArea == theChart.ChartAreas["MyRangeBarChartArea"])
{
theChart.ChartAreas["MyPointChartArea"].AxisX.ScaleView.Position = e.NewPosition;
theChart.ChartAreas["MyPointChartArea"].AxisX.ScaleView.Size = e.NewSize;
theChart.ChartAreas["MyPointChartArea"].AxisX.ScaleView.SizeType = e.NewSizeType;
}
}
我还需要做什么才能使图表对齐?图表的物理范围是相同的。只是数据略有偏差。
感谢您的任何帮助。
I have two ChartArea
objects in a Chart
(System.Windows.Forms.DataVisualization.Charting
is what I'm using).
One is a Point graph, and the other is a RangeBar graph. The horizontal axis on the RangeBar graph is actually the Y axis, so I cannot just use something like this:
Chart1.ChartAreas["Chart Area 2"].AlignWithChartArea = "Default";
I've figured out how to zoom both charts and keep them aligned, but when I try to scroll both charts by clicking on the scrollbar on one of the horizontal axes, I can't quite get it to line up. They almost line up, but they're off by maybe a second or so (the horizontal axis in both graphs is time).
Here's what I have:
private void theChart_AxisViewChanged(object sender, ViewEventArgs e)
{
if (e.ChartArea == theChart.ChartAreas["MyPointChartArea"])
{
theChart.ChartAreas["MyRangeBarChartArea"].AxisY.ScaleView.Position = e.NewPosition;
theChart.ChartAreas["MyRangeBarChartArea"].AxisY.ScaleView.Size = e.NewSize;
theChart.ChartAreas["MyRangeBarChartArea"].AxisY.ScaleView.SizeType = e.NewSizeType;
}
if (e.ChartArea == theChart.ChartAreas["MyRangeBarChartArea"])
{
theChart.ChartAreas["MyPointChartArea"].AxisX.ScaleView.Position = e.NewPosition;
theChart.ChartAreas["MyPointChartArea"].AxisX.ScaleView.Size = e.NewSize;
theChart.ChartAreas["MyPointChartArea"].AxisX.ScaleView.SizeType = e.NewSizeType;
}
}
What else do I need to do to get the charts to line up? The physical extent of the charts is the same. It's just the data that are slightly misaligned.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论