2017-12-30 95 views
0

私の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()方法の最後の行です。私がそれをコメントアウトすると、データが表示されますが、私が興味を持っていない方法で表示されます。

+0

あなたは[ 'chartTrend.ChartAreas [0] .RecalculateAxesScaleを()']を追加しようとすることができます(HTTPS ://msdn.microsoft.com/en-us/en-en/library/system.windows.forms.datavisualization.charting.chartarea.recalculateaxesscale(v = vs.110).aspx)。データがなければ何も表示できないことに注意してください! – TaW

+0

@TaWありがとうございますが、動作しません。私はそれを知っていて、データを追加した後でコードを追加しても、同じ結果が得られます。 – phoenix2000

答えて

0

問題はスクロールの位置でした。グラフにデータを追加すると、時間範囲の開始からはるかに離れていて、スクロールをクリックした時点からチャートが描かれていたことを理解していました。だから私は私の最初のポイントを追加した後、スクロールを移動することを決め、最終的には、この行によって解決される問題:

chartTrend.ChartAreas[0].AxisX.ScaleView.Position = chartTrend.ChartAreas[0].AxisX.Minimum; 
関連する問題