Bar Field Chart 3D

A field of bars over a grid of values, colored by height.

-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.510 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.51

Data

The chart draws what the data says and decides nothing of its own: data[row][column] is the value of one bar. Its row and column place it - the columns along x, the rows along z, evenly over the values domain names or at the values x and z give each of them - the smallest gap between two columns and two rows gives its footprint, its value its height from 0, and the ramp between the two colors at the lowest and the highest value its color. A value that is not a finite number draws no bar, and neither does a column or row without a finite place. The gap between two bars is fixed, a fifth of the cell, so neighbours stay apart.

Uneven spacing

Where the columns or rows were not measured at even steps, x and z name the value of each: here wells sampled at the distances they stand at and the depths they were drilled to. Every bar keeps the footprint of the smallest gap, so a wide gap stays a gap and never makes a bigger bar.

0 km2 km4 km6 km8 km10 kmdistance0 km2 km4 km6 km8 km10 kmdistance0 km2 km4 km6 km8 km10 kmdistance0 km2 km4 km6 km8 km10 kmdistance0 mg/l10 mg/l20 mg/l30 mg/l40 mg/l50 mg/l60 mg/lnitrate0 mg/l10 mg/l20 mg/l30 mg/l40 mg/l50 mg/l60 mg/lnitrate0 mg/l10 mg/l20 mg/l30 mg/l40 mg/l50 mg/l60 mg/lnitrate0 mg/l10 mg/l20 mg/l30 mg/l40 mg/l50 mg/l60 mg/lnitrate5 m10 m15 m20 m25 m30 m35 m40 mdepth5 m10 m15 m20 m25 m30 m35 m40 mdepth5 m10 m15 m20 m25 m30 m35 m40 mdepth5 m10 m15 m20 m25 m30 m35 m40 mdepth

Installation

npx shadcn@latest add niekes/chart3dcn/bar-field-chart-3d#v1.2.0

Update

Press Update: the hills move, and every bar glides to its new height over the animationDuration of the container, its color following.

-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.510 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.51

Enter and leave

The grid may grow and shrink, while every bar keeps its value. A new bar grows from the floor as it fades in, while the axes make room; a gone one shrinks back into it as it fades out, the mirror of its entering (see Enter in the glossary).

012345670123456701234567012345670 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m01234567012345670123456701234567

Renderers

The same chart on every renderer, side by side. The marks are data the chart hands to the container, and "svg" and "canvas" draw them all - where the browser has no canvas, as SVG.

-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.510 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.51
SVG
-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.510 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m0 m100 m200 m300 m400 m500 m600 m700 m-1-0.500.51-1-0.500.51-1-0.500.51-1-0.500.51
Canvas

Many marks

A 40 by 40 field, sixteen hundred bars - and the chart stays interactive. The scene is one list of marks, so the demo starts on "canvas", the renderer for many marks, and the select shows the same scene on SVG.

0102030column0102030column0102030column0102030column01002003004005006007000100200300400500600700010020030040050060070001002003004005006007000102030row0102030row0102030row0102030row

API Reference

Prop

Type

Edit on GitHub

On this page