问题
I'm using OxyPlot to draw a huge amount of data in a StairStepSeries. The performance is good, but very bad if I'm activating Markers. Therefore I would like to implement a check: Markers can only be activated if a certain number of visible points are not exceeded.
Is it possible to get only the number of visibile points? I found no solution. I get only the total number of points of a chart.
回答1:
I haven't tested this myself.
public int GetNumberOfVisiblePointsOnScreen(StairStepSeries stairStepSeries)
{
int numberOfVisiblePointsOnScreen = 0;
foreach (DataPoint point in stairStepSeries.Points) {
if (stairStepSeries.GetScreenRectangle ().Contains (stairStepSeries.Transform (point)))
numberOfVisiblePointsOnScreen++;
}
return numberOfVisiblePointsOnScreen;
}
GetScreenRectangle() method will give the Rectangle the series currently uses on the screen. Loop through all the DataPoints inside your StairStepSeries and check if it is in the Current screen rectangle.
来源:https://stackoverflow.com/questions/41185544/oxyplot-get-visible-points