Bar Chart 3D

Bars on a floor, one row per entry and one per series.

JanFebMarAprMayJunJanFebMarAprMayJunJanFebMarAprMayJunJanFebMarAprMayJun050100150200250300350Visitors050100150200250300350Visitors050100150200250300350Visitors050100150200250300350VisitorsDesktopMobileDesktopMobileDesktopMobileDesktopMobile
Desktop
Mobile

Stacks

Keys of the same name in stack stand on one another in one row along z, in the order of keys - those above 0 upward from the floor, those below 0 downward from it - and the axis names the row by its stack. Here the browsers stack as Web and the apps as App, so the depth still sets the two side by side (ADR-0016). A bar says its own value on hover; the tooltip of the demo adds the total of its stack. A bar that comes grows where it stands in its stack and lifts the bars over it.

One stack of every key leaves nothing on z: that is a 2D stacked bar chart, and a 2D chart draws it better. For stacks of 100 %, normalise the data first, with a map over the entries.

JanFebMarAprMayJunJanFebMarAprMayJunJanFebMarAprMayJunJanFebMarAprMayJun0100200300400500600Visitors0100200300400500600Visitors0100200300400500600Visitors0100200300400500600VisitorsWebAppWebAppWebAppWebApp
Chrome
Safari
iOS
Android

Installation

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

Update

Press Update: the chart glides into the new data over the animationDuration of its container, and the y axis scales along.

JanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJune050100150200250300350Sessions050100150200250300350Sessions050100150200250300350Sessions050100150200250300350SessionsDesktopMobileDesktopMobileDesktopMobileDesktopMobile

Enter and leave

New data may also bring, drop and reorder whole rows - a bar follows the name of its entry, in the index field. An added month grows out of the floor and fades in while the row axis makes room, its line growing to the new tick, its label fading in; a removed one shrinks back into the floor and fades out, the mirror of its entering, while the rows around it glide to their new cells and the axis closes the gap (see Enter in the glossary).

JanuaryFebruaryMarchAprilJanuaryFebruaryMarchAprilJanuaryFebruaryMarchAprilJanuaryFebruaryMarchApril050100150200250300350Sessions050100150200250300350Sessions050100150200250300350Sessions050100150200250300350SessionsDesktopMobileDesktopMobileDesktopMobileDesktopMobile

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.

JanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJune050100150200250300350Visitors050100150200250300350Visitors050100150200250300350Visitors050100150200250300350VisitorsDesktopMobileDesktopMobileDesktopMobileDesktopMobile
SVG
JanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJuneJanuaryFebruaryMarchAprilMayJune050100150200250300350Visitors050100150200250300350Visitors050100150200250300350Visitors050100150200250300350VisitorsDesktopMobileDesktopMobileDesktopMobileDesktopMobile
Canvas

Many marks

Three 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.

135791113151719135791113151719135791113151719135791113151719050100150200050100150200050100150200050100150200Series 1Series 2Series 3Series 4Series 5Series 6Series 7Series 8Series 9Series 10Series 11Series 12Series 13Series 14Series 15Series 1Series 2Series 3Series 4Series 5Series 6Series 7Series 8Series 9Series 10Series 11Series 12Series 13Series 14Series 15Series 1Series 2Series 3Series 4Series 5Series 6Series 7Series 8Series 9Series 10Series 11Series 12Series 13Series 14Series 15Series 1Series 2Series 3Series 4Series 5Series 6Series 7Series 8Series 9Series 10Series 11Series 12Series 13Series 14Series 15

API Reference

Prop

Type

Edit on GitHub

On this page