@tylix/charts
v0.4.0
Published
Hand-rolled SVG charts for Tylix: sparkline and line chart
Readme
@tylix/charts
Hand-rolled SVG charts for Tylix. No third-party dependencies.
What's included
sparkline()andlineChart()return plain geometry (paths, ticks, plot area) so a.tyxtemplate can render them with{{#each}}sparklineSvg()andlineChartSvg()return finished SVG strings- Building blocks:
linearScale,niceTicks,extent,linePath,areaPath - Gap support (
nullvalues break the line),linearandstepcurves, optional area fill, multiple series - TypeScript declarations (
index.d.ts) - Themeable colors via
--tylix-chart-1through--tylix-chart-5; sparklines inheritcurrentColor
Usage
import { sparkline, lineChart } from '@tylix/charts'
const s = sparkline([12, 18, 15, 30, 22], { width: 120, height: 32 })
// s.path, s.areaPath, s.last
const c = lineChart(
[{ name: 'CPU', data: [10, 40, 30, 80] }],
{ width: 480, height: 240, formatY: (v) => `${v}%` }
)
// c.plot, c.xTicks, c.yTicks, c.series[0].pathRun the tests with node --test.
License
MIT
