package-trendsv0.2.1 Every option
  1. package-trends
  2. Reference
  3. Every option

Every option

The full surface. 4 entry points, and your bundler drops whatever you do not import.

Entry points

import { … } from "package-trends";          // 8.3 kB gzipped
import { … } from "package-trends/react";    // 6.8 kB
import { … } from "package-trends/compare";  // 6.9 kB
import { … } from "package-trends/heatmap";  // 3.6 kB

Core exports

ExportWhat it does
fetchDownloads(name, options)One package's range from the npm API.
fetchMany(names, fetchOne)Several at once, asking for each distinct name only once.
computeTrend(range, options)Totals, peak, trough and change from the raw series, plus the shaped values to draw.
analyse(range, options)Growth, fit and r², weekday profile, volatility, spikes, streak.
compare(ranges, options)Several ranges on one scale, absolute or indexed.
sparklineSvg(values, options)A standalone SVG string, for anywhere outside React.
toWeekly / toMonthly / toBandsBucketing.
fillGaps / applyGapsThe zero repair, on its own.
formatCount / formatChange / formatExact / formatWeekdayIntl-backed formatting.
describeTrend(trend, locale)The sentence a screen reader gets.
between(from, to)An explicit date range.

Props

PropTypeWhat it does
packagestringThe package name, scoped names included.
dataDownloadRangeA range already fetched. When set, nothing is requested.
periodPeriod | between()"last-week", "last-month", "last-year", or an explicit pair.
variant"sparkline" | "text" | "kpi"Default sparkline.
chart"line" | "column" | "band"The chart form.
curve"linear" | "smooth" | "step" | "step-before"How the line joins its points.
domain[number, number] | "auto" | "zero"The y-range the values are laid out across.
aggregate"week" | "month"Buckets whole weeks or months back from the latest day.
smoothnumberMoving-average window for the drawn line. Default 7.
gaps"fill" | "zero"What to do with the days npm has no data for. Default fill.
width / heightnumber | stringPixels, or a CSS length that scales with the text.
fluidbooleanFill the container's width rather than sit at a natural size.
mark / markColorMarkKind[] / recordPoints to call out: last, peak, trough.
axis / axisColorboolean / stringA rule at zero where zero is inside the domain.
fill / fillPatternstring / FillPatternArea or bar fill, flat or patterned.
stroke / strokeWidth / strokeDasharraystring / number / stringThe line itself.
colors{ up, down }The rise and fall figures. Unset, they inherit.
stylesrecordInline styles per part: weight, display, spacing.
numberFormat / percentFormatIntl.NumberFormatOptionsMerged over the defaults.
localestringPassed to Intl.
labelstring | (trend) => stringThe accessible name for the chart.
interactive / onActivePointboolean / fnPointer and keyboard inspection.
fallback / renderErrorReactNode / fnWhile loading, and when it fails.
svgProps / pathPropsrecordAnything else the elements should carry.
children(state) => ReactNodeReplaces the built-in markup entirely.