Class PixelDecimator

java.lang.Object
com.arbergashi.charts.internal.PixelDecimator

public final class PixelDecimator extends Object
Algorithm for data reduction for display purposes.

With very large datasets (e.g., 1 million points), it is inefficient to draw lines for every point when the screen is only 2000 pixels wide. The decimator reduces the data to min/max values per pixel column.

Since:
2025-06-01
Version:
1.0.0
Author:
Arber Gashi
  • Method Details

    • decimate

      public static int decimate(double[] xIn, double[] yIn, int count, PlotContext context, double[] outX, double[] outY)
      Reduces the input data to approx. 2 points per pixel column (Min and Max).
      Parameters:
      xIn - Input X
      yIn - Input Y
      count - Number of points
      context - PlotContext (for width)
      outX - Output buffer (must be large enough, e.g., 4 * width)
      outY - Output buffer
      Returns:
      Number of points in the output buffer