Skip to main content
100%

Canvas Chart Zoom

✓ Published0🌍 Public
CColinEberhardt
Last edited May 28, 2019
Created on Mar 27, 2017

This example renders 10,000 random data points as a scatter plot on a Canvas surface, using d3fc’s `cartesianCanvasChart` and `seriesCanvasPoint` components. A d3-zoom handler enables pan and zoom interactions, re-rendering the chart on each transform by updating linear scales and invoking the chart’s render function. The code also includes SVG equivalents (`cartesianSvgChart`, `seriesSvgPoint`) to highlight the performance difference, with Canvas offering roughly 10x faster redraws.

AI-generated description

This example demonstrates the rendering of 10,000 datapoints with pan / zoom via d3-zoom. As you manipulate the chart it is being re-rendered by invoking selection.call on the top level component. Rendering the data to Canvas is approximately x10 faster than SVG in this case.

The visual d3fc components support rendering to both Canvas and SVG. In this case the cartesianCanvasChart and seriesCanvasPoint are used to render the chart. You can swap then for SVG simply by changing the to cartesianSvgChart and seriesSvgPoint.

mit Licensed

Similar vizzes