Candlestick
Prices per period: open, high, low, close.
66.7 KB of code · core 29.5 + 9 blocks 37.2
Brent crude, monthly, USD per barrel
Brent moved between $71 and $90 a barrel over the two years and ended at $82, above the $78 it started at.
How it is made: mark.candlestick takes open, high, low and close from each row. They share the y scale; green means the price rose over the month.
What the report is made of
The composer reads the JSON below and puts into the page the core and only the blocks its chart uses: 9 of the 59, 66.7 KB of code, minified, which is 31% of the 215.9 KB that the core and every block weigh together. The report file is 74.4 KB: that code, the data, the styles and the page around them.
| Block | What it does | Share of the code | KB |
|---|---|---|---|
core.composed-plain A report with plain data: no checks, no decoder. Most reports. | A report with plain data: no checks, no decoder. Most reports. | 29.5 | |
lib.pointer Where the pointer is on the chart, and following a mouse or a finger once a frame. Shared by tooltip, crosshair, zoom and brush. | Where the pointer is on the chart, and following a mouse or a finger once a frame. Shared by tooltip, crosshair, zoom and brush. | 1.7 | |
lib.ticks Round steps and ticks (1, 2 or 5 × 10ⁿ). Shared by the number scales and the histogram bins. | Round steps and ticks (1, 2 or 5 × 10ⁿ). Shared by the number scales and the histogram bins. | 0.7 | |
scale.linear Numbers to positions, with round ticks. | Numbers to positions, with round ticks. | 1.6 | |
scale.time Dates to positions, ticks in days, months or years (UTC). | Dates to positions, ticks in days, months or years (UTC). | 4.1 | |
mark.candlestick Open, high, low and close. | Open, high, low and close. | 2.4 | |
guide.axis Axes: formatted labels, a title, long categories wrapped. | Axes: formatted labels, a title, long categories wrapped. | 11.7 | |
guide.grid Grid lines at the ticks. | Grid lines at the ticks. | 0.6 | |
interaction.tooltip The values under the pointer. | The values under the pointer. | 10.7 | |
renderer.svg Draws into SVG: sharp, selectable, prints well. The default. | Draws into SVG: sharp, selectable, prints well. The default. | 3.9 | |
| Total | The core 29.5 and 9 blocks 37.2 | 66.7 |
The JSON
This is the whole input. data holds the datasets, each chart is a spec that names one.
In a checkout of the repository: node scripts/compose.js skills/blockcharts/recipes/candlestick.json report.html.
Saved as page.json, it composes the same with the skill's own runtime/compose.js.
candlestick.json
{
"title": "Candlestick",
"data": {
"brent": [
{
"month": "2024-01-01",
"open": 78,
"high": 79.5,
"low": 72,
"close": 73
},
{
"month": "2024-02-01",
"open": 73,
"high": 82.78,
"low": 71.3,
"close": 80.28
},
{
"month": "2024-03-01",
"open": 80.28,
"high": 88.37,
"low": 77.88,
"close": 84.87
},
{
"month": "2024-04-01",
"open": 84.87,
"high": 86.37,
"low": 79.14,
"close": 82.24
},
{
"month": "2024-05-01",
"open": 82.24,
"high": 84.74,
"low": 77.44,
"close": 78.44
},
{
"month": "2024-06-01",
"open": 78.44,
"high": 81.94,
"low": 73.03,
"close": 74.73
},
{
"month": "2024-07-01",
"open": 74.73,
"high": 83.72,
"low": 72.33,
"close": 82.22
},
{
"month": "2024-08-01",
"open": 82.22,
"high": 88.13,
"low": 79.12,
"close": 85.63
},
{
"month": "2024-09-01",
"open": 85.63,
"high": 89.13,
"low": 81.16,
"close": 82.16
},
{
"month": "2024-10-01",
"open": 82.16,
"high": 83.66,
"low": 77.39,
"close": 79.09
},
{
"month": "2024-11-01",
"open": 79.09,
"high": 81.59,
"low": 74.21,
"close": 76.61
},
{
"month": "2024-12-01",
"open": 76.61,
"high": 87.53,
"low": 73.51,
"close": 84.03
},
{
"month": "2025-01-01",
"open": 84.03,
"high": 87.68,
"low": 83.03,
"close": 86.18
},
{
"month": "2025-02-01",
"open": 86.18,
"high": 88.68,
"low": 80.41,
"close": 82.11
},
{
"month": "2025-03-01",
"open": 82.11,
"high": 85.61,
"low": 77.58,
"close": 79.98
},
{
"month": "2025-04-01",
"open": 79.98,
"high": 81.48,
"low": 75.51,
"close": 78.61
},
{
"month": "2025-05-01",
"open": 78.61,
"high": 88.18,
"low": 77.61,
"close": 85.68
},
{
"month": "2025-06-01",
"open": 85.68,
"high": 90.03,
"low": 83.98,
"close": 86.53
},
{
"month": "2025-07-01",
"open": 86.53,
"high": 88.03,
"low": 79.71,
"close": 82.11
},
{
"month": "2025-08-01",
"open": 82.11,
"high": 84.61,
"low": 77.99,
"close": 81.09
},
{
"month": "2025-09-01",
"open": 81.09,
"high": 84.59,
"low": 79.67,
"close": 80.67
},
{
"month": "2025-10-01",
"open": 80.67,
"high": 88.63,
"low": 78.97,
"close": 87.13
},
{
"month": "2025-11-01",
"open": 87.13,
"high": 89.63,
"low": 84.31,
"close": 86.71
},
{
"month": "2025-12-01",
"open": 86.71,
"high": 90.21,
"low": 79.12,
"close": 82.22
}
]
},
"charts": [
{
"title": "Brent crude, monthly, USD per barrel",
"note": "Brent moved between $71 and $90 a barrel over the two years and ended at $82, above the $78 it started at.",
"how": "mark.candlestick takes open, high, low and close from each row. They share the y scale; green means the price rose over the month.",
"spec": {
"data": "brent",
"size": [
720,
340
],
"padding": {
"top": 8,
"right": 8,
"bottom": 8,
"left": 8
},
"scales": {
"x": {
"type": "time",
"padding": 0.03
},
"y": {
"type": "linear"
}
},
"guides": [
{
"type": "grid",
"scale": "y"
},
{
"type": "axis",
"scale": "x",
"format": {
"month": "short",
"year": "2-digit"
}
},
{
"type": "axis",
"scale": "y"
}
],
"marks": [
{
"type": "candlestick",
"x": "month",
"open": "open",
"high": "high",
"low": "low",
"close": "close"
}
],
"interaction": [
{
"type": "tooltip",
"formats": {
"month": {
"month": "long",
"year": "numeric"
}
}
}
]
}
}
]
}
The report the composer makes from it is one standalone file (74.4 KB): open it from disk, mail it, print it.
In a page of your own
The charts above use the full kit (81.8 KB gzipped), the smallest one that has the blocks this example needs:
lib.pointer, lib.ticks, scale.linear, scale.time, mark.candlestick, guide.axis, guide.grid, interaction.tooltip, renderer.svg.
The HTML below loads it from the jsDelivr CDN, pinned to version 0.0.5; to serve it from your own site, put its file there
(the files of a release) and change the address.
HTML
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.5/release/kits/full.js"></script>
<script type="application/json" id="bc-data">
{"brent":[{"month":"2024-01-01","open":78,"high":79.5,"low":72,"close":73},{"month":"2024-02-01","open":73,"high":82.78,"low":71.3,"close":80.28},{"month":"2024-03-01","open":80.28,"high":88.37,"low":77.88,"close":84.87},{"month":"2024-04-01","open":84.87,"high":86.37,"low":79.14,"close":82.24},{"month":"2024-05-01","open":82.24,"high":84.74,"low":77.44,"close":78.44},{"month":"2024-06-01","open":78.44,"high":81.94,"low":73.03,"close":74.73},{"month":"2024-07-01","open":74.73,"high":83.72,"low":72.33,"close":82.22},{"month":"2024-08-01","open":82.22,"high":88.13,"low":79.12,"close":85.63},{"month":"2024-09-01","open":85.63,"high":89.13,"low":81.16,"close":82.16},{"month":"2024-10-01","open":82.16,"high":83.66,"low":77.39,"close":79.09},{"month":"2024-11-01","open":79.09,"high":81.59,"low":74.21,"close":76.61},{"month":"2024-12-01","open":76.61,"high":87.53,"low":73.51,"close":84.03},{"month":"2025-01-01","open":84.03,"high":87.68,"low":83.03,"close":86.18},{"month":"2025-02-01","open":86.18,"high":88.68,"low":80.41,"close":82.11},{"month":"2025-03-01","open":82.11,"high":85.61,"low":77.58,"close":79.98},{"month":"2025-04-01","open":79.98,"high":81.48,"low":75.51,"close":78.61},{"month":"2025-05-01","open":78.61,"high":88.18,"low":77.61,"close":85.68},{"month":"2025-06-01","open":85.68,"high":90.03,"low":83.98,"close":86.53},{"month":"2025-07-01","open":86.53,"high":88.03,"low":79.71,"close":82.11},{"month":"2025-08-01","open":82.11,"high":84.61,"low":77.99,"close":81.09},{"month":"2025-09-01","open":81.09,"high":84.59,"low":79.67,"close":80.67},{"month":"2025-10-01","open":80.67,"high":88.63,"low":78.97,"close":87.13},{"month":"2025-11-01","open":87.13,"high":89.63,"low":84.31,"close":86.71},{"month":"2025-12-01","open":86.71,"high":90.21,"low":79.12,"close":82.22}]}
</script>
<script type="application/json" data-bc-chart>
{
"data": "brent",
"size": [
720,
340
],
"padding": {
"top": 8,
"right": 8,
"bottom": 8,
"left": 8
},
"scales": {
"x": {
"type": "time",
"padding": 0.03
},
"y": {
"type": "linear"
}
},
"guides": [
{
"type": "grid",
"scale": "y"
},
{
"type": "axis",
"scale": "x",
"format": {
"month": "short",
"year": "2-digit"
}
},
{
"type": "axis",
"scale": "y"
}
],
"marks": [
{
"type": "candlestick",
"x": "month",
"open": "open",
"high": "high",
"low": "low",
"close": "close"
}
],
"interaction": [
{
"type": "tooltip",
"formats": {
"month": {
"month": "long",
"year": "numeric"
}
}
}
],
"alt": "Brent crude, monthly, USD per barrel"
}
</script>