React Pixi Plot - Make interactive plots with React and WebGL
ReactPixiPlot is a Javascript library for writing PixiJS plots using React declarative style. It relies on react-pixi-fiber
to render the plot
Usage
import render from 'react-dom';import * as PIXI from 'pixi.js';import React from 'react';import countries from './countries.json';import white_circle from './white_circle.png';import scaleLinear from 'd3-scale';import extent from 'd3-array';import PixiPlot RescalingSprite DraggableContainer ZoomableContainer from 'react-pixi-plot'; PIXIloader;PIXIloader;
Components
This library provides the following components allowing for the easy creation of an interactive plot.
<PixiPlot />
;
PixiPlot
is the main component to use to render a plot. It will render a PIXI.js canvas
, using the react-pixi-fiber
Stage
component.
Children of a PixiPlot
element are rendered using react-pixi-fiber
, and thus must be components from that library, one of the components below, or a customPIXIComponent
.
PixiPlot
allows you to render axes around the plot, using d3
scales. The following props can be given to PixiPlot
:
;
<DraggableContainer />
;
A simple PIXI container that makes the viewport draggable by using the mouse right click.
<ZoomableContainer />
;
A PIXI container that makes the viewport zoomable by scrolling. If used in combination with DraggableContainer
, ZoomableContainer
should be a child of DraggableContainer
.
<SelectionContainer />
;
A container that captures mouse interactions such as selection (left click), hovering, and brushing (click and drag). During brushing operations, an optional selection overlay can be rendered.
<RescalingSprite />
;
To be used in combination with a ZoomableContainer
, this sprite always renders with the same height and width in pixels. Useful for instance for scatterplots, allowing you to get more detail values when zooming without ending up with very large sprites.
<SVGContainer />
;
A container that will reproduce the contents of an SVG HTML element with one or more PIXI.Graphics
.