npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

candlestickcharts

v1.0.0

Published

Create static candlestick charts using HTML Canvas from JSON data.

Downloads

4

Readme

Create candlestick charts using HTML Canvas

This open source package will seek to solve only one problem - creating static candlestick charts in an app from a source of data that will plot using HTML Canvas and a sprinkle of JavaScript.

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.

Data Source

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.

Get Started

  1. Install the npm package: npm install candlestickcharts

  2. 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.getElementById("stockChart");

// 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.
myCanvas.width = 700;
myCanvas.height = 350;

// 3. Create an object with your specified options. Here's a sample object with the chart options:
const msftDaily = {
  canvas: myCanvas,
  padding: 10,
  gridScale: 5,
  gridColor: "#DBDBDB",
  bullColor: "#3D92FA",
  bearColor: "#FB6C64",
  data: json
};

// 4. Instantiate a new chart.
let myChart = new Candlesticks(msftDaily);

// 5. Draw your chart!
myChart.draw();