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

@chonla/blockchart

v1.1.0

Published

Draw a blockchart with html5 canvas.

Downloads

7

Readme

Block Chart JS

Block Chart JS draws block chart in HTML canvas.

Usage

npm

npm install @chonla/blockchart

cdn

https://cdn.jsdelivr.net/gh/chonla/[email protected]/dist/blockchart.min.js

HTML

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Block Chart Demo</title>
    <style>
        canvas {
            border: 1px solid #c3c3c3;
        }
    </style>
</head>

<body>
    <canvas id="myCanvas" width="800" height="500"></canvas>
    <script src="./blockchart.min.js"></script>
    <script type="text/javascript">
        window.onload = () => {
            var chart = new BlockChart('myCanvas', {
                blocks: {
                    background: {
                        style: 'preset-scale',
                        color: 'sweet-pastel'
                    },
                    shadow: {
                        style: 'custom'
                    }
                }
            });

            chart.loadData([{
                    value: 3,
                    title: 'ok'
                },
                {
                    value: 1,
                    title: 'not ok'
                },
                {
                    value: 8,
                    title: 'awesome'
                },
                {
                    value: 3,
                    title: 'so so'
                },
                {
                    value: 9,
                    title: 'so so'
                },
                {
                    value: 9,
                    title: 'so so'
                },
                {
                    value: 9,
                    title: 'so so'
                },
                {
                    value: 9,
                    title: 'so so'
                },
                {
                    value: 9,
                    title: 'so so'
                },
                {
                    value: 10,
                    title: 'wonderful'
                },
                {
                    value: 2,
                    title: 'well'
                },
                {
                    value: 3,
                    title: 'nice'
                }
            ]);
        };
    </script>
</body>

</html>

Default Configuration

{
    // style of canvas and boundary to be plotted on to
    canvas: {
        background: { // background color of canvas
            style: 'static',
            color: '#ffffff'
        }
    },
    padding: {
        top: 30, // space between canvas and top of draw area
        bottom: 50, // space between canvas and bottom of draw area
        left: 50, // space between canvas and left of draw area
        right: 50 // space between canvas and right of draw area
    },
    boundary: {
        background: { // background color of boundary
            style: 'static',
            color: '#ffffff'
        }
    },
    yAxis: {
        width: 1, // thickness of y axis
        color: '#777777' // color of y axis
    },
    xAxis: {
        width: 1, // thickness of x axis
        color: '#777777', // color of x axis
        label: {
            font: 'Arial', // font family
            size: 12, // font size in pixel
            color: '#00000', // font color
            margin: {
                top: 4
            }
        }
    },

    // style and properties of blocks to be plotted
    blocks: {
        forceSquare: true,
        scaleX: {
            scale: [ // value and label represent in each scale
                {
                    value: 1,
                    label: '1'
                },
                {
                    value: 2,
                    label: '2'
                },
                {
                    value: 3,
                    label: '3'
                },
                {
                    value: 4,
                    label: '4'
                },
                {
                    value: 5,
                    label: '5'
                },
                {
                    value: 6,
                    label: '6'
                },
                {
                    value: 7,
                    label: '7'
                },
                {
                    value: 8,
                    label: '8'
                },
                {
                    value: 9,
                    label: '9'
                },
                {
                    value: 10,
                    label: '10'
                }
            ]
        },
        space: {
            horizontal: 4, // space between each column
            vertical: 4 // space between each blocks in vertical
        },
        groupBy: 'value', // key used to group data into same column
        background: {
            style: 'custom', // custom background color. other supported color is 'scale', 'preset-scale'
            color: '#aaaaaa', // default block background color
            scaleTo: '#eacd31' // when scale style is used, color palette will be generate from color -> scaleTo color
        },
        shadow: {
            style: 'custom', // custom shadow. other supported shadow is 'none'
            color: '#aaaaaa',
            blur: 1,
            offsetX: 1,
            offsetY: 1
        },
        border: {
            style: 'line',
            width: 2,
            color: '#000000'
        }
    }
}

License

MIT