@tectra-ng/charts 0.0.0-stage → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tectra contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @tectra-ng/charts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Angular charts drawn as SVG by the components themselves — no chart library and no dependencies. They render on the server with the same markup the browser hydrates, take every colour, font and size from the tectra design tokens (themes, dark mode and `dt` just work), use the kit's legend, tooltip overlay and locale, and can be read with the keyboard and screen readers.
4
+
5
+ ```bash
6
+ npm install @tectra-ng/charts
7
+ ```
8
+
9
+ Part of `tectra-ng`. One entry point per chart, so you only bundle what you import:
10
+
11
+ | Entry point | What it holds |
12
+ |---|---|
13
+ | `@tectra-ng/charts/line` | `<tx-line-chart>` — line and area, stacked and 100%, time axis, gaps, decimation |
14
+ | `@tectra-ng/charts/column` | `<tx-column-chart>` — columns and bars, stacked, 100% and grouped, data labels, negative values |
15
+ | `@tectra-ng/charts/pie` | `<tx-pie-chart>` — pie, donut and half donut, centre total, legend with values, `txPieLegend` |
16
+ | `@tectra-ng/charts/core` | scales, ticks, formats, curves, stacks, the chart frame, axes and legend — for your own charts |
17
+
18
+ ```ts
19
+ import { TxLineChart } from '@tectra-ng/charts/line';
20
+ ```
21
+
22
+ ```html
23
+ <tx-line-chart [series]="[{ name: 'Visits', data: [120, 180, 150] }]" [categories]="['Mon', 'Tue', 'Wed']" />
24
+ ```
25
+
26
+ Peer dependencies: `@angular/core`, `@angular/common`, `@angular/cdk`, `@tectra-ng/core`, `@tectra-ng/themes`, `@tectra-ng/ui`, `@tectra-ng/icons`. Docs and examples: [tectra-ng.com](https://tectra-ng.com/components/line-chart).
@@ -0,0 +1,71 @@
1
+ # Column Chart
2
+
3
+ `<tx-column-chart>` — columns or horizontal bars for comparing values across categories: stacked, 100% stacked or grouped. Drawn as SVG by the component, rendered on the server and themed by the design tokens.
4
+
5
+ ```ts
6
+ import { TxColumnChart } from '@tectra-ng/charts/column';
7
+ ```
8
+
9
+ ```html
10
+ <tx-column-chart [series]="series" [categories]="weekdays" stackType="100%" />
11
+ ```
12
+
13
+ ## Inputs
14
+ | Name | Description |
15
+ |---|---|
16
+ | series | `{ name, data, color? }[]` — one number (or `null`) per category. An empty list shows "No data" |
17
+ | categories | Labels of the category axis, one per value |
18
+ | stacked | Stacks the series (default); `false` groups them side by side |
19
+ | stackType | `normal` or `100%` (every category to 100%; also turns stacking on) |
20
+ | height | Height in px (350), or a CSS size such as `'100%'` of a parent with a definite height |
21
+ | horizontal | Draws horizontal bars with the categories on the left |
22
+ | dataLabels | Writes each value on its bar (inside when it fits) |
23
+ | showLegend | Shows the legend; a single series never has one |
24
+ | legendPosition | `top`, `bottom`, `left` or `right` |
25
+ | legendAlign | `start`, `center` or `end` for a top or bottom legend |
26
+ | legendVariant | Look of the legend: `dot` (default), `line`, `pill` or `stat` (series totals, or the hovered column's values, in large type; it replaces the tooltip) |
27
+ | showTooltip | Shows the tooltip on hover and keyboard focus |
28
+ | tooltipMode | `shared` (every series of the category) or `single` |
29
+ | tooltipFormatter | `(value, { seriesIndex, dataPointIndex }) => string` for tooltip and data label values; default — the locale number format |
30
+ | valueFormat | Value axis format: `number`, `integer`, `compact`, `percent` or a function |
31
+ | yScale | `linear` or `log` |
32
+ | yMin | Fixed start of the value axis |
33
+ | yMax | Fixed end of the value axis |
34
+ | xAxisTitle | Title of the category axis |
35
+ | yAxisTitle | Title of the value axis |
36
+ | grid | Grid lines: `value`, `category`, `both` or `none` |
37
+ | xAxisPosition | Side of the horizontal axis: `bottom` or `top` |
38
+ | yAxisPosition | Side of the vertical axis: `left` or `right` |
39
+ | labelMode | Category labels that do not fit: `auto`, `rotate` or `skip` |
40
+ | maxLabelWidth | Longer category labels are cut with an ellipsis (220px) |
41
+ | loading | Shows a skeleton of the same size |
42
+ | ariaLabel | What the chart shows; starts the summary read by screen readers |
43
+ | dt | Design tokens of this chart (`chart`) — bar radius, width and gap, palette, labels |
44
+ | pt | Classes and styles of the parts: `root`, `legend`, `legendItem`, `plot`, `svg`, `grid`, `axis`, `bar`, `dataLabel`, `tooltip`, `empty`, `skeleton` |
45
+ | ptOptions | How `pt` merges with the global pass-through |
46
+ | unstyled | Removes the tectra styles and keeps the behaviour |
47
+
48
+ ## Outputs
49
+ | Name | Description |
50
+ |---|---|
51
+ | barClick | A bar was clicked: `seriesIndex`, `dataPointIndex`, `value`, `category` |
52
+ | seriesToggle | A legend item hid or showed a series: `seriesIndex`, `name`, `hidden` |
53
+
54
+ ## Slots
55
+ | Name | Description |
56
+ |---|---|
57
+ | txChartTooltip | `<ng-template txChartTooltip let-data>` — own tooltip content |
58
+ | txChartLegend | `<ng-template txChartLegend let-item>` — own legend item |
59
+
60
+ ## Keyboard
61
+ | Key | Action |
62
+ |---|---|
63
+ | Tab | Focuses the chart, then the legend items |
64
+ | ← / → | Previous / next category (↑ / ↓ when `horizontal`); announced, the tooltip follows |
65
+ | ↑ / ↓ | Previous / next series in the category (← / → when `horizontal`) |
66
+ | Home / End | First / last category |
67
+ | Escape | Closes the tooltip |
68
+
69
+ ## Notes
70
+
71
+ Hovering a column (not the empty space around it) highlights it, fades the others and pins the tooltip above it with an arrow; a stack also shows its total. Only the outer end of a stack is rounded and the segments are split by a thin card-coloured gap. Bars grow from the zero line once when the chart appears and slide to new values on change; both are off with reduced motion. The bar width, the gap between grouped bars and the radius come from the `chart.bar` tokens.
package/core/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Charts core
2
+
3
+ `@tectra-ng/charts/core` — the shared core of every tectra chart: pure functions for scales, ticks, number and date formats, curves, stacks and decimation, the chart frame (size, legend, tooltip, "No data", skeleton, accessibility) and the axes. The charts use it; you can build your own chart on it too.
4
+
5
+ ```ts
6
+ import { linearScale, niceDomain, chartNumberFormatter, TxChartSeries } from '@tectra-ng/charts/core';
7
+ ```
8
+
9
+ ## Scales and ticks
10
+
11
+ | Function | What it does |
12
+ |---|---|
13
+ | `linearScale(domain, range)` | Maps numbers to pixels: `map`, `invert`, `ticks(count)` |
14
+ | `logScale(domain, range)` | Logarithmic scale; ticks are powers of ten (and 2 / 5 between them when there is room) |
15
+ | `timeScale(domain, range)` | Time in ms; `ticks(count)` and `interval(count)` pick calendar steps — seconds, minutes, hours, days, weeks, months, years |
16
+ | `bandScale(count, range, paddingInner?, paddingOuter?)` | Equal bands for categories: `start`, `center`, `bandwidth`, `indexAt` |
17
+ | `pointScale(count, range)` | Evenly spaced points from edge to edge: `at`, `indexAt` |
18
+ | `niceDomain(min, max, count?)` | Widens a range to round numbers (`[3, 97]` → `[0, 100]`) |
19
+ | `linearTicks(min, max, count?)`, `tickStep`, `logTicks`, `timeTicks` | Round tick values |
20
+ | `toTime(value)` | ISO string (a date-only string is local midnight), `Date` or timestamp → ms |
21
+
22
+ ## Formats
23
+
24
+ | Function | What it does |
25
+ |---|---|
26
+ | `chartNumberFormatter(intl, format)` | `number` (up to 2 decimals), `integer`, `compact` (`1.2K`), `percent` or your function → `(value) => string` |
27
+ | `tickFormatter(intl, ticks, format)` | Like the above with as many decimals as the tick step needs |
28
+ | `compactNumber(value, intl?)` | `1234567` → `1.2M` |
29
+ | `timeTickFormatter(intl, interval, span)`, `timeTooltipFormatter(intl, interval)` | Dates for ticks and tooltips through `Intl.DateTimeFormat` |
30
+ | `chartMonthNames(intl, 'long' \| 'short')` | 12 capitalised month names |
31
+ | `textWidth(text, fontSize)`, `truncateText(text, maxWidth, fontSize)` | Text width estimate that gives the same layout on the server and in the browser |
32
+
33
+ ## Shapes, stacks, data
34
+
35
+ | Function | What it does |
36
+ |---|---|
37
+ | `linePath(points, curve)`, `areaPath(top, bottom, curve)` | SVG paths; `null` points split the path; curves `smooth` (monotone), `straight`, `step` |
38
+ | `stackValues(series, 'normal' \| '100%')` | `[from, to]` per value; positive and negative values stack apart |
39
+ | `largestTriangleThreeBuckets(points, threshold)`, `decimateSeries(points, threshold)` | Thin long series and keep their shape |
40
+ | `normalizeSeries(series, categories, xType)` | Turns `TxChartSeries[]` into labels, x values and a value table |
41
+ | `cartesianLayout(options)` | Plot area, value and category scales, tick labels (skipped or rotated when they collide), grid and zero line |
42
+ | `chartColor(index)`, `chartPalette(count?)`, `seriesColor(color, index)` | The series palette as `var(--tx-chart-series-colorN)` |
43
+
44
+ ## Components
45
+
46
+ | Name | What it is |
47
+ |---|---|
48
+ | `TxChartFrame` (`tx-chart-frame`) | The box of a chart: measures itself after hydration, places the legend, shows the tooltip on the kit overlay (pinned to the data with an arrow, on the side the data gives), "No data", the skeleton, the summary and the hidden data table, and forwards pointer and arrow-key events |
49
+ | `TxChartAxes` (`g[tx-chart-axes]`) | Grid, zero line, tick labels and titles from `cartesianLayout().axes` |
50
+ | `TxChartLegend` (`tx-chart-legend`) | Legend items that toggle series; arrow keys move between them; variants `dot`, `line`, `pill` and `stat` (a value in large type) |
51
+ | `TxChartTooltipTemplate` (`ng-template[txChartTooltip]`) | Own tooltip content in any chart |
52
+ | `TxChartLegendTemplate` (`ng-template[txChartLegend]`) | Own legend item in any chart |
53
+
54
+ ## Types
55
+
56
+ `TxChartSeries` (`name`, `data` — numbers or `{ x, y }` points, `color?`), `TxChartValueFormat`, `TxChartTooltipFormatter` (`(value, { seriesIndex, dataPointIndex }) => string`), `TxChartLegendItem`, `TxChartTooltipData`, `TxChartLegendPosition`, `TxChartHeight`.
57
+
58
+ ## Notes
59
+
60
+ Texts ("No data", the summary, the data table, announcements) come from the kit locale (`chartNoData`, `chartSummary`, …) and numbers and dates from `Intl` with the locale's `intl` code. The tokens are the `chart` group of `@tectra-ng/themes`.