Create candlestick charts using HTML Canvas
At the moment, it will only serve daily candlestick charts for a 100 data points (aka 100 day chart, about 5 months worth of data.) If this project picks up, or if there is enough time available, I'd like to develop additional features.
If you would like to view a working sample or play around with the code, check it out here on Codepen*: Live Preview *Please note that the preview example only uses 7 data points as a test.
This tool is currently designed for the usage of Alpha Vantage data which is currently available for free through their API. You may acquire data either in JSON or CSV. CSV data has not been tested on this tool yet, but if used with a CSV -> JSON tool, I'm sure it's possible to use it here as well.
Other forms of JSON data should work too, but will require some tweaking to the code that accesses the different key/values needed.
Install the npm package:
npm install candlestickcharts
require('candlestickcharts');to where it's needed in your project.
How to use Candlesticks.js in 5 Steps
// 1. Store your HTML Canvas element into a variable.let myCanvas = document;// 2. Determine the size of your canvas. Below sizes are what's been tested for.// Min. width can be 600. Anything smaller will be tougher to display information adequately for 100 data points.myCanvaswidth = 700;myCanvasheight = 350;// 3. Create an object with your specified options. Here's a sample object with the chart options:const msftDaily =canvas: myCanvaspadding: 10gridScale: 5gridColor: "#DBDBDB"bullColor: "#3D92FA"bearColor: "#FB6C64"data: json;// 4. Instantiate a new chart.let myChart = msftDaily;// 5. Draw your chart!myChart;