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

plotlyjs-finance

v0.0.2

Published

plotly.js finance chart wrapper

Downloads

9

Readme

plotlyjs-finance

A plotly.js finance chart wrapper

Available chart types

  • Open-high-low-close (OHLC) charts
  • Candlestick charts

Installation

npm install plotlyjs-finance

Examples

HTML page (more info on the plotlyjs homepage):

<!DOCTYPE html>
<head>
    <!-- D3.js -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    <!-- Plotly.js -->
    <script src="https://d14fo0winaifog.cloudfront.net/plotly-basic.js"></script>
    <!-- PlotlyFinance -->
    <script src="https://cdn.rawgit.com/etpinard/plotlyjs-finance/master/plotlyjs-finance.js"></script>
</head>
<body>

<div id="myDiv" style="width: 700px; height: 500px"></div>

<script>
var fig = PlotlyFinance.createOHLC(  // or PlotlyFinance.createCandlestick
    {
        open: [33.01, 33.31, 33.50, 32.06, 34.12, 33.05, 33.31, 33.50],
        high: [34.20, 34.37, 33.62, 34.25, 35.18, 33.25, 35.37, 34.62],
        low: [31.70, 30.75, 32.87, 31.62, 30.81, 32.75, 32.75, 32.87],
        close: [34.10, 31.93, 33.37, 33.18, 31.18, 33.10, 32.93, 33.70],
        dates: [
            [2013,3,4], [2013,6,5], [2013,9,6], [2013,12,4],
            [2014,3,5], [2014,6,6], [2014,9,4], [2014,12,5]
        ].map(function(d) { return new Date(d[0], d[1]-1, d[2]); })
    }
);

Plotly.plot('myDiv', fig.data, fig.layout);
</script>
</body>
</html>

Node.js script (more info on plotly-nodejs api homepage):

var PlotlyFinance = require('plotlyjs-finance');
var plotly = require('plotly')('username', 'apikey');

var fig = PlotlyFinance.createOHLC(  // or PlotlyFinance.createCandlestick
    {
        open: [33.01, 33.31, 33.50, 32.06, 34.12, 33.05, 33.31, 33.50],
        high: [34.20, 34.37, 33.62, 34.25, 35.18, 33.25, 35.37, 34.62],
        low: [31.70, 30.75, 32.87, 31.62, 30.81, 32.75, 32.75, 32.87],
        close: [34.10, 31.93, 33.37, 33.18, 31.18, 33.10, 32.93, 33.70],
        dates: [
            [2013,3,4], [2013,6,5], [2013,9,6], [2013,12,4],
            [2014,3,5], [2014,6,6], [2014,9,4], [2014,12,5]
        ].map(function(d) { return new Date(d[0], d[1]-1, d[2]); })
    }
);

var graphOptions = {
    filename: 'ohlc-first',
    fileopt: 'overwrite',
    layout: fig.layout
};

plotly.plot(fig.data, graphOptions, function(err, msg) {
    console.log(msg);
});

more in examples/

API

PlotlyFinance.createOHLC and PlotlyFinance.createCandlestick take the same arguments: a data object and an opts object.

  • data is an object with required keys open, high, low and close linked to numerical arrays. Optionally dates can be linked to an array of dates

  • opts is an object of plotlyjs trace options and/or a direction key set to 'both' (the default), 'increasing' or 'decreasing'