簡體   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