2

そのため、 Xamarin.Forms の下で OxyPlotScatterSeriesを使用して作成しようとしましたが、ユーザーが操作したときにポイントを埋める必要があります。

プロット自体は問題なくレンダリングされており、インタラクション同様にレンダリングされているようです。

問題は、ポイントをクリックすると、最初は のを使用して塗りつぶされないことSelectionColorですPlotModel。キャンバスを更新するには、キャンバスをドラッグする必要があります。その後、特定のポイントが更新され、SelectionColor.

PlotModel私はそのようにインスタンス化します:

var model = new PlotModel()
{  
    SelectionColor = OxyColors.Red,
    // ...
};

以降、 my をインスタンス化しますScatterSeries

var scatterSeries = new ScatterSeries()
{
    SelectionMode = SelectionMode.Single,
    // ...
};

次にListofを作成します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れる前にキャンバスをドラッグする必要があります。

何か案は?

4

0 に答える 0