ngx-mira-charts 0.1.0 â 0.2.0-dev.2
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/README.md +53 -56
- package/fesm2022/ngx-mira-charts.mjs +799 -91
- package/fesm2022/ngx-mira-charts.mjs.map +1 -1
- package/index.d.ts +472 -73
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
# ngx-mira-charts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/ngx-mira-charts) [](https://github.com/dhutaryan/ngx-mira-charts/blob/main/LICENSE) [](https://dhutaryan.github.io/ngx-mira-charts/)
|
|
4
4
|
|
|
5
|
-
A chart is
|
|
5
|
+
Composable SVG charts for Angular, built on signals. A chart is put together in your template, from parts: the axes, the grid, the cursor, the tooltip, the legend, and a `<mira-line>` or a `<mira-bar>` for each series. Each part takes its settings as inputs, so there's no options object to fill in.
|
|
6
6
|
|
|
7
7
|
> Early days: the versions are 0.x, and the API may change between them.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Why this one
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
- ð§Đ **Composed in the template.** Write the parts you need and leave out the rest. A second `<mira-bar>` makes grouped bars, with nothing to set on the chart.
|
|
12
|
+
- ð **Your rows, in their own shape.** A chart takes an array of plain objects, and each series reads its values by `dataKey`. The values must be numbers: a string, even `'42'`, is left out.
|
|
13
|
+
- ð
°ïļ **Angular all the way down.** Standalone components with signal inputs, OnPush throughout, with zone.js or without it.
|
|
14
|
+
- ðŠķ **Small.** No d3 and no chart engine, and no runtime dependencies beyond `tslib`.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- ð Line charts: straight or smooth lines, with a dot on each value
|
|
19
|
+
- ð Bar charts: one series, or several side by side
|
|
20
|
+
- âïļ Values below zero, and gaps where a value is missing
|
|
21
|
+
- ð§ Axes, a grid and a cursor at the datum under the pointer
|
|
22
|
+
- ðŽ A tooltip with each series' value there, or a box of your own
|
|
23
|
+
- ð·ïļ A legend along any edge of the chart or anywhere on the page, which can hide or show a series on a click
|
|
24
|
+
- ð A chart fills its container and follows its size, or takes a fixed width and height
|
|
25
|
+
- ðĻ Light and dark, with the colors as CSS custom properties
|
|
26
|
+
- ðĨïļ Server rendering, at a set size until the browser can measure the chart
|
|
17
27
|
|
|
18
28
|
## Not here (yet)
|
|
19
29
|
|
|
20
|
-
Area and pie charts, stacked and horizontal bars, a
|
|
30
|
+
Area and pie charts, stacked and horizontal bars, a palette of series colors, animations and keyboard access to the data. The plan is in the [issues](https://github.com/dhutaryan/ngx-mira-charts/issues).
|
|
21
31
|
|
|
22
32
|
## Installation
|
|
23
33
|
|
|
24
|
-
```
|
|
34
|
+
```bash
|
|
25
35
|
npm install ngx-mira-charts
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
Requires **Angular 20.2** or a later 20.x (peer dependencies `@angular/core` and `@angular/common`).
|
|
29
39
|
|
|
30
40
|
## Quick start
|
|
31
41
|
|
|
@@ -36,12 +46,13 @@ import {
|
|
|
36
46
|
MiraCursor,
|
|
37
47
|
MiraLine,
|
|
38
48
|
MiraLineChart,
|
|
49
|
+
MiraTooltip,
|
|
39
50
|
MiraXAxis,
|
|
40
51
|
MiraYAxis,
|
|
41
52
|
} from 'ngx-mira-charts'
|
|
42
53
|
|
|
43
54
|
@Component({
|
|
44
|
-
selector: 'app-
|
|
55
|
+
selector: 'app-solar-chart',
|
|
45
56
|
imports: [
|
|
46
57
|
MiraLineChart,
|
|
47
58
|
MiraCartesianGrid,
|
|
@@ -49,70 +60,56 @@ import {
|
|
|
49
60
|
MiraXAxis,
|
|
50
61
|
MiraYAxis,
|
|
51
62
|
MiraLine,
|
|
63
|
+
MiraTooltip,
|
|
52
64
|
],
|
|
53
65
|
template: `
|
|
54
|
-
<mira-line-chart [data]="
|
|
66
|
+
<mira-line-chart [data]="day" ariaLabel="Solar output and usage, kW">
|
|
55
67
|
<mira-cartesian-grid strokeDasharray="3 3" />
|
|
56
68
|
<mira-cursor />
|
|
57
|
-
<mira-x-axis dataKey="
|
|
69
|
+
<mira-x-axis dataKey="hour" />
|
|
58
70
|
<mira-y-axis />
|
|
59
|
-
<mira-line
|
|
60
|
-
|
|
71
|
+
<mira-line
|
|
72
|
+
dataKey="solar"
|
|
73
|
+
name="Solar"
|
|
74
|
+
stroke="#d97706"
|
|
75
|
+
curve="monotone"
|
|
76
|
+
/>
|
|
77
|
+
<mira-line dataKey="usage" name="Usage" stroke="#3b82f6" />
|
|
78
|
+
<mira-tooltip />
|
|
61
79
|
</mira-line-chart>
|
|
62
80
|
`,
|
|
63
81
|
})
|
|
64
|
-
export class
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
{
|
|
82
|
+
export class SolarChart {
|
|
83
|
+
// What a home's solar panels make and what the home uses, in kW.
|
|
84
|
+
protected readonly day = [
|
|
85
|
+
{ hour: '08:00', solar: 1.6, usage: 1.4 },
|
|
86
|
+
{ hour: '10:00', solar: 3.2, usage: 0.8 },
|
|
87
|
+
{ hour: '12:00', solar: 4.1, usage: 1.1 },
|
|
88
|
+
{ hour: '14:00', solar: 3.6, usage: 0.9 },
|
|
89
|
+
{ hour: '16:00', solar: 2.1, usage: 1.2 },
|
|
90
|
+
{ hour: '18:00', solar: 0.6, usage: 2.3 },
|
|
69
91
|
]
|
|
70
92
|
}
|
|
71
93
|
```
|
|
72
94
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
A bar chart takes the same parts, with a `<mira-bar>` for each key (import `MiraBarChart` and `MiraBar`):
|
|
95
|
+
Parts are drawn in the order they're written, so the grid goes first and the lines over it; the tooltip is laid over the svg, wherever it's written. For a bar chart, write `<mira-bar-chart>` instead, and a `<mira-bar>` for each series, with its color as `fill` (import `MiraBarChart` and `MiraBar`):
|
|
76
96
|
|
|
77
97
|
```html
|
|
78
|
-
<mira-bar-chart [data]="
|
|
98
|
+
<mira-bar-chart [data]="day" ariaLabel="Solar output and usage, kW">
|
|
79
99
|
<mira-cartesian-grid strokeDasharray="3 3" />
|
|
80
100
|
<mira-cursor />
|
|
81
|
-
<mira-x-axis dataKey="
|
|
101
|
+
<mira-x-axis dataKey="hour" />
|
|
82
102
|
<mira-y-axis />
|
|
83
|
-
<mira-bar dataKey="
|
|
84
|
-
<mira-bar dataKey="
|
|
103
|
+
<mira-bar dataKey="solar" name="Solar" fill="#d97706" />
|
|
104
|
+
<mira-bar dataKey="usage" name="Usage" fill="#3b82f6" />
|
|
105
|
+
<mira-tooltip />
|
|
85
106
|
</mira-bar-chart>
|
|
86
107
|
```
|
|
87
108
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
## Components
|
|
91
|
-
|
|
92
|
-
| Component | Inputs |
|
|
93
|
-
| --- | --- |
|
|
94
|
-
| `<mira-line-chart>` | `data`, `width`, `height`, `margin`, `ariaLabel` |
|
|
95
|
-
| `<mira-bar-chart>` | `data`, `width`, `height`, `margin`, `ariaLabel` |
|
|
96
|
-
| `<mira-x-axis>` | `dataKey`, `height` |
|
|
97
|
-
| `<mira-y-axis>` | `width`, `tickCount` |
|
|
98
|
-
| `<mira-cartesian-grid>` | `horizontal`, `vertical`, `strokeDasharray` |
|
|
99
|
-
| `<mira-cursor>` | â |
|
|
100
|
-
| `<mira-line>` | `dataKey`, `stroke`, `curve` (`'linear'` or `'monotone'`), `dot`, `activeDot` |
|
|
101
|
-
| `<mira-bar>` | `dataKey`, `fill` |
|
|
102
|
-
|
|
103
|
-
Without `width` and `height`, the chart takes its container's size, with a height of 300px in a container that has none.
|
|
104
|
-
|
|
105
|
-
## Theming
|
|
106
|
-
|
|
107
|
-
Set these CSS custom properties anywhere above the chart:
|
|
108
|
-
|
|
109
|
-
- `--mira-axis-color`: the axes' lines and labels;
|
|
110
|
-
- `--mira-grid-color`: the grid;
|
|
111
|
-
- `--mira-cursor-color`: the cursor, a line or, in a bar chart, a band in this color at 25% opacity;
|
|
112
|
-
- `--mira-background`: what's behind the chart, for the ring around the dot under the pointer. The page's by default: set it where the chart sits on a card of another color.
|
|
109
|
+
## Documentation
|
|
113
110
|
|
|
114
|
-
|
|
111
|
+
ð **[Read the docs](https://dhutaryan.github.io/ngx-mira-charts/)**: guides, live demos and the API reference.
|
|
115
112
|
|
|
116
113
|
## License
|
|
117
114
|
|
|
118
|
-
MIT
|
|
115
|
+
[MIT](https://github.com/dhutaryan/ngx-mira-charts/blob/main/LICENSE)
|