在单击滚动条之前,不会显示图表系列

问题描述 投票:0回答:1

这是我的C#程序中图表的init方法。

private void initGraph()
{  
    chartTrend.Cursor = Cursors.Hand;
    chartTrend.ChartAreas[0].CursorX.LineColor = Color.Red;
    chartTrend.ChartAreas[0].CursorX.LineWidth = 2;
    chartTrend.ChartAreas[0].CursorX.LineDashStyle = ChartDashStyle.Dot;            
    chartTrend.ChartAreas[0].CursorX.IsUserEnabled = true;

    // let us select a portion of chart so then zoom that portion
    chartTrend.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
    chartTrend.ChartAreas[0].CursorX.Interval =1 ;
    chartTrend.ChartAreas[0].CursorX.IntervalType = DateTimeIntervalType.Seconds;

    chartTrend.ChartAreas[0].CursorX.AutoScroll = false;
    chartTrend.ChartAreas[0].AxisY.IsStartedFromZero = true;
    chartTrend.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
    chartTrend.ChartAreas[0].AxisY.ScaleView.Zoomable = false;

    // disable zoom-reset button (only scrollbar's arrows are available)
    chartTrend.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
    chartTrend.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
    chartTrend.ChartAreas[0].AxisX.ScrollBar.Enabled = true;
    chartTrend.ChartAreas[0].AxisX.ScaleView.SizeType = DateTimeIntervalType.Seconds;           
    chartTrend.ChartAreas[0].AxisX.ScaleView.Size = 528;
}

问题是,当我向图表添加数据时,直到我点击滚动才会显示它。我甚至试图通过软件移动滚动但它没有用。我能做什么?

顺便说一句,这是initGraph()方法的最后一行。当我发表评论时,会显示数据,但是我对此并不感兴趣。

c# .net charts
1个回答
0
投票

问题是滚动的位置。我明白当我向图表添加数据时,它描绘的图表是从远离我的时间范围开始的时间开始的,并且在点击滚动之后,它将它带到了适当的时间。所以我决定在添加我的第一个点之后移动滚动,最后,这个问题解决了这个问题:

chartTrend.ChartAreas[0].AxisX.ScaleView.Position = chartTrend.ChartAreas[0].AxisX.Minimum;
© www.soinside.com 2019 - 2024. All rights reserved.