3D candlesticks
Candlesticks as boxes, as deep as their volume. Good for prices and volumes of a few weeks, in one picture.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
import 'nervure/3d';
const spec = {
type: 'candles3d',
data: [
{ label: '1 Jan', open: 121, close: 119.7, high: 121.8, low: 117.7, volume: 391 },
{ label: '2 Jan', open: 119.7, close: 114.4, high: 122.2, low: 112.2, volume: 536 },
{ label: '3 Jan', open: 114.4, close: 110.8, high: 115.4, low: 109.8, volume: 1723 },
{ label: '4 Jan', open: 110.8, close: 104.2, high: 113.4, low: 104, volume: 860 },
{ label: '5 Jan', open: 104.2, close: 100.6, high: 105.3, low: 97.6, volume: 225 },
{ label: '6 Jan', open: 100.6, close: 99.9, high: 103, low: 98, volume: 1525 },
{ label: '7 Jan', open: 99.9, close: 95.6, high: 101.6, low: 93.4, volume: 1602 },
{ label: '8 Jan', open: 95.6, close: 91.8, high: 97.9, low: 90.3, volume: 290 },
{ label: '9 Jan', open: 91.8, close: 95.9, high: 97.2, low: 89.9, volume: 1728 },
{ label: '10 Jan', open: 95.9, close: 101.7, high: 103.2, low: 95.2, volume: 1381 },
{ label: '11 Jan', open: 101.7, close: 100.3, high: 103.7, low: 98.1, volume: 721 },
{ label: '12 Jan', open: 100.3, close: 108.1, high: 109.6, low: 99.2, volume: 578 },
{ label: '13 Jan', open: 108.1, close: 101.5, high: 109.3, low: 101.2, volume: 771 },
{ label: '14 Jan', open: 101.5, close: 105, high: 107.3, low: 99.5, volume: 1378 },
{ label: '15 Jan', open: 105, close: 99.5, high: 106, low: 97.1, volume: 1408 },
{ label: '16 Jan', open: 99.5, close: 102.5, high: 105.9, low: 97.8, volume: 1553 },
{ label: '17 Jan', open: 102.5, close: 104.5, high: 107, low: 99.2, volume: 715 },
{ label: '18 Jan', open: 104.5, close: 102.2, high: 108.4, low: 100.8, volume: 1429 },
{ label: '19 Jan', open: 102.2, close: 104.9, high: 108.4, low: 101.5, volume: 372 },
{ label: '20 Jan', open: 104.9, close: 110.7, high: 113.1, low: 101, volume: 1453 },
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type candles3d takes:
/** Candlesticks as boxes, as deep as their volume. */
interface Candles3DSpec extends Base3D {
type: 'candles3d';
data: { label: string; open: number; high: number; low: number; close: number; volume?: number }[];
up?: string;
down?: string;
}
interface Base3D extends Base {
/** Where the eye stands, in degrees: `azimuth` turns around the vertical axis, `elevation` rises from the floor (0) to straight above (90). */
view?: { azimuth?: number; elevation?: number };
/** Drag the chart, or focus its turn button and use the arrow keys, to turn the view. Home on the button goes back to `view`. */
rotate?: boolean;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More