同じ問題で同じ質問をした後、唯一の有効な解決策 (少なくとも私の観点では) は次のようになります。
PlotView.InvalidatePlot(true)
そうすることで、1つまたは複数を更新した後Series
、PlotView
.
リフレッシュレートは、シリーズが更新される頻度またはレートによって異なります。
コード スニペットを次に示します (Xamarin Android でも動作するはずです)。
PlotView resultsChart = FindViewById<PlotView>(Resource.Id.resultsChart);
PlotModel plotModel = new PlotModel
{
// set here main properties such as the legend, the title, etc. example :
Title = "My Awesome Real-Time Updated Chart",
TitleHorizontalAlignment = TitleHorizontalAlignment.CenteredWithinPlotArea,
LegendTitle = "I am a Legend",
LegendOrientation = LegendOrientation.Horizontal,
LegendPlacement = LegendPlacement.Inside,
LegendPosition = LegendPosition.TopRight
// there are many other properties you can set here
}
// now let's define X and Y axis for the plot model
LinearAxis xAxis = new LinearAxis();
xAxis.Position = AxisPosition.Bottom;
xAxis.Title = "Time (hours)";
LinearAxis yAxis = new LinearAxis();
yAxis.Position = AxisPosition.Left;
yAxis.Title = "Values";
plotModel.Axes.Add(xAxis);
plotModel.Axes.Add(yAxis);
// Finally let's define a LineSerie
LineSeries lineSerie = new LineSeries
{
StrokeThickness = 2,
CanTrackerInterpolatePoints = false,
Title = "Value",
Smooth = false
};
plotModel.Series.Add(lineSerie);
resultsChart.Model = plotModel;
DataPoints
に追加し、それに応じLineSerie
て自動的に更新する必要があるときはいつでも、次のようにしてください。PlotView
resultsChart.InvalidatePlot(true);
そうすることで、自動的に更新されますPlotView
。
ちなみに、 はPlotView
、タッチ、ピンチによるズーム、またはあらゆる種類の UI 関連イベントなどのイベントが発生したときにも更新されます。
お役に立てれば幸いです。私はこれに非常に長い間悩まされていました。