そのため、 Xamarin.Forms の下で OxyPlotScatterSeries
を使用して作成しようとしましたが、ユーザーが操作したときにポイントを埋める必要があります。
プロット自体は問題なくレンダリングされており、インタラクションも同様にレンダリングされているようです。
問題は、ポイントをクリックすると、最初は のを使用して塗りつぶされないことSelectionColor
ですPlotModel
。キャンバスを更新するには、キャンバスをドラッグする必要があります。その後、特定のポイントが更新され、SelectionColor
.
PlotModel
私はそのようにインスタンス化します:
var model = new PlotModel()
{
SelectionColor = OxyColors.Red,
// ...
};
以降、 my をインスタンス化しますScatterSeries
。
var scatterSeries = new ScatterSeries()
{
SelectionMode = SelectionMode.Single,
// ...
};
次にList
ofを作成しますScatterPoint
。
var scatterPoints = new List<ScatterPoint>
{
new ScatterPoint(0, 4),
// ...
};
TouchStarted
最後に、次のイベントをリッスンしScatterSeries
ます。
scatterSeries.TouchStarted += (sender, e) =>
{
var xCoordinate = e.Position.X;
var yCoordinate = e.Position.Y;
var screenPoint = new ScreenPoint(xCoordinate, yCoordinate);
var point = lineSeries.GetNearestPoint(screenPoint, false);
var index = (int)point.Index;
scatterSeries.SelectItem(index);
// I expect it to refresh and update the PlotModel here:
model.InvalidatePlot(true);
e.Handled = true;
};
前述のように、これは正常に機能するようですが、キャンバスがPlotModel
更新さSelectionColor
れる前にキャンバスをドラッグする必要があります。
何か案は?