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

horizon-timeseries-chart

v1.11.1

Published

A chart to represent time-series data using multiple vertically layered horizon area plots

Downloads

455

Readme

Horizon Time-series Chart

NPM package Build Size NPM Downloads

An interactive vertically stacked horizon chart to represent time-series data.

For more information on the Horizon visual representation method, please see d3-horizon.

NPM

Check out the examples:

Quick start

import HorizonTSChart from 'horizon-timeseries-chart';

or using a script tag

<script src="//unpkg.com/horizon-timeseries-chart"></script>

then

const myChart = new HorizonTSChart(<myDOMElement>)
  .data(<myData>);

API reference

| Method | Description | Default | |---|---|:---:| | width([px]) | Getter/setter for the chart width. | <window width> | | height([px]) | Getter/setter for the chart height. This height will be divided equally between all the vertically stacked series. | <window height> | | data([array]) | Getter/setter for the chart data, as an array of data points. The syntax of each item is defined by the series, ts and val accessor methods. | [] | | series([string or fn]) | Getter/setter for the data point accessor function to extract the series. A function receives the data point as input and should return the unique series identifier. A string indicates the object attribute to use. | | | seriesComparator([fn(a, b)]) | Getter/setter for the comparator function used to sort the series from top to bottom. The function should follow the signature function(seriesA, seriesB) and return a numeric value. | (a, b) => a.localeCompare(b) | | seriesLabelFormatter([fn(series)]) | Getter/setter for the series label formatter function, used to show labels on the left-hand side of each series. The formatter should receive a series ID, as present in the data, and return a string. | series => series | | ts([string or fn]) | Getter/setter for the data point accessor function to extract the x-axis timestamp. A function receives the data point as input and should return a number or a Date object indicating the point time. A string indicates the object attribute to use. | ts | | val([string or fn]) | Getter/setter for the data point accessor function to extract the y-axis numeric value. A function receives the data point as input and should return a number. A string indicates the object attribute to use. | val | | useUtc([boolean]) | Getter/setter for whether to consider and represent time using the local timezone (false) or in UTC (true). | false | | use24h([boolean]) | Getter/setter for whether to show time in 24h or 12h (am/pm) format. | true | | horizonBands([number]) | Getter/setter for the number of horizon bands to use. | 4 | | horizonMode(['offset' or 'mirror']) | Getter/setter for the mode used to represent negative values. offset renders the negative values from the top of the chart downwards, while mirror represents them upwards as if they were positive values, albeit with a different color. | offset | | yNormalize([boolean]) | Getter/setter for whether to normalize all series Y axis to the same extent, in order to compare series in absolute terms. It defines the behavior of the dynamic calculation of the max Y, when yExtent is not explicitly set. If true, the extent is calculated as the global maximum value of all the data points combined across all series. If false, each series extent will be based on their own local maximum. | false | | yExtent([number or fn]) | Getter/setter for the series accessor function to set the y-axis maximum absolute value. By default (undefined), the max Y is calculated dynamically from the data. A function receives the series ID as input and should return a numeric value. A number sets the same extent for all the series. | undefined | | yScaleExp([number or fn]) | Getter/setter for the series accessor function to set the y-axis scale exponent. Only values > 0 are supported. An exponent of 1 (default) represents a linear Y scale. A function receives the series ID as input and should return a numeric value. A number sets the same scale exponent for all the series. | 1 | | yAggregation([fn([numbers])]) | Getter/setter for the method to reduce multiple values to a single number, in case there is more than one y value per unique ts and series. | vals => vals.reduce((a,b) => a+b) (accumulate) | | positiveColors([[colors] or fn]) | Getter/setter for the series accessor function to set the colors to use for the positive value bands. The top band gets assigned the max color, and the other bands are colored according to the interpolation of the color stops. Minimum two colors are required. | ['white', 'midnightBlue'] | | positiveColorStops([[stopNumbers] or fn]) | Getter/setter for the series accessor function to set the stop values to use in the interpolation of the positive colors. Each stop represents an interpolation ratio and only values between ]0, 1[ (excluding) are permitted. The stops are used to interpolate the middle colors in positiveColors and are only applicable if there are more than 2 colors. If the number of stops is less than number of middle colors, linear interpolation is used to populate the remaining stops. A value of undefined (default) results in complete linear interpolation. | undefined | | negativeColors([[colors] or fn]) | Getter/setter for the series accessor function to set the colors to use for the negative value bands. The top band gets assigned the max color, and the other bands are colored according to the interpolation of the color stops. Minimum two colors are required. | ['white', 'crimson'] | | negativeColorStops([[stopNumbers] or fn]) | Getter/setter for the series accessor function to set the stop values to use in the interpolation of the negative colors. Each stop represents an interpolation ratio and only values between ]0, 1[ (excluding) are permitted. The stops are used to interpolate the middle colors in negativeColors and are only applicable if there are more than 2 colors. If the number of stops is less than number of middle colors, linear interpolation is used to populate the remaining stops. A value of undefined (default) results in complete linear interpolation. | undefined | | interpolationCurve([d3CurveFn]) | Getter/setter for the interpolation curve function used to draw lines between points. Should be a d3 curve function. A falsy value sets linear interpolation (curveLinear). | curveBasis | | showRuler([boolean]) | Getter/setter for whether to show a vertical ruler highlighting the closest time point across all series. | true | | enableZoom([boolean]) | Getter/setter for whether to enable pointer-based zoom interactions on the chart, along the time (x-axis) dimension. | false | | transitionDuration([ms]) | Getter/setter for the duration (in milliseconds) of the transitions between data states. | 250 | | tooltipContent([fn({series, ts, val, points})]) | Getter/setter for the tooltip content accessor function. Accepts plain-text or HTML. A value of null will permanently hide the tooltip. | ({ series, ts, val }) => `${series}<br>${ts}: ${val}` | | onHover([fn({x, y, points})]) | Callback function for chart hover events. Gets triggered every time the mouse moves in/out of a different point hover area. Includes the point information as single argument, with x, y and points (list of all data points associated with the corresponding x value) data. If no point is in the x proximity of the mouse pointer, a value of null is returned instead. | - | | onClick([fn({x, y, points})]) | Callback function for chart click events. Includes the currently hovered point information as single argument, with x, y and points (list of all data points associated with the corresponding x value) data. If no point is in the x proximity of the mouse pointer, a value of null is returned instead. | - |

Giving Back

paypal If this project has helped you and you'd like to contribute back, you can always buy me a ☕!