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

stacked-area

v1.6.3

Published

Draw SVG Stacked Area Charts

Downloads

26

Readme

Table of Contents

StackedArea

Draw SVG Stacked Area Charts.

Install in your Node project with

and use it inside your code via

or, alternatively

Create the new stackedArea objects via

Parameters

  • settings Object The configuration object for the diagram. All data for the diagram is provided with this object. In this configuration object, whenever a date is to be given, it can be an ISO 8601 String or a JavaScript Date object. A Moment object is also fine.
    • settings.title String? The title for the diagram.
    • settings.legendTitle String? The title for the legend.
    • settings.svg Object The DOM tree element, wich must be an svg tag. The diagram will be attached to this DOM tree element. Example:settings.svg = document.getElementById('stackedAreaDiagram');'stackedAreaDiagram' is the id of a svg tag.
    • settings.width Number? The width of the diagram in pixels, the margin settings have to be included in that width.
    • settings.height Number? The height of the diagram in pixels, the margin settings have to be included in that height.
    • settings.margin {top: Number, right: Number, bottom: Number, right: Number}? The margin for the diagram. Default values are:settings.margin = { top: 50, right: 50, bottom: 50, left: 50 }
    • settings.fromDate (String | Date)? The start date for the diagram. Example:settings.fromDate = '2018-09-01';
    • settings.toDate (String | Date)? The end date for the diagram. Example:settings.toDate = '2018-09-05';
    • settings.markers Array<{date: (String | Date), label: String}>? Highlight specific dates inside of the diagram with markers. Each marker is an object with a date for the marker and an optional label. Example:settings.markers = [ { date: '2018-09-03', label: 'M1' }, { date: '2018-09-10', label: 'M2' }];
    • settings.drawOptions Array<String>? An array to determine the parts to be drawn. Possible options:'title' - draw the title 'axis' - draw the x and y axis 'legend' - draw the legend information 'markers' - draw the markers 'focus' - draw detailed data when hovering the diagram By default all of these draw options are on.
    • settings.style Object? Influence the appearance of the diagram with typeface and colors. The defaults are:settings.style = { fontSize: 12, fontFamily: 'sans-serif', color: '#222', backgroundColor: '#fff', axis: {color: '#222'}, markers: {color: '#222', backgroundColor: '#fff'} }You may configure colors for each stacked area, like for a chart with stacked areas named 'Highest', 'High', 'Medium' and 'Low': settings.style.Highest = { color: 'chartreuse', stroke: 'white' }; settings.style.High = { color: 'cornflowerblue', stroke: 'white' }; settings.style.Medium = { color: 'darkorange', stroke: 'white' }; settings.style.Low = { color: 'firebrick', stroke: 'white' };
    • settings.data {keys: Array<String>, entries: Array<Object>} The data for the diagram. Example:settings.data = { keys: ['Low', 'Medium', 'High', 'Highest'], entries: [ { date: '2018-09-03', Highest: 0, High: 0, Medium: 0, Low: 0 }, { date: '2018-09-04', Highest: 1, High: 0, Medium: 0, Low: 0 }, { date: '2018-09-05', Highest: 1, High: 1, Medium: 0, Low: 0 }, { date: '2018-09-06', Highest: 1, High: 0, Medium: 1, Low: 1 }, { date: '2018-09-07', Highest: 2, High: 1, Medium: 0, Low: 2 }, { date: '2018-09-08', Highest: 1, High: 1, Medium: 2, Low: 2 }, { date: '2018-09-09', Highest: 0, High: 0, Medium: 1, Low: 5 }, { date: '2018-09-10', Highest: 1, High: 1, Medium: 0, Low: 5 } ]}Each entry object must contain a date and the counts for the keys. Each key will be rendered as a stacked layer. The rendering of the stacked layers will follow the order of the keys. Hereby left to right keys leads to stacked areas from bottom to top.

draw

Draw the Stacked Area Chart inside of the provided settings.svg DOM tree element.

remove

Clear the chart from the provided settings.svg DOM tree element

imageSource

Draw the Stacked Area Chart inside of the provided settings.svg DOM tree element and return the result as a string which can be assigned to the SRC attribute of an HTML IMG tag.

Returns string

svgSource

Draw the Stacked Area Chart inside of the provided settings.svg DOM tree element and return the result as a SVG tag string.

Returns string