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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@alphacharts/drawings

v0.1.1

Published

Chart drawing tools for alphacharts: 82 tools, undo/redo, magnet and templates.

Readme

@alphacharts/drawings

One chart plugin, DrawingsPlugin, owns every drawing on a chart. 82 tools.

import { createChart } from "@alphacharts/core";
import { DrawingsPlugin, ArrayBarSource, allTools } from "@alphacharts/drawings";

const source = new ArrayBarSource({ time, open, high, low, close, volume }); // columnar arrays you also pass to the series
const drawings = new DrawingsPlugin({ tools: allTools, source, interval: 60_000, magnet: "weak" });
chart.addPlugin(drawings);

drawings.setTool("trendLine");               // the user clicks/drags; Esc cancels
drawings.add({ tool: "fibRetracement", anchors: [{ time: t0, price: 120 }, { time: t1, price: 100 }] });
drawings.events.on("created", (d) => save(d));
chart.saveState();                           // includes drawings.toJSON(); restoreState() brings them back

Import named tools (import { trendLine } from "@alphacharts/drawings") and pass only those in tools to keep the rest out of the bundle; allTools is 28 KB gzip.

What is anchored to what

Every drawing is JSON: a tool id, anchors of (time, price) (never a timeline index, so prepending history or replacing data moves nothing), a style and tool props. Every number a tool prints (Δ price, %, bars, Fib level prices, Gann levels, risk/reward, quantity, VWAP, ratios) is arithmetic on the anchors and goes through the chart's price formatter. A ratio over a zero move is "n/a", a bar count without a BarSource is omitted; nothing is estimated. Invalid drawings (wrong anchor count, long position with the stop above the entry, non-finite numbers, a bar-reading tool without a source) throw with context. A tool that throws while drawing is reported once through onError and skipped; the other drawings keep drawing.

Two deliberate exceptions to "time + price": anchored text/note are positioned on the pane (props fx, fy, fractions of its size) and stay put while the chart pans; Gann square fixed is square in screen pixels.

Machinery

  • Tool API (ToolDef): anchor count, gesture (drag, clicks, single, freehand, variable-length with double-click/Enter to finish), shapes() in CSS px, validate, constrain, handlePoints. Drawing, hit-testing, box select and handles are generic over the returned Shapes.
  • Styles: color, width, dash, fill, text colour/size/bold/italic, text, extend left/right (in time terms).
  • Magnet off | weak | strong: snaps to the nearest bar's open/high/low/close (weak: within 16 px).
  • Lock, hide, visibility per chart interval (setInterval), multi-select (shift-click, shift-drag box), copy/paste (at the pointer), duplicate (5 bars later, same price), delete, z-order (front/back/forward/backward).
  • Undo/redo: every mutation is a command with an exact inverse (add remembers its index, remove its indices, patch full snapshots, reorder both orders); a drag is one step.
  • Templates and favourite tools in any core LayoutStore.
  • Keyboard: Delete/Backspace, Esc, Ctrl/Cmd+Z, +Shift+Z (or +Y), +C, +V, +D, Enter.
  • Events: created, changed, removed, selected, tool, history.
  • JSON: toJSON() / fromJSON(), schema version 1; a newer version is refused, nothing is replaced unless the whole state validates.

Tools (82)

| Family | Tools | |---|---| | lines (8) | trendLine, ray, infoLine, extendedLine, horizontalLine, horizontalRay, verticalLine, crossLine | | channels (4) | parallelChannel, regressionTrendChannel, flatTopBottom, disjointChannel | | pitchforks (5) | pitchfork, schiffPitchfork, modifiedSchiffPitchfork, insidePitchfork, pitchfan | | fibonacci (10) | fibRetracement, fibExtension (trend-based), fibChannel, fibTimeZone, fibSpeedFan, fibTrendTime, fibCircles, fibSpiral, fibSpeedArcs, fibWedge | | gann (4) | gannBox, gannSquareFixed, gannSquare, gannFan | | shapes (12) | rectangle, rotatedRectangle, ellipse, circle, triangle, arc, curve, doubleCurve, polyline, path, brush, highlighter | | annotations (14) | text, anchoredText, note, anchoredNote, callout, comment, priceLabel, priceNote, signpost, flagMark, arrow, arrowMarker, arrowMarkUp, arrowMarkDown | | position (6) | longPosition, shortPosition, forecast, projection, barsPattern, ghostFeed | | measure (3) | dateRange, priceRange, dateAndPriceRange | | patterns (6) | xabcd, cypher, abcd, trianglePattern, threeDrives, headAndShoulders | | elliott (5) | elliottImpulse, elliottCorrection, elliottTriangle, elliottDoubleCombo, elliottTripleCombo | | cycles (3) | cyclicLines, timeCycles, sineLine | | volume (2) | anchoredVwap, volumeProfile |

Definitions this library chose

Where a tool has no single canonical definition, this is what is drawn (and tested):

  • Fib retracement: level 0 at the end anchor, 1 at the start. Extension: c + (b − a)·r.
  • Pitchforks: the median always runs to the midpoint of B and C. Schiff starts it at (A.x, mid-price of A and B); modified Schiff at the midpoint of A and B; inside keeps A as the origin and puts the outer tines through the midpoints of A–B and A–C.
  • Gann fan: the n×m line has the 1×1 slope (anchor 0 → anchor 1) times n/m.
  • Position quantity: floor(accountSize · riskPercent / 100 / |entry − stop| / lot) · lot, shown only when accountSize is given. A 1e-9 relative guard keeps 0.3 / 0.1 from flooring to 2.
  • Anchored VWAP: Σ(typical·volume) / Σ(volume), typical = (H + L + C) / 3, from the bar at or before the anchor.
  • Volume profile is a bar-level approximation (a bar's volume is spread over the rows its high–low range overlaps); the tool's label says so. A bar series has no traded-at-price data.
  • Ghost feed: bars resampled (seeded, deterministic) from the bars between the first two anchors, chained from the third anchor's price. Bars pattern: those bars moved so the first close sits at the third anchor's price.
  • Bar counts are positions in the bar sequence (BarSource.logical), fractional between bars.

Not done / limits

  • Text and note content is edited with update(id, { style: { text } }); there is no in-canvas text editor, no toolbar, no settings dialog.
  • Handles exist for anchors only (a rectangle has two corner handles, not eight).
  • Straight segments on a log or percent price scale are straight in pixels between the mapped anchors; level prices are still exact arithmetic on prices.
  • The magnet and bar counts need a BarSource; the core has no public range iteration over series data, so the integrator hands one in (ArrayBarSource mirrors setData/update/prepend).