Skip to main content
100%

column-render

✓ Published0🌍 Public
11wheel
Last edited Oct 20, 2019
Created on Oct 10, 2019

This example compares two canvas-based techniques for rendering line charts with large datasets. It draws a time series of system metrics (CPU idle percentage, memory usage) using both chained `lineTo` commands and a column-oriented approach that groups points by their x-coordinate. The column method renders up to three times faster with a million points and provides better control over anti-aliasing blur. The code uses D3.js for data loading and scaling, and Canvas API methods like `ctx.lineTo`, `ctx.moveTo`, and `ctx.clearRect`. Clicking either chart re-renders it and displays the elapsed time.

AI-generated description

Two ways of drawing a line chart with lots of points:

  • chained lineTo commands
  • grouping points by the x position

Rendering points in a column is about twice as fast with 40k points and three times as fast with a million points. It also gives better control over the anti aliasing blur.

On macOS chrome, the lineTo version also has a rendering bug. The min y value is 0, but points are drawn far above the top grid line.

context

somewhat related research

Similar vizzes