因此,我尝试在 Xamarin.Forms 下创建一个ScatterSeries
使用OxyPlot,我希望在用户与其交互时为其填充一个点。
情节本身渲染得很好,交互似乎也是如此。
问题是,一旦我单击一个点,它一开始并没有使用SelectionColor
. PlotModel
我必须拖动画布以使其更新,然后更新特定点并用SelectionColor
.
我这样实例化PlotModel
:
var model = new PlotModel()
{
SelectionColor = OxyColors.Red,
// ...
};
此后我实例化 my ScatterSeries
:
var scatterSeries = new ScatterSeries()
{
SelectionMode = SelectionMode.Single,
// ...
};
接下来我创建一个List
s 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
- 我必须在画布更新之前拖动画布。
有任何想法吗?