Gallery › Candlestick chart

Candlestick chart: Halcyon County 2031 bond price

Date, Open, High, Low and Close columns.

Halcyon County 2031 bond priceWeekly open, high, low and close, dollars per $100 of face value

Candlestick chart of 8 periods from Aug 4 to Sep 22. Blue candles closed at or above their open (5); red candles closed below it (3). It opened at 101.2 and closed at 101.9, a change of +0.7 (+0.7%). The highest high was 102.4 (Sep 8); the lowest low 100.1 (Aug 25).

  • Closed up
  • Closed down
100100.5101101.5102102.5Aug 4Aug 11Aug 18Aug 25Sep 1Sep 8Sep 15Sep 22
100100.5101101.5102102.5Aug4Aug11Aug18Aug25Sep1Sep8Sep15Sep22
Data for “Halcyon County 2031 bond price”
WeekOpenHighLowClose
Aug 4101.2101.9100.8101.6
Aug 11101.6102.1101.1101.3
Aug 18101.3101.5100.2100.4
Aug 25100.4101100.1100.9
Sep 1100.9101.8100.7101.7
Sep 8101.7102.4101.5102.2
Sep 15102.2102.3101.4101.6
Sep 22101.6102101.2101.9

Source: Halcyon County sample data (fictional, for the demo)

The spec

This is everything OSCharts needed to draw the chart above. The data is a table: named columns and rows, the way it sits in a spreadsheet.

{
  "id": "bond-price",
  "type": "candlestick",
  "title": "Halcyon County 2031 bond price",
  "subtitle": "Weekly open, high, low and close, dollars per $100 of face value",
  "source": "Halcyon County sample data (fictional, for the demo)",
  "format": {
    "maximumFractionDigits": 2
  },
  "data": {
    "columns": [
      "Week",
      "Open",
      "High",
      "Low",
      "Close"
    ],
    "rows": [
      [
        "Aug 4",
        101.2,
        101.9,
        100.8,
        101.6
      ],
      [
        "Aug 11",
        101.6,
        102.1,
        101.1,
        101.3
      ],
      [
        "Aug 18",
        101.3,
        101.5,
        100.2,
        100.4
      ],
      [
        "Aug 25",
        100.4,
        101,
        100.1,
        100.9
      ],
      [
        "Sep 1",
        100.9,
        101.8,
        100.7,
        101.7
      ],
      [
        "Sep 8",
        101.7,
        102.4,
        101.5,
        102.2
      ],
      [
        "Sep 15",
        102.2,
        102.3,
        101.4,
        101.6
      ],
      [
        "Sep 22",
        101.6,
        102,
        101.2,
        101.9
      ]
    ]
  }
}

Put it on a page

In a browser, load the two files and mount the chart:

<link rel="stylesheet" href="oscharts.css">
<script src="oscharts.js" defer></script>
<div id="chart"></div>
<script type="module">
  OSCharts.mount(document.getElementById("chart"), spec);
</script>

Or render it on a server or in a build step, so the chart is in the page before any JavaScript runs:

import { render } from "oscharts";
const html = render(spec);   // a complete, accessible <figure>

Command line: npx oscharts render spec.json > chart.html