如何解决 MSchart 控件图 C# 的滚动大小问题
我使用 MSChart 制作了一个图表,并且能够实现缩放功能。
图表可以缩放,但是当我缩放后想要四处移动时,就会出现问题。当我在 y 轴滚动条上上下单击时,滚动增量很好。然而,对于x轴滚动条来说,滚动增量是可怕的。即使中间有数据,它也总是会走到最后。
我尝试在网上寻找解决方案,但运气不好,
这是我的代码:
// Chart area (where the axes and series are plotted)
ChartArea chartArea = new ChartArea();
chartArea.AxisX.Minimum = DateTime.MinValue.ToOADate();
chartArea.AxisY.Minimum = 0;
chartArea.AxisY.Maximum = 100;
//chartArea.AxisY.IntervalAutoMode = IntervalAutoMode.VariableCount;
chartArea.AxisX.Title = "Time";
chartArea.AxisX.LabelStyle.Format = DEFAULT_TIME_FORMAT_STRING;
chartArea.AxisY.LabelStyle.Format = "#########################";
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
chartArea.BackColor = Color.Transparent;
m_chart.ChartAreas.Add(chartArea);
//add zoom-in features for x and y axis
m_chart.ChartAreas[0].CursorY.Interval = 0;
m_chart.ChartAreas[0].CursorY.IsUserEnabled = true;
m_chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
m_chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
m_chart.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true;
m_chart.ChartAreas[0].CursorX.Interval = 0;
//m_chart.ChartAreas[0].CursorX.AutoScroll = true;
//m_chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
m_chart.ChartAreas[0].CursorX.IsUserEnabled = true;
m_chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
m_chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
m_chart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
我不明白我做错了什么
I made a graph using MSChart and I was able to implement the zooming ability.
The graph can zoom but the problem arises when I want to move around after I zoom. When I click up and down on the y axis scrollbar, the scrolling increment is fine. However, for the x axis scrollbar, the scrolling increment is horrible. It will always go the very end even though there is data in the middle.
I tried looking online for the solution but was out of luck
here is my code:
// Chart area (where the axes and series are plotted)
ChartArea chartArea = new ChartArea();
chartArea.AxisX.Minimum = DateTime.MinValue.ToOADate();
chartArea.AxisY.Minimum = 0;
chartArea.AxisY.Maximum = 100;
//chartArea.AxisY.IntervalAutoMode = IntervalAutoMode.VariableCount;
chartArea.AxisX.Title = "Time";
chartArea.AxisX.LabelStyle.Format = DEFAULT_TIME_FORMAT_STRING;
chartArea.AxisY.LabelStyle.Format = "#########################";
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
chartArea.BackColor = Color.Transparent;
m_chart.ChartAreas.Add(chartArea);
//add zoom-in features for x and y axis
m_chart.ChartAreas[0].CursorY.Interval = 0;
m_chart.ChartAreas[0].CursorY.IsUserEnabled = true;
m_chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = true;
m_chart.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
m_chart.ChartAreas[0].AxisY.ScrollBar.IsPositionedInside = true;
m_chart.ChartAreas[0].CursorX.Interval = 0;
//m_chart.ChartAreas[0].CursorX.AutoScroll = true;
//m_chart.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
m_chart.ChartAreas[0].CursorX.IsUserEnabled = true;
m_chart.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
m_chart.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
m_chart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
I dont see what I am doing wrong
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将比例视图类型设置为适当的时间选择。
Set the scaleview type to the appropriate time selection.
只需进行更改
,滚动条就会出现在图表区域之外,您就不会遇到这个问题。
Just change
then the scroll bar will comes outside the chartarea and you will not face that problem.