如何解决 MSchart 控件图 C# 的滚动大小问题

发布于 2024-11-07 14:09:36 字数 1825 浏览 5 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦明 2024-11-14 14:09:36

将比例视图类型设置为适当的时间选择。

m_chart.ChartAreas[0].AxisX.ScaleView.SizeType = "Seconds";
m_chart.ChartAreas[0].AxisX.ScaleView.MinSizeType= "Seconds";
m_chart.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSizeType= "Seconds";
m_chart.ChartAreas[0].AxisX.ScaleView.SmallScrollSizeType= "Seconds";

Set the scaleview type to the appropriate time selection.

m_chart.ChartAreas[0].AxisX.ScaleView.SizeType = "Seconds";
m_chart.ChartAreas[0].AxisX.ScaleView.MinSizeType= "Seconds";
m_chart.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSizeType= "Seconds";
m_chart.ChartAreas[0].AxisX.ScaleView.SmallScrollSizeType= "Seconds";
策马西风 2024-11-14 14:09:36

只需进行更改

m_chart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false;

,滚动条就会出现在图表区域之外,您就不会遇到这个问题。

Just change

m_chart.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false;

then the scroll bar will comes outside the chartarea and you will not face that problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文