繁体   English   中英

使用MS Chart Controls缩放时,为什么我的X轴标签会消失?

[英]Why do my X-Axes labels disappear when I zoom using MS Chart Controls?

我正在使用MS Chart Controls。 折线图是基于正常时间的图表。 问题是当我单击图表并选择放大时间时,会出现滚动条,并且x轴标签消失。 我怎样才能防止这种情况发生? 如果我无法自动修复它,是否有代码我可以添加到一个按钮来修复标签?

private void Chart0Configuration()
    {
        chart1.ChartAreas[0].Visible = false;
        chart1.ChartAreas[0].AlignmentOrientation = AreaAlignmentOrientations.Vertical;
        chart1.ChartAreas[0].AlignmentStyle = AreaAlignmentStyles.All;

        chart1.ChartAreas[0].Position.Auto = false;
        chart1.ChartAreas[0].Position.X = 2;
        chart1.ChartAreas[0].Position.Y = 10;
        chart1.ChartAreas[0].Position.Width = 98;
        //chart1.ChartAreas[0].Position.Height = *****variable


        //chart1.ChartAreas[0].AxisY.MajorTickMark.Enabled = false;
        //chart1.ChartAreas[0].AxisY.MinorTickMark.Enabled = false;
        //chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

        //chart1.ChartAreas[0].AxisX.MajorTickMark.Enabled = true;
        //chart1.ChartAreas[0].AxisX.MinorTickMark.Enabled = true;
        //chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
        //chart1.ChartAreas[0].AxisX.MajorTickMark.Interval = 10;

        chart1.ChartAreas[0].AxisX.Interval = 0;
        chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;

        chart1.ChartAreas[0].AxisX.LabelStyle.Enabled = true;
        //chart1.ChartAreas[0].AxisX.LabelStyle.Format = "hh:mm:ss";
        chart1.ChartAreas[0].AxisY.LabelStyle.IsEndLabelVisible = true;

        chart1.ChartAreas[0].InnerPlotPosition.Auto = false;
        chart1.ChartAreas[0].InnerPlotPosition.X = 3;
        chart1.ChartAreas[0].InnerPlotPosition.Y = 10;
        chart1.ChartAreas[0].InnerPlotPosition.Width = 88;
        chart1.ChartAreas[0].InnerPlotPosition.Height = 80;

        chart1.ChartAreas[0].CursorX.IsUserEnabled = true;
        chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
        //chart1.ChartAreas[0].CursorX.AutoScroll = true;
        chart1.ChartAreas[0].CursorX.Position = 0;
        chart1.ChartAreas[0].CursorX.Interval = 0;


        chart1.ChartAreas[0].AxisX.ScrollBar.Size = 5;
        chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
        chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
        chart1.ChartAreas[0].AxisX.ScrollBar.BackColor = Color.LightGray;
        chart1.ChartAreas[0].AxisX.ScrollBar.ButtonColor = Color.Gray;
        chart1.ChartAreas[0].AxisX.ScrollBar.LineColor = Color.Black;                               
        chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
    }

在查看间隔时,我无意中找到了答案。 现在我已添加以下代码行,它们仍然可见。

chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Days;

暂无
暂无

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

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