@ember-lattice/charts 1.0.0 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @ember-lattice/charts
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f931851: `LatticeChart` has a template form (ADR 0028, FR-11). The block declares the chart:
8
+ `<c.Category @column>` gives the column of the x-axis labels, and each
9
+ `<c.Series @column @label @color>` gives one series, in template order. `@label` sets the series
10
+ name, and `@color` sets its color. The declarations render no element. `@columns` and
11
+ `@category` stay for the engine form. A chart with `@columns` and `<c.Series>`, or with
12
+ `@category` and `<c.Category>`, fails.
13
+
14
+ `ChartHarness.seriesColors()` reads the computed color of each series: the fill of a bar or an
15
+ area, and the stroke of a line.
16
+
17
+ `LatticeChart` takes `@data`: plain rows, in place of `@table`. Each declared column reads the
18
+ key of its ID. `<c.Category>` takes `@label`.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [f931851]
23
+ - Updated dependencies [f931851]
24
+ - Updated dependencies [f931851]
25
+ - @ember-lattice/ember@1.1.0
26
+ - @ember-lattice/core@1.1.0
27
+
3
28
  ## 1.0.0
4
29
 
5
30
  ### Major Changes
package/README.md CHANGED
@@ -32,26 +32,40 @@ const column = {
32
32
 
33
33
  ## LatticeChart
34
34
 
35
- `LatticeChart` draws the rows of a table with `@ember-joinery/chart`.
35
+ `LatticeChart` draws rows with `@ember-joinery/chart`: plain rows (`@data`) or the rows of a
36
+ table (`@table`). Declare the chart in its block: `<c.Category>` gives the column of the x-axis
37
+ labels, and each `<c.Series>` gives one series. The declarations render no element.
36
38
 
37
39
  ```gts
38
40
  import { LatticeChart } from '@ember-lattice/charts'
39
41
 
40
42
  <template>
41
- <LatticeChart
42
- @table={{table}}
43
- @columns={{array 'sales' 'cost'}}
44
- @type='line'
45
- @label='Sales by month'
46
- />
43
+ <LatticeChart @data={{months}} @type='bar' @label='Sales by month' as |c|>
44
+ <c.Category @column='month' @label='Month' />
45
+ <c.Series @column='sales' @label='Sales' @color='var(--chart-3)' />
46
+ <c.Series @column='cost' @label='Cost' />
47
+ </LatticeChart>
47
48
  </template>
48
49
  ```
49
50
 
50
- | Argument | Effect |
51
- | ----------- | ------------------------------------------------------------------------- |
52
- | `@table` | The table. The chart follows its current rows: sort, filter and group. |
53
- | `@columns` | The ids of the number columns. Each column is one series. |
54
- | `@type` | `line`, `area` or `bar`. |
55
- | `@label` | The caption and the SVG title. It is necessary for accessibility. |
56
- | `@category` | The column of the x-axis labels. Default: the first other visible column. |
57
- | `@rowIds` | A selected range: only these rows, in table order. |
51
+ | Declaration | Effect |
52
+ | ---------------------- | ---------------------------------------------------------------------- |
53
+ | `<c.Category @column>` | The column of the x-axis labels. Default: the first other visible one. |
54
+ | `<c.Category @label>` | The category name. Default: the column header. |
55
+ | `<c.Series @column>` | One series, in template order: the ID of a number column. |
56
+ | `<c.Series @label>` | The series name. Default: the column header. |
57
+ | `<c.Series @color>` | The series color, a CSS color. Default: `var(--chart-<n>)`. |
58
+
59
+ | Argument | Effect |
60
+ | ----------- | ----------------------------------------------------------------------- |
61
+ | `@data` | The rows. Each column reads the key of its ID. |
62
+ | `@table` | A table, in place of `@data`. The chart follows its current rows. |
63
+ | `@type` | `line`, `area` or `bar`. |
64
+ | `@label` | The caption and the SVG title. It is necessary for accessibility. |
65
+ | `@rowIds` | A selected range: only these rows, in table order. |
66
+ | `@columns` | The engine form: the ids of the series columns, in place of `c.Series`. |
67
+ | `@category` | The engine form: the x-axis column, in place of `c.Category`. |
68
+
69
+ The engine form gives `@columns` (and `@category`) in place of the declarations. The column
70
+ header names each series, and the place of the series gives its color. Do not mix the two forms
71
+ in one chart.
@@ -0,0 +1,84 @@
1
+ import Component from '@glimmer/component';
2
+ import type { TOC } from '@ember/component/template-only';
3
+ import type Owner from '@ember/owner';
4
+ import type { ComponentLike, WithBoundArgs } from '@glint/template';
5
+ import { DeclarationRegistry } from '@ember-lattice/ember';
6
+ import type { Registered } from '@ember-lattice/ember';
7
+ export interface LatticeChartSeriesSignature {
8
+ Args: {
9
+ /** The ID of a number column of the table. */
10
+ column: string;
11
+ /** The series name: the tooltip, the description and the data table. Default: the column header. */
12
+ label?: string;
13
+ /** The series color, a CSS color. Default: `var(--chart-<n>)`, from the place of the series. */
14
+ color?: string;
15
+ };
16
+ }
17
+ export interface LatticeChartCategorySignature {
18
+ Args: {
19
+ /** The ID of the column of the x-axis labels. */
20
+ column: string;
21
+ /** The name of the category: the description and the data table. Default: the column header. */
22
+ label?: string;
23
+ };
24
+ }
25
+ /** The declarations that `LatticeChart` yields. */
26
+ export interface ChartDeclarations {
27
+ /** The column of the x-axis labels. */
28
+ Category: ComponentLike<LatticeChartCategorySignature>;
29
+ /** One series. The series show in template order. */
30
+ Series: ComponentLike<LatticeChartSeriesSignature>;
31
+ }
32
+ /** A declaration in the registry of a chart. */
33
+ export interface DeclaredPart extends Registered {
34
+ readonly kind: 'category' | 'series';
35
+ readonly column: string;
36
+ readonly label: string | undefined;
37
+ readonly color: string | undefined;
38
+ }
39
+ export type ChartRegistry = DeclarationRegistry<DeclaredPart>;
40
+ export declare const chartRegistry: () => ChartRegistry;
41
+ interface Registers {
42
+ registry: ChartRegistry;
43
+ }
44
+ type SeriesArgs = LatticeChartSeriesSignature['Args'] & Registers;
45
+ type CategoryArgs = LatticeChartCategorySignature['Args'] & Registers;
46
+ export declare class SeriesDeclaration extends Component<{
47
+ Args: SeriesArgs;
48
+ }> implements DeclaredPart {
49
+ /** A comment node: the place of the declaration in the template. */
50
+ readonly marker: Comment;
51
+ readonly kind = "series";
52
+ constructor(owner: Owner, args: SeriesArgs);
53
+ willDestroy(): void;
54
+ get column(): string;
55
+ get label(): string | undefined;
56
+ get color(): string | undefined;
57
+ }
58
+ export declare class CategoryDeclaration extends Component<{
59
+ Args: CategoryArgs;
60
+ }> implements DeclaredPart {
61
+ readonly marker: Comment;
62
+ readonly kind = "category";
63
+ readonly color: undefined;
64
+ constructor(owner: Owner, args: CategoryArgs);
65
+ willDestroy(): void;
66
+ get column(): string;
67
+ get label(): string | undefined;
68
+ }
69
+ /** The declarations of the chart, curried with its registry. */
70
+ export interface DeclareParts {
71
+ Category: WithBoundArgs<typeof CategoryDeclaration, 'registry'>;
72
+ Series: WithBoundArgs<typeof SeriesDeclaration, 'registry'>;
73
+ }
74
+ /** Yields the declarations: each one adds itself to the registry. */
75
+ export declare const DeclareMode: TOC<{
76
+ Args: {
77
+ registry: ChartRegistry;
78
+ };
79
+ Blocks: {
80
+ default: [DeclareParts];
81
+ };
82
+ }>;
83
+ export {};
84
+ //# sourceMappingURL=declarations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../src/declarations.gts"],"names":[],"mappings":"AAyIA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAE1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE;QACJ,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAA;QACd,oGAAoG;QACpG,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,gGAAgG;QAChG,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE;QACJ,iDAAiD;QACjD,MAAM,EAAE,MAAM,CAAA;QACd,gGAAgG;QAChG,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;CACF;AAED,mDAAmD;AACnD,MAAM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,QAAQ,CAAC,IAAI,cAAa;IAC1B,QAAQ,CAAC,KAAK,YAAY;gBAEd,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY;IAKnC,WAAW;IAKpB,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;CAMF;AAED,gEAAgE;AAChE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,CAAC,OAAO,mBAAmB,EAAE,UAAU,CAAC,CAAA;IAC/D,MAAM,EAAE,aAAa,CAAC,OAAO,iBAAiB,EAAE,UAAU,CAAC,CAAA;CAC5D;AAED,qEAAqE;AACrE,eAAO,MAAM,WAAW,EAAE,GAAG,CAAC;IAC5B,IAAI,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAA;KAAE,CAAA;IACjC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC,YAAY,CAAC,CAAA;KAAE,CAAA;CACpC,CAMC,CAAA"}
@@ -2,6 +2,7 @@ export { AreaSparkline, BarSparkline, ColumnSparkline, LineSparkline, Sparkline,
2
2
  export type { SparklineSignature, SparklineType } from './sparkline';
3
3
  export { default as LatticeChart } from './lattice-chart';
4
4
  export type { ChartColumn, ChartRow, ChartTable, LatticeChartSignature, LatticeChartType, } from './lattice-chart';
5
+ export type { ChartDeclarations, LatticeChartCategorySignature, LatticeChartSeriesSignature, } from './declarations';
5
6
  export { RangeChart, rangeChartArgs } from './range-chart';
6
7
  export type { ChartRangeTable, RangeChartSignature } from './range-chart';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC7D,YAAY,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC9D,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC7D,YAAY,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC9D,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import Component from '@glimmer/component';
2
2
  import type { LatticeLocaleTextOverride } from '@ember-lattice/core';
3
3
  import type { ChartConfig } from '@ember-joinery/chart';
4
+ import type { ChartDeclarations } from './declarations';
4
5
  /** The parts of a `@ember-lattice/core` table that the chart reads. */
5
6
  export interface ChartColumn {
6
7
  id: string;
@@ -22,13 +23,25 @@ export interface ChartTable {
22
23
  export type LatticeChartType = 'line' | 'area' | 'bar';
23
24
  export interface LatticeChartSignature {
24
25
  Args: {
25
- table: ChartTable;
26
- /** The ids of the number columns: one series for each. */
27
- columns: ReadonlyArray<string>;
26
+ /** The rows of a table: the chart follows its sort, its filter and its groups. */
27
+ table?: ChartTable;
28
+ /**
29
+ * The template form: plain rows. Each column reads the key of its id. The row id is the `id`
30
+ * key, as text, or the index. Give `@table` or `@data`, not both.
31
+ */
32
+ data?: ReadonlyArray<object>;
33
+ /**
34
+ * The engine form: the ids of the number columns, one series for each. With no `@columns`,
35
+ * the block declares the series (`<c.Series>`).
36
+ */
37
+ columns?: ReadonlyArray<string>;
28
38
  type: LatticeChartType;
29
39
  /** The chart's name: the caption and the SVG title. */
30
40
  label: string;
31
- /** The column of the x-axis labels. Default: the first visible column not in `columns`. */
41
+ /**
42
+ * The column of the x-axis labels, or `<c.Category>`. Default: the first visible column that
43
+ * is not a series.
44
+ */
32
45
  category?: string;
33
46
  /** A selected range: only these rows, in table order. Default: all the current rows. */
34
47
  rowIds?: ReadonlyArray<string>;
@@ -37,12 +50,37 @@ export interface LatticeChartSignature {
37
50
  /** The locale of the description and the numbers. Default: the owner locale. */
38
51
  locale?: string;
39
52
  };
53
+ Blocks: {
54
+ /** The template form: `<c.Category>` and one `<c.Series>` for each series. No element. */
55
+ default: [ChartDeclarations];
56
+ };
40
57
  Element: HTMLElement;
41
58
  }
59
+ /** The name, the color and the data key of a series. */
60
+ interface SeriesInfo {
61
+ key: string;
62
+ label: string;
63
+ color: string;
64
+ }
42
65
  export default class LatticeChart extends Component<LatticeChartSignature> {
43
66
  CATEGORY: string;
44
67
  HIDDEN: import("@ember/template").TrustedHTML;
45
68
  captionId: string;
69
+ /** The template form: the declarations of the block. */
70
+ registry: import('./declarations').ChartRegistry;
71
+ /** `@table`, or with `@data`, a table of the rows. */
72
+ get table(): ChartTable;
73
+ /** With `@data`: the rows as a chart table. The columns are the keys of the first row. */
74
+ get rows(): ChartTable | undefined;
75
+ /** The declarations of one kind, in template order. */
76
+ private declared;
77
+ /** The ids of the series columns: `@columns`, or the `<c.Series>` declarations. */
78
+ get seriesIds(): ReadonlyArray<string>;
79
+ /**
80
+ * The name and the color of each series: the `@label` and the `@color` of its declaration, or
81
+ * the column header and the chart token of its place.
82
+ */
83
+ get seriesInfo(): SeriesInfo[];
46
84
  get l(): import("@ember-lattice/core").LatticeLocale;
47
85
  /** The header text of a column, or its id. */
48
86
  headerOf: (id: string) => string;
@@ -56,6 +94,7 @@ export default class LatticeChart extends Component<LatticeChartSignature> {
56
94
  values: string[];
57
95
  }[];
58
96
  get columns(): readonly ChartColumn[];
97
+ /** The column of the x-axis labels: `@category`, `<c.Category>`, or the first other column. */
59
98
  get category(): string | undefined;
60
99
  get config(): ChartConfig;
61
100
  get series(): {
@@ -66,4 +105,5 @@ export default class LatticeChart extends Component<LatticeChartSignature> {
66
105
  get isBar(): boolean;
67
106
  get isArea(): boolean;
68
107
  }
108
+ export {};
69
109
  //# sourceMappingURL=lattice-chart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lattice-chart.d.ts","sourceRoot":"","sources":["../src/lattice-chart.gts"],"names":[],"mappings":"AA0NA,OAAO,SAAS,MAAM,oBAAoB,CAAA;AAM1C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CACpC;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,IAAI;QAAE,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAA;IAChD,iBAAiB,IAAI,aAAa,CAAC,WAAW,CAAC,CAAA;IAC/C,qB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,+FAA+F;IAC/F,IAAI,QAAQ,uBAaX;IAED,IAAI,MAAM,IAAI,WAAW,CAIxB;IAED,IAAI,MAAM;;;QAET;IAED,IAAI,IAAI,8BAiBP;IAED,IAAI,KAAK,YAER;IAED,IAAI,MAAM,YAET;CAyPF"}
package/dist/index.js CHANGED
@@ -5,9 +5,14 @@ import { latticeLocale } from '@ember-lattice/core';
5
5
  import { precompileTemplate } from '@ember/template-compilation';
6
6
  import { setComponentTemplate } from '@ember/component';
7
7
  import templateOnly from '@ember/component/template-only';
8
+ import { cached } from '@glimmer/tracking';
9
+ import { assert } from '@ember/debug';
8
10
  import { guidFor } from '@ember/object/internals';
9
11
  import { htmlSafe } from '@ember/template';
10
12
  import { ChartContainer } from '@ember-joinery/chart';
13
+ import { hash } from '@ember/helper';
14
+ import { DeclarationRegistry } from '@ember-lattice/ember';
15
+ import { n } from 'decorator-transforms/runtime';
11
16
 
12
17
  // Sparklines: small SVG charts in a grid cell. They keep no state, so they are `cheap` cells
13
18
  // that can reuse row slots. Put one in `meta.lattice.cell` of a column whose value is an array
@@ -132,7 +137,82 @@ const ColumnSparkline = setComponentTemplate(precompileTemplate("<Sparkline @val
132
137
  })
133
138
  }), templateOnly());
134
139
 
140
+ // The declarations of `LatticeChart` in the template form (ADR 0028, FR-11): `<c.Category>` and
141
+ // `<c.Series>`. A declaration renders no element. The chart renders its block before its
142
+ // `figure`, and each declaration adds itself to the registry of the chart. The chart reads the
143
+ // registry after the block, as the grid reads its columns, so the first render has the series.
144
+ /** The declarations that `LatticeChart` yields. */
145
+ /** A declaration in the registry of a chart. */
146
+ const chartRegistry = () => new DeclarationRegistry();
147
+ class SeriesDeclaration extends Component {
148
+ /** A comment node: the place of the declaration in the template. */marker = document.createComment('');
149
+ kind = 'series';
150
+ constructor(owner, args) {
151
+ super(owner, args);
152
+ args.registry.add(this);
153
+ }
154
+ willDestroy() {
155
+ super.willDestroy();
156
+ this.args.registry.remove(this);
157
+ }
158
+ get column() {
159
+ return this.args.column;
160
+ }
161
+ get label() {
162
+ return this.args.label;
163
+ }
164
+ get color() {
165
+ return this.args.color;
166
+ }
167
+ static {
168
+ setComponentTemplate(precompileTemplate("{{~this.marker~}}", {
169
+ strictMode: true
170
+ }), this);
171
+ }
172
+ }
173
+ class CategoryDeclaration extends Component {
174
+ marker = document.createComment('');
175
+ kind = 'category';
176
+ color = undefined;
177
+ constructor(owner, args) {
178
+ super(owner, args);
179
+ args.registry.add(this);
180
+ }
181
+ willDestroy() {
182
+ super.willDestroy();
183
+ this.args.registry.remove(this);
184
+ }
185
+ get column() {
186
+ return this.args.column;
187
+ }
188
+ get label() {
189
+ return this.args.label;
190
+ }
191
+ static {
192
+ setComponentTemplate(precompileTemplate("{{~this.marker~}}", {
193
+ strictMode: true
194
+ }), this);
195
+ }
196
+ }
197
+ /** The declarations of the chart, curried with its registry. */
198
+
199
+ /** Yields the declarations: each one adds itself to the registry. */const DeclareMode = setComponentTemplate(precompileTemplate("{{~yield (record Category=(component CategoryDeclaration registry=@registry) Series=(component SeriesDeclaration registry=@registry))~}}", {
200
+ strictMode: true,
201
+ scope: () => ({
202
+ record: hash,
203
+ CategoryDeclaration,
204
+ SeriesDeclaration
205
+ })
206
+ }), templateOnly());
207
+
135
208
  // An integrated chart: the rows of a Lattice table, drawn by @ember-joinery/chart.
209
+ //
210
+ // Two forms give the series. The engine form gives `@columns` (and `@category`). The template
211
+ // form (ADR 0028, FR-11) declares them in the block: `<c.Category>` and one `<c.Series>` for each
212
+ // series, with its label and its color (`./declarations.gts`).
213
+ //
214
+ // The rows come from `@table` (for example the table of a grid), or from `@data`: plain rows, and
215
+ // each column reads the key of its id.
136
216
  /** The data key of the x-axis labels. A column id cannot start with `__lattice`. */const CATEGORY = '__lattice_category';
137
217
  /** The data table is for screen readers only: it is not visible. */
138
218
  const HIDDEN = htmlSafe('position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap');
@@ -140,19 +220,98 @@ class LatticeChart extends Component {
140
220
  CATEGORY = CATEGORY;
141
221
  HIDDEN = HIDDEN;
142
222
  captionId = `${guidFor(this)}-caption`;
223
+ /** The template form: the declarations of the block. */
224
+ registry = chartRegistry();
225
+ // Nothing reads the registry before the declarations block, which renders before the
226
+ // `figure`: a registration writes tracked state (ADR 0028).
227
+ /** `@table`, or with `@data`, a table of the rows. */
228
+ get table() {
229
+ const {
230
+ table,
231
+ data,
232
+ label
233
+ } = this.args;
234
+ assert(`LatticeChart "${label}": give @table or @data, not both`, !table || !data);
235
+ const rows = table ?? this.rows;
236
+ assert(`LatticeChart "${label}": give @table or @data`, rows !== undefined);
237
+ return rows;
238
+ }
239
+ /** With `@data`: the rows as a chart table. The columns are the keys of the first row. */
240
+ get rows() {
241
+ const data = this.args.data;
242
+ if (data === undefined) return undefined;
243
+ const rows = data.map((datum, index) => {
244
+ const record = datum;
245
+ const id = record['id'];
246
+ return {
247
+ id: is.string(id) || is.number(id) ? String(id) : String(index),
248
+ getValue: key => record[key]
249
+ };
250
+ });
251
+ const columns = Object.keys(data[0] ?? {}).map(id => ({
252
+ id,
253
+ columnDef: {}
254
+ }));
255
+ return {
256
+ getRowModel: () => ({
257
+ rows
258
+ }),
259
+ getAllLeafColumns: () => columns
260
+ };
261
+ }
262
+ /** The declarations of one kind, in template order. */
263
+ static {
264
+ n(this.prototype, "rows", [cached]);
265
+ }
266
+ declared(kind) {
267
+ return this.registry.items.filter(part => part.kind === kind);
268
+ }
269
+ /** The ids of the series columns: `@columns`, or the `<c.Series>` declarations. */
270
+ get seriesIds() {
271
+ const declared = this.declared('series').map(part => part.column);
272
+ const columns = this.args.columns;
273
+ if (columns !== undefined) {
274
+ assert(`LatticeChart "${this.args.label}": give @columns or <c.Series>, not both`, declared.length === 0);
275
+ return columns;
276
+ }
277
+ const twice = declared.filter((id, i) => declared.indexOf(id) !== i);
278
+ assert(`LatticeChart "${this.args.label}": two series have the column "${twice.join('", "')}"`, twice.length === 0);
279
+ return declared;
280
+ }
281
+ /**
282
+ * The name and the color of each series: the `@label` and the `@color` of its declaration, or
283
+ * the column header and the chart token of its place.
284
+ */
285
+ static {
286
+ n(this.prototype, "seriesIds", [cached]);
287
+ }
288
+ get seriesInfo() {
289
+ const parts = new Map(this.declared('series').map(part => [part.column, part]));
290
+ const declared = this.args.columns === undefined;
291
+ return this.seriesIds.map((key, i) => {
292
+ const part = declared ? parts.get(key) : undefined;
293
+ return {
294
+ key,
295
+ label: part?.label ?? this.headerOf(key),
296
+ color: part?.color ?? `var(--chart-${i % 5 + 1})`
297
+ };
298
+ });
299
+ }
143
300
  get l() {
144
301
  return latticeLocale(getOwner(this), this.args.localeText, this.args.locale);
145
302
  }
146
303
  /** The header text of a column, or its id. */
147
304
  headerOf = id => {
148
- const header = this.args.table.getAllLeafColumns().find(c => c.id === id)?.columnDef.header;
305
+ const header = this.table.getAllLeafColumns().find(c => c.id === id)?.columnDef.header;
149
306
  return is.string(header) ? header : id;
150
307
  };
151
308
  get seriesNames() {
152
- return this.args.columns.map(this.headerOf);
309
+ return this.seriesInfo.map(series => series.label);
153
310
  }
154
311
  get categoryName() {
155
312
  const category = this.category;
313
+ const label = this.declared('category')[0]?.label;
314
+ if (label !== undefined) return label;
156
315
  return category ? this.headerOf(category) : this.l.t('charts.chart.category');
157
316
  }
158
317
  /** The SVG `<desc>`: the kind, the series, the category and the number of points. */
@@ -172,31 +331,32 @@ class LatticeChart extends Component {
172
331
  const number = new Intl.NumberFormat(this.l.locale);
173
332
  return this.data.map(datum => ({
174
333
  category: String(datum[CATEGORY]),
175
- values: this.args.columns.map(id => {
334
+ values: this.seriesIds.map(id => {
176
335
  const value = datum[id];
177
336
  return is.number(value) ? number.format(value) : '';
178
337
  })
179
338
  }));
180
339
  }
181
340
  get columns() {
182
- const table = this.args.table;
341
+ const table = this.table;
183
342
  return table.getVisibleLeafColumns?.() ?? table.getAllLeafColumns();
184
343
  }
344
+ /** The column of the x-axis labels: `@category`, `<c.Category>`, or the first other column. */
185
345
  get category() {
186
- return this.args.category ?? this.columns.find(c => !this.args.columns.includes(c.id))?.id;
346
+ const declared = this.declared('category');
347
+ assert(`LatticeChart "${this.args.label}": give @category or <c.Category>, not both`, this.args.category === undefined || declared.length === 0);
348
+ assert(`LatticeChart "${this.args.label}": give one <c.Category>`, declared.length <= 1);
349
+ const series = this.seriesIds;
350
+ return this.args.category ?? declared[0]?.column ?? this.columns.find(c => !series.includes(c.id))?.id;
187
351
  }
188
352
  get config() {
189
- const headers = new Map(this.args.table.getAllLeafColumns().map(c => [c.id, c.columnDef]));
190
- return Object.fromEntries(this.args.columns.map((id, i) => {
191
- const header = headers.get(id)?.header;
192
- return [id, {
193
- label: is.string(header) ? header : id,
194
- color: `var(--chart-${i % 5 + 1})`
195
- }];
196
- }));
353
+ return Object.fromEntries(this.seriesInfo.map(series => [series.key, {
354
+ label: series.label,
355
+ color: series.color
356
+ }]));
197
357
  }
198
358
  get series() {
199
- return this.args.columns.map(key => ({
359
+ return this.seriesIds.map(key => ({
200
360
  key,
201
361
  color: `var(--color-${key})`
202
362
  }));
@@ -204,11 +364,12 @@ class LatticeChart extends Component {
204
364
  get data() {
205
365
  const ids = this.args.rowIds ? new Set(this.args.rowIds) : undefined;
206
366
  const category = this.category;
207
- return this.args.table.getRowModel().rows.filter(row => !ids || ids.has(row.id)).map(row => {
367
+ const series = this.seriesIds;
368
+ return this.table.getRowModel().rows.filter(row => !ids || ids.has(row.id)).map(row => {
208
369
  const datum = {
209
370
  [CATEGORY]: category ? String(row.getValue(category) ?? '') : row.id
210
371
  };
211
- for (const id of this.args.columns) {
372
+ for (const id of series) {
212
373
  const value = row.getValue(id);
213
374
  datum[id] = is.number(value) ? value : null;
214
375
  }
@@ -222,9 +383,10 @@ class LatticeChart extends Component {
222
383
  return this.args.type === 'area';
223
384
  }
224
385
  static {
225
- setComponentTemplate(precompileTemplate("<figure class=\"lt-chart\" aria-labelledby={{this.captionId}} ...attributes>\n <figcaption class=\"lt-chart-caption\" id={{this.captionId}}>{{@label}}</figcaption>\n <ChartContainer @config={{this.config}} as |chart|>\n {{#if this.isBar}}\n <chart.BarChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Bar @dataKey={{s.key}} @fill={{s.color}} />\n {{/each}}\n </chart.BarChart>\n {{else if this.isArea}}\n <chart.AreaChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Area @dataKey={{s.key}} @fill={{s.color}} @stroke={{s.color}} />\n {{/each}}\n </chart.AreaChart>\n {{else}}\n <chart.LineChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Line @dataKey={{s.key}} @stroke={{s.color}} />\n {{/each}}\n </chart.LineChart>\n {{/if}}\n </ChartContainer>\n <table class=\"lt-chart-data\" style={{this.HIDDEN}}>\n <caption>{{@label}}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{{this.categoryName}}</th>\n {{#each this.seriesNames as |name|}}\n <th scope=\"col\">{{name}}</th>\n {{/each}}\n </tr>\n </thead>\n <tbody>\n {{#each this.tableRows as |row|}}\n <tr>\n <th scope=\"row\">{{row.category}}</th>\n {{#each row.values as |value|}}\n <td>{{value}}</td>\n {{/each}}\n </tr>\n {{/each}}\n </tbody>\n </table>\n</figure>", {
386
+ setComponentTemplate(precompileTemplate("{{!-- The template form (ADR 0028): the declarations render first, and render no element. --}}\n{{~#if (has-block)~}}\n <DeclareMode @registry={{this.registry}} as |c|>{{yield c}}</DeclareMode>\n{{~/if~}}\n<figure class=\"lt-chart\" aria-labelledby={{this.captionId}} ...attributes>\n <figcaption class=\"lt-chart-caption\" id={{this.captionId}}>{{@label}}</figcaption>\n <ChartContainer @config={{this.config}} as |chart|>\n {{#if this.isBar}}\n <chart.BarChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Bar @dataKey={{s.key}} @fill={{s.color}} />\n {{/each}}\n </chart.BarChart>\n {{else if this.isArea}}\n <chart.AreaChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Area @dataKey={{s.key}} @fill={{s.color}} @stroke={{s.color}} />\n {{/each}}\n </chart.AreaChart>\n {{else}}\n <chart.LineChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Line @dataKey={{s.key}} @stroke={{s.color}} />\n {{/each}}\n </chart.LineChart>\n {{/if}}\n </ChartContainer>\n <table class=\"lt-chart-data\" style={{this.HIDDEN}}>\n <caption>{{@label}}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{{this.categoryName}}</th>\n {{#each this.seriesNames as |name|}}\n <th scope=\"col\">{{name}}</th>\n {{/each}}\n </tr>\n </thead>\n <tbody>\n {{#each this.tableRows as |row|}}\n <tr>\n <th scope=\"row\">{{row.category}}</th>\n {{#each row.values as |value|}}\n <td>{{value}}</td>\n {{/each}}\n </tr>\n {{/each}}\n </tbody>\n </table>\n</figure>", {
226
387
  strictMode: true,
227
388
  scope: () => ({
389
+ DeclareMode,
228
390
  ChartContainer
229
391
  })
230
392
  }), this);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/sparkline.gts","../src/lattice-chart.gts","../src/range-chart.gts"],"sourcesContent":["// Sparklines: small SVG charts in a grid cell. They keep no state, so they are `cheap` cells\n// that can reuse row slots. Put one in `meta.lattice.cell` of a column whose value is an array\n// of numbers.\nimport Component from '@glimmer/component'\nimport { getOwner } from '@ember/owner'\nimport is from '@sindresorhus/is'\nimport type { TOC } from '@ember/component/template-only'\nimport { latticeLocale } from '@ember-lattice/core'\nimport type { LatticeLocale, LatticeLocaleTextOverride } from '@ember-lattice/core'\n\nexport type SparklineType = 'line' | 'area' | 'bar' | 'column'\n\nexport interface SparklineSignature {\n Args: {\n /** An array of numbers. Other items are ignored. */\n value: unknown\n type?: SparklineType\n /** Locale text that replaces the owner text for this sparkline. */\n localeText?: LatticeLocaleTextOverride\n /** The locale of the numbers. Default: the owner locale. */\n locale?: string\n }\n Element: SVGSVGElement\n}\n\nconst W = 100\nconst H = 24\nconst PAD = 2\n\nconst numbersOf = (value: unknown): number[] =>\n is.array(value) ? value.filter((v): v is number => is.number(v) && Number.isFinite(v)) : []\n\n/**\n * The accessible name of a sparkline: the minimum, the maximum and the last value, in the locale\n * (default: the English text and the runtime locale).\n */\nexport function sparklineLabel(\n value: unknown,\n l: LatticeLocale = latticeLocale(undefined),\n): string {\n const nums = numbersOf(value)\n if (nums.length === 0) return l.t('charts.sparkline.noData')\n const number = new Intl.NumberFormat(l.locale, { maximumFractionDigits: 2 })\n const [min, max, last] = [Math.min(...nums), Math.max(...nums), nums.at(-1)!].map(n =>\n number.format(n),\n )\n return l.t('charts.sparkline.label', { min: min!, max: max!, last: last! })\n}\n\ninterface Rect {\n x: number\n y: number\n width: number\n height: number\n}\n\n/** A linear scale from [lo, hi] to [to, from], flat in the middle when lo = hi. */\nconst scale = (lo: number, hi: number, from: number, to: number) => (v: number) =>\n hi === lo ? (from + to) / 2 : from + ((hi - v) / (hi - lo)) * (to - from)\n\nexport class Sparkline extends Component<SparklineSignature> {\n get nums() {\n return numbersOf(this.args.value)\n }\n\n get type(): SparklineType {\n return this.args.type ?? 'line'\n }\n\n get label() {\n return sparklineLabel(\n this.args.value,\n latticeLocale(getOwner(this), this.args.localeText, this.args.locale),\n )\n }\n\n get isLinear() {\n return this.type === 'line' || this.type === 'area'\n }\n\n get points(): Array<[number, number]> {\n const nums = this.nums\n const y = scale(Math.min(...nums), Math.max(...nums), PAD, H - PAD)\n const step = nums.length > 1 ? (W - 2 * PAD) / (nums.length - 1) : 0\n return nums.map((v, i) => [nums.length > 1 ? PAD + i * step : W / 2, y(v)])\n }\n\n /** One value has no line: it shows as a dot. */\n get dot() {\n const [x, y] = this.points[0] ?? [0, 0]\n return this.isLinear && this.nums.length === 1 ? { x, y } : undefined\n }\n\n get linePath() {\n if (!this.isLinear || this.nums.length < 2) return undefined\n return 'M' + this.points.map(([x, y]) => `${x},${y}`).join('L')\n }\n\n get areaPath() {\n const line = this.linePath\n if (this.type !== 'area' || !line) return undefined\n const xs = this.points.map(([x]) => x)\n return `${line}L${xs.at(-1)},${H}L${xs[0]},${H}Z`\n }\n\n /** Columns go up (or down) from the zero line; bars go right (or left) from it. */\n get rects(): Rect[] {\n if (this.isLinear) return []\n const nums = this.nums\n const lo = Math.min(0, ...nums)\n const hi = Math.max(0, ...nums)\n const columns = this.type === 'column'\n const band = (columns ? W : H) / nums.length\n // For bars the value runs along x, so the scale goes from right to left.\n const at = columns ? scale(lo, hi, PAD, H - PAD) : scale(lo, hi, W - PAD, PAD)\n const zero = at(0)\n return nums.map((v, i) => {\n const start = Math.min(at(v), zero)\n const length = Math.max(Math.abs(at(v) - zero), 0.5)\n const across = i * band + band * 0.1\n return columns\n ? { x: across, y: start, width: band * 0.8, height: length }\n : { x: start, y: across, width: length, height: band * 0.8 }\n })\n }\n\n <template>\n <svg\n class='lt-sparkline lt-sparkline-{{this.type}}'\n role='img'\n aria-label={{this.label}}\n viewBox='0 0 100 24'\n preserveAspectRatio='none'\n width='100%'\n height='20'\n style='display:block;color:var(--chart-1, currentColor)'\n ...attributes\n >\n {{#if this.areaPath}}\n <path\n class='lt-sparkline-area'\n d={{this.areaPath}}\n fill='currentColor'\n fill-opacity='0.2'\n stroke='none'\n />\n {{/if}}\n {{#if this.linePath}}\n <path\n class='lt-sparkline-line'\n d={{this.linePath}}\n fill='none'\n stroke='currentColor'\n stroke-width='1.5'\n vector-effect='non-scaling-stroke'\n />\n {{/if}}\n {{#if this.dot}}\n <circle cx={{this.dot.x}} cy={{this.dot.y}} r='2' fill='currentColor' />\n {{/if}}\n {{#each this.rects as |box|}}\n <rect\n x={{box.x}}\n y={{box.y}}\n width={{box.width}}\n height={{box.height}}\n fill='currentColor'\n />\n {{/each}}\n </svg>\n </template>\n}\n\n/** The cell signature: a full cell of `LatticeGrid` gets more arguments; it reads `value`. */\ninterface CellSignature {\n Args: { value: unknown }\n Element: SVGSVGElement\n}\n\nexport const LineSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='line' ...attributes />\n</template>\n\nexport const AreaSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='area' ...attributes />\n</template>\n\nexport const BarSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='bar' ...attributes />\n</template>\n\nexport const ColumnSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='column' ...attributes />\n</template>\n","// An integrated chart: the rows of a Lattice table, drawn by @ember-joinery/chart.\nimport Component from '@glimmer/component'\nimport { getOwner } from '@ember/owner'\nimport { guidFor } from '@ember/object/internals'\nimport { htmlSafe } from '@ember/template'\nimport is from '@sindresorhus/is'\nimport { latticeLocale } from '@ember-lattice/core'\nimport type { LatticeLocaleTextOverride } from '@ember-lattice/core'\nimport { ChartContainer } from '@ember-joinery/chart'\nimport type { ChartConfig } from '@ember-joinery/chart'\n\n/** The parts of a `@ember-lattice/core` table that the chart reads. */\nexport interface ChartColumn {\n id: string\n columnDef: { header?: unknown }\n}\n\nexport interface ChartRow {\n id: string\n getValue(columnId: string): unknown\n}\n\nexport interface ChartTable {\n getRowModel(): { rows: ReadonlyArray<ChartRow> }\n getAllLeafColumns(): ReadonlyArray<ChartColumn>\n getVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n}\n\nexport type LatticeChartType = 'line' | 'area' | 'bar'\n\nexport interface LatticeChartSignature {\n Args: {\n table: ChartTable\n /** The ids of the number columns: one series for each. */\n columns: ReadonlyArray<string>\n type: LatticeChartType\n /** The chart's name: the caption and the SVG title. */\n label: string\n /** The column of the x-axis labels. Default: the first visible column not in `columns`. */\n category?: string\n /** A selected range: only these rows, in table order. Default: all the current rows. */\n rowIds?: ReadonlyArray<string>\n /** Locale text that replaces the owner text for this chart. */\n localeText?: LatticeLocaleTextOverride\n /** The locale of the description and the numbers. Default: the owner locale. */\n locale?: string\n }\n Element: HTMLElement\n}\n\n/** The data key of the x-axis labels. A column id cannot start with `__lattice`. */\nconst CATEGORY = '__lattice_category'\n\n/** The data table is for screen readers only: it is not visible. */\nconst HIDDEN = htmlSafe(\n 'position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap',\n)\n\nexport default class LatticeChart extends Component<LatticeChartSignature> {\n CATEGORY = CATEGORY\n HIDDEN = HIDDEN\n captionId = `${guidFor(this)}-caption`\n\n get l() {\n return latticeLocale(getOwner(this), this.args.localeText, this.args.locale)\n }\n\n /** The header text of a column, or its id. */\n headerOf = (id: string) => {\n const header = this.args.table.getAllLeafColumns().find(c => c.id === id)?.columnDef.header\n return is.string(header) ? header : id\n }\n\n get seriesNames(): string[] {\n return this.args.columns.map(this.headerOf)\n }\n\n get categoryName(): string {\n const category = this.category\n return category ? this.headerOf(category) : this.l.t('charts.chart.category')\n }\n\n /** The SVG `<desc>`: the kind, the series, the category and the number of points. */\n get description(): string {\n const l = this.l\n return l.t('charts.chart.description', {\n type: l.t(`charts.chart.${this.args.type}`),\n series: new Intl.ListFormat(l.locale, { type: 'conjunction' }).format(this.seriesNames),\n category: this.categoryName,\n points: l.plural('charts.chart.points', this.data.length),\n })\n }\n\n /** The rows of the data table: the category, then a text for each series. */\n get tableRows(): { category: string; values: string[] }[] {\n const number = new Intl.NumberFormat(this.l.locale)\n return this.data.map(datum => ({\n category: String(datum[CATEGORY]),\n values: this.args.columns.map(id => {\n const value = datum[id]\n return is.number(value) ? number.format(value) : ''\n }),\n }))\n }\n\n get columns() {\n const table = this.args.table\n return table.getVisibleLeafColumns?.() ?? table.getAllLeafColumns()\n }\n\n get category() {\n return this.args.category ?? this.columns.find(c => !this.args.columns.includes(c.id))?.id\n }\n\n get config(): ChartConfig {\n const headers = new Map(this.args.table.getAllLeafColumns().map(c => [c.id, c.columnDef]))\n return Object.fromEntries(\n this.args.columns.map((id, i) => {\n const header = headers.get(id)?.header\n return [\n id,\n { label: is.string(header) ? header : id, color: `var(--chart-${(i % 5) + 1})` },\n ]\n }),\n )\n }\n\n get series() {\n return this.args.columns.map(key => ({ key, color: `var(--color-${key})` }))\n }\n\n get data() {\n const ids = this.args.rowIds ? new Set(this.args.rowIds) : undefined\n const category = this.category\n return this.args.table\n .getRowModel()\n .rows.filter(row => !ids || ids.has(row.id))\n .map(row => {\n const datum: Record<string, unknown> = {\n [CATEGORY]: category ? String(row.getValue(category) ?? '') : row.id,\n }\n for (const id of this.args.columns) {\n const value = row.getValue(id)\n datum[id] = is.number(value) ? value : null\n }\n return datum\n })\n }\n\n get isBar() {\n return this.args.type === 'bar'\n }\n\n get isArea() {\n return this.args.type === 'area'\n }\n\n <template>\n <figure class='lt-chart' aria-labelledby={{this.captionId}} ...attributes>\n <figcaption class='lt-chart-caption' id={{this.captionId}}>{{@label}}</figcaption>\n <ChartContainer @config={{this.config}} as |chart|>\n {{#if this.isBar}}\n <chart.BarChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Bar @dataKey={{s.key}} @fill={{s.color}} />\n {{/each}}\n </chart.BarChart>\n {{else if this.isArea}}\n <chart.AreaChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Area @dataKey={{s.key}} @fill={{s.color}} @stroke={{s.color}} />\n {{/each}}\n </chart.AreaChart>\n {{else}}\n <chart.LineChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Line @dataKey={{s.key}} @stroke={{s.color}} />\n {{/each}}\n </chart.LineChart>\n {{/if}}\n </ChartContainer>\n <table class='lt-chart-data' style={{this.HIDDEN}}>\n <caption>{{@label}}</caption>\n <thead>\n <tr>\n <th scope='col'>{{this.categoryName}}</th>\n {{#each this.seriesNames as |name|}}\n <th scope='col'>{{name}}</th>\n {{/each}}\n </tr>\n </thead>\n <tbody>\n {{#each this.tableRows as |row|}}\n <tr>\n <th scope='row'>{{row.category}}</th>\n {{#each row.values as |value|}}\n <td>{{value}}</td>\n {{/each}}\n </tr>\n {{/each}}\n </tbody>\n </table>\n </figure>\n </template>\n}\n","// Chart a range: a chart of the selected cells of a grid. The rows of the range are the points.\n// The number columns of the range are the series, and the first other column is the x-axis.\n// An app opens it from a context menu item (the `export` block of `GridContextMenu`).\nimport Component from '@glimmer/component'\nimport is from '@sindresorhus/is'\nimport type { GridRange } from '@ember-lattice/ember'\nimport LatticeChart from './lattice-chart.gts'\nimport type { ChartColumn, ChartTable, LatticeChartType } from './lattice-chart.gts'\n\n/** A table with the parts that a range needs: the cell selection and the pinned column order. */\nexport interface ChartRangeTable extends ChartTable {\n getCellSelectionBounds?(): ReadonlyArray<GridRange>\n getStartVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n getCenterVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n getEndVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n}\n\nexport interface RangeChartArgs {\n rowIds: string[]\n columns: string[]\n category: string | undefined\n}\n\n/** The columns in the order of the grid: start pinned, center, end pinned. */\nfunction displayColumns(table: ChartRangeTable): ReadonlyArray<ChartColumn> {\n const center =\n table.getCenterVisibleLeafColumns?.() ??\n table.getVisibleLeafColumns?.() ??\n table.getAllLeafColumns()\n return [\n ...(table.getStartVisibleLeafColumns?.() ?? []),\n ...center,\n ...(table.getEndVisibleLeafColumns?.() ?? []),\n ]\n}\n\n/** The `LatticeChart` args of a range: its row IDs, its number columns and its category. */\nexport function rangeChartArgs(table: ChartRangeTable, range: GridRange): RangeChartArgs {\n const rows = table.getRowModel().rows.slice(range.minRowIndex, range.maxRowIndex + 1)\n const ids = displayColumns(table)\n .slice(range.minColumnIndex, range.maxColumnIndex + 1)\n .map(c => c.id)\n // A column is a series when its values in the range are numbers (blanks are allowed).\n const isNumber = (id: string) =>\n rows.some(r => is.number(r.getValue(id))) &&\n rows.every(r => is.number(r.getValue(id)) || is.nullOrUndefined(r.getValue(id)))\n return {\n rowIds: rows.map(r => r.id),\n columns: ids.filter(isNumber),\n category: ids.find(id => !isNumber(id)),\n }\n}\n\nexport interface RangeChartSignature {\n Args: {\n table: ChartRangeTable\n type: LatticeChartType\n label: string\n /** The range. Default: the last range of the table cell selection. */\n range?: GridRange\n }\n Element: HTMLElement\n}\n\nexport class RangeChart extends Component<RangeChartSignature> {\n get range(): GridRange | undefined {\n return this.args.range ?? this.args.table.getCellSelectionBounds?.().at(-1)\n }\n\n get chart(): RangeChartArgs | undefined {\n const range = this.range\n return range ? rangeChartArgs(this.args.table, range) : undefined\n }\n\n <template>\n {{#if this.chart}}\n <LatticeChart\n @table={{@table}}\n @columns={{this.chart.columns}}\n @rowIds={{this.chart.rowIds}}\n @category={{this.chart.category}}\n @type={{@type}}\n @label={{@label}}\n ...attributes\n />\n {{/if}}\n </template>\n}\n"],"names":["W","H","PAD","numbersOf","value","is","array","filter","v","number","Number","isFinite","sparklineLabel","l","latticeLocale","undefined","nums","length","t","Intl","NumberFormat","locale","maximumFractionDigits","min","max","last","Math","at","map","n","format","scale","lo","hi","from","to","Sparkline","Component","args","type","label","getOwner","localeText","isLinear","points","y","step","i","dot","x","linePath","join","areaPath","line","xs","rects","columns","band","zero","start","abs","across","width","height","setComponentTemplate","precompileTemplate","strictMode","LineSparkline","scope","templateOnly","AreaSparkline","BarSparkline","ColumnSparkline","CATEGORY","HIDDEN","htmlSafe","LatticeChart","captionId","guidFor","headerOf","id","header","table","getAllLeafColumns","find","c","columnDef","string","seriesNames","categoryName","category","description","series","ListFormat","plural","data","tableRows","datum","String","values","getVisibleLeafColumns","includes","config","headers","Map","Object","fromEntries","get","color","key","ids","rowIds","Set","getRowModel","rows","row","has","getValue","isBar","isArea","ChartContainer","displayColumns","center","getCenterVisibleLeafColumns","getStartVisibleLeafColumns","getEndVisibleLeafColumns","rangeChartArgs","range","slice","minRowIndex","maxRowIndex","minColumnIndex","maxColumnIndex","isNumber","some","r","every","nullOrUndefined","RangeChart","getCellSelectionBounds","chart"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AAuBA,MAAMA,CAAA,GAAI,GAAA;AACV,MAAMC,CAAA,GAAI,EAAA;AACV,MAAMC,GAAA,GAAM,CAAA;AAEZ,MAAMC,SAAA,GAAaC,KAAc,IAC/BC,EAAA,CAAGC,KAAK,CAACF,KAAA,CAAA,GAASA,KAAA,CAAMG,MAAM,CAAEC,CAAA,IAAmBH,EAAA,CAAGI,MAAM,CAACD,CAAA,CAAA,IAAME,MAAA,CAAOC,QAAQ,CAACH,CAAA,CAAA,CAAA,GAAM,EAAE;AAE7F;;;;AAIO,SAASI,cAAAA,CACdR,KAAc,EACdS,CAAG,GAAgBC,aAAA,CAAcC,SAAA,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,OAAOA,KAAA,GAAQD,eAAe,IAAI,CAACxF,IAAI,CAAC4C,KAAK,EAAE6C,KAAA,CAAA,GAAShH,SAAA;AAC1D,EAAA;AAEA,EAAA;IAAAiD,oBAAA,CAAAC,kBAAA,CAAA,mNAAA,EAYA;MAAAC,UAAA,EAAA,IAAA;AAAAE,MAAAA,KAAA,EAAAA,OAAA;AAAAQ,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/sparkline.gts","../src/declarations.gts","../src/lattice-chart.gts","../src/range-chart.gts"],"sourcesContent":["// Sparklines: small SVG charts in a grid cell. They keep no state, so they are `cheap` cells\n// that can reuse row slots. Put one in `meta.lattice.cell` of a column whose value is an array\n// of numbers.\nimport Component from '@glimmer/component'\nimport { getOwner } from '@ember/owner'\nimport is from '@sindresorhus/is'\nimport type { TOC } from '@ember/component/template-only'\nimport { latticeLocale } from '@ember-lattice/core'\nimport type { LatticeLocale, LatticeLocaleTextOverride } from '@ember-lattice/core'\n\nexport type SparklineType = 'line' | 'area' | 'bar' | 'column'\n\nexport interface SparklineSignature {\n Args: {\n /** An array of numbers. Other items are ignored. */\n value: unknown\n type?: SparklineType\n /** Locale text that replaces the owner text for this sparkline. */\n localeText?: LatticeLocaleTextOverride\n /** The locale of the numbers. Default: the owner locale. */\n locale?: string\n }\n Element: SVGSVGElement\n}\n\nconst W = 100\nconst H = 24\nconst PAD = 2\n\nconst numbersOf = (value: unknown): number[] =>\n is.array(value) ? value.filter((v): v is number => is.number(v) && Number.isFinite(v)) : []\n\n/**\n * The accessible name of a sparkline: the minimum, the maximum and the last value, in the locale\n * (default: the English text and the runtime locale).\n */\nexport function sparklineLabel(\n value: unknown,\n l: LatticeLocale = latticeLocale(undefined),\n): string {\n const nums = numbersOf(value)\n if (nums.length === 0) return l.t('charts.sparkline.noData')\n const number = new Intl.NumberFormat(l.locale, { maximumFractionDigits: 2 })\n const [min, max, last] = [Math.min(...nums), Math.max(...nums), nums.at(-1)!].map(n =>\n number.format(n),\n )\n return l.t('charts.sparkline.label', { min: min!, max: max!, last: last! })\n}\n\ninterface Rect {\n x: number\n y: number\n width: number\n height: number\n}\n\n/** A linear scale from [lo, hi] to [to, from], flat in the middle when lo = hi. */\nconst scale = (lo: number, hi: number, from: number, to: number) => (v: number) =>\n hi === lo ? (from + to) / 2 : from + ((hi - v) / (hi - lo)) * (to - from)\n\nexport class Sparkline extends Component<SparklineSignature> {\n get nums() {\n return numbersOf(this.args.value)\n }\n\n get type(): SparklineType {\n return this.args.type ?? 'line'\n }\n\n get label() {\n return sparklineLabel(\n this.args.value,\n latticeLocale(getOwner(this), this.args.localeText, this.args.locale),\n )\n }\n\n get isLinear() {\n return this.type === 'line' || this.type === 'area'\n }\n\n get points(): Array<[number, number]> {\n const nums = this.nums\n const y = scale(Math.min(...nums), Math.max(...nums), PAD, H - PAD)\n const step = nums.length > 1 ? (W - 2 * PAD) / (nums.length - 1) : 0\n return nums.map((v, i) => [nums.length > 1 ? PAD + i * step : W / 2, y(v)])\n }\n\n /** One value has no line: it shows as a dot. */\n get dot() {\n const [x, y] = this.points[0] ?? [0, 0]\n return this.isLinear && this.nums.length === 1 ? { x, y } : undefined\n }\n\n get linePath() {\n if (!this.isLinear || this.nums.length < 2) return undefined\n return 'M' + this.points.map(([x, y]) => `${x},${y}`).join('L')\n }\n\n get areaPath() {\n const line = this.linePath\n if (this.type !== 'area' || !line) return undefined\n const xs = this.points.map(([x]) => x)\n return `${line}L${xs.at(-1)},${H}L${xs[0]},${H}Z`\n }\n\n /** Columns go up (or down) from the zero line; bars go right (or left) from it. */\n get rects(): Rect[] {\n if (this.isLinear) return []\n const nums = this.nums\n const lo = Math.min(0, ...nums)\n const hi = Math.max(0, ...nums)\n const columns = this.type === 'column'\n const band = (columns ? W : H) / nums.length\n // For bars the value runs along x, so the scale goes from right to left.\n const at = columns ? scale(lo, hi, PAD, H - PAD) : scale(lo, hi, W - PAD, PAD)\n const zero = at(0)\n return nums.map((v, i) => {\n const start = Math.min(at(v), zero)\n const length = Math.max(Math.abs(at(v) - zero), 0.5)\n const across = i * band + band * 0.1\n return columns\n ? { x: across, y: start, width: band * 0.8, height: length }\n : { x: start, y: across, width: length, height: band * 0.8 }\n })\n }\n\n <template>\n <svg\n class='lt-sparkline lt-sparkline-{{this.type}}'\n role='img'\n aria-label={{this.label}}\n viewBox='0 0 100 24'\n preserveAspectRatio='none'\n width='100%'\n height='20'\n style='display:block;color:var(--chart-1, currentColor)'\n ...attributes\n >\n {{#if this.areaPath}}\n <path\n class='lt-sparkline-area'\n d={{this.areaPath}}\n fill='currentColor'\n fill-opacity='0.2'\n stroke='none'\n />\n {{/if}}\n {{#if this.linePath}}\n <path\n class='lt-sparkline-line'\n d={{this.linePath}}\n fill='none'\n stroke='currentColor'\n stroke-width='1.5'\n vector-effect='non-scaling-stroke'\n />\n {{/if}}\n {{#if this.dot}}\n <circle cx={{this.dot.x}} cy={{this.dot.y}} r='2' fill='currentColor' />\n {{/if}}\n {{#each this.rects as |box|}}\n <rect\n x={{box.x}}\n y={{box.y}}\n width={{box.width}}\n height={{box.height}}\n fill='currentColor'\n />\n {{/each}}\n </svg>\n </template>\n}\n\n/** The cell signature: a full cell of `LatticeGrid` gets more arguments; it reads `value`. */\ninterface CellSignature {\n Args: { value: unknown }\n Element: SVGSVGElement\n}\n\nexport const LineSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='line' ...attributes />\n</template>\n\nexport const AreaSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='area' ...attributes />\n</template>\n\nexport const BarSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='bar' ...attributes />\n</template>\n\nexport const ColumnSparkline: TOC<CellSignature> = <template>\n <Sparkline @value={{@value}} @type='column' ...attributes />\n</template>\n","// The declarations of `LatticeChart` in the template form (ADR 0028, FR-11): `<c.Category>` and\n// `<c.Series>`. A declaration renders no element. The chart renders its block before its\n// `figure`, and each declaration adds itself to the registry of the chart. The chart reads the\n// registry after the block, as the grid reads its columns, so the first render has the series.\nimport Component from '@glimmer/component'\nimport { hash as record } from '@ember/helper'\nimport type { TOC } from '@ember/component/template-only'\nimport type Owner from '@ember/owner'\nimport type { ComponentLike, WithBoundArgs } from '@glint/template'\nimport { DeclarationRegistry } from '@ember-lattice/ember'\nimport type { Registered } from '@ember-lattice/ember'\n\nexport interface LatticeChartSeriesSignature {\n Args: {\n /** The ID of a number column of the table. */\n column: string\n /** The series name: the tooltip, the description and the data table. Default: the column header. */\n label?: string\n /** The series color, a CSS color. Default: `var(--chart-<n>)`, from the place of the series. */\n color?: string\n }\n}\n\nexport interface LatticeChartCategorySignature {\n Args: {\n /** The ID of the column of the x-axis labels. */\n column: string\n /** The name of the category: the description and the data table. Default: the column header. */\n label?: string\n }\n}\n\n/** The declarations that `LatticeChart` yields. */\nexport interface ChartDeclarations {\n /** The column of the x-axis labels. */\n Category: ComponentLike<LatticeChartCategorySignature>\n /** One series. The series show in template order. */\n Series: ComponentLike<LatticeChartSeriesSignature>\n}\n\n/** A declaration in the registry of a chart. */\nexport interface DeclaredPart extends Registered {\n readonly kind: 'category' | 'series'\n readonly column: string\n readonly label: string | undefined\n readonly color: string | undefined\n}\n\nexport type ChartRegistry = DeclarationRegistry<DeclaredPart>\n\nexport const chartRegistry = (): ChartRegistry => new DeclarationRegistry<DeclaredPart>()\n\ninterface Registers {\n registry: ChartRegistry\n}\n\ntype SeriesArgs = LatticeChartSeriesSignature['Args'] & Registers\ntype CategoryArgs = LatticeChartCategorySignature['Args'] & Registers\n\nexport class SeriesDeclaration extends Component<{ Args: SeriesArgs }> implements DeclaredPart {\n /** A comment node: the place of the declaration in the template. */\n readonly marker = document.createComment('')\n readonly kind = 'series'\n\n constructor(owner: Owner, args: SeriesArgs) {\n super(owner, args)\n args.registry.add(this)\n }\n\n override willDestroy() {\n super.willDestroy()\n this.args.registry.remove(this)\n }\n\n get column(): string {\n return this.args.column\n }\n\n get label(): string | undefined {\n return this.args.label\n }\n\n get color(): string | undefined {\n return this.args.color\n }\n\n <template>{{~this.marker~}}</template>\n}\n\nexport class CategoryDeclaration extends Component<{ Args: CategoryArgs }> implements DeclaredPart {\n readonly marker = document.createComment('')\n readonly kind = 'category'\n readonly color = undefined\n\n constructor(owner: Owner, args: CategoryArgs) {\n super(owner, args)\n args.registry.add(this)\n }\n\n override willDestroy() {\n super.willDestroy()\n this.args.registry.remove(this)\n }\n\n get column(): string {\n return this.args.column\n }\n\n get label(): string | undefined {\n return this.args.label\n }\n\n <template>{{~this.marker~}}</template>\n}\n\n/** The declarations of the chart, curried with its registry. */\nexport interface DeclareParts {\n Category: WithBoundArgs<typeof CategoryDeclaration, 'registry'>\n Series: WithBoundArgs<typeof SeriesDeclaration, 'registry'>\n}\n\n/** Yields the declarations: each one adds itself to the registry. */\nexport const DeclareMode: TOC<{\n Args: { registry: ChartRegistry }\n Blocks: { default: [DeclareParts] }\n}> = <template>\n {{~yield\n (record\n Category=(component CategoryDeclaration registry=@registry)\n Series=(component SeriesDeclaration registry=@registry)\n )\n ~}}\n</template>\n","// An integrated chart: the rows of a Lattice table, drawn by @ember-joinery/chart.\n//\n// Two forms give the series. The engine form gives `@columns` (and `@category`). The template\n// form (ADR 0028, FR-11) declares them in the block: `<c.Category>` and one `<c.Series>` for each\n// series, with its label and its color (`./declarations.gts`).\n//\n// The rows come from `@table` (for example the table of a grid), or from `@data`: plain rows, and\n// each column reads the key of its id.\nimport Component from '@glimmer/component'\nimport { cached } from '@glimmer/tracking'\nimport { assert } from '@ember/debug'\nimport { getOwner } from '@ember/owner'\nimport { guidFor } from '@ember/object/internals'\nimport { htmlSafe } from '@ember/template'\nimport is from '@sindresorhus/is'\nimport { latticeLocale } from '@ember-lattice/core'\nimport type { LatticeLocaleTextOverride } from '@ember-lattice/core'\nimport { ChartContainer } from '@ember-joinery/chart'\nimport type { ChartConfig } from '@ember-joinery/chart'\nimport { DeclareMode, chartRegistry } from './declarations.gts'\nimport type { ChartDeclarations, DeclaredPart } from './declarations.gts'\n\n/** The parts of a `@ember-lattice/core` table that the chart reads. */\nexport interface ChartColumn {\n id: string\n columnDef: { header?: unknown }\n}\n\nexport interface ChartRow {\n id: string\n getValue(columnId: string): unknown\n}\n\nexport interface ChartTable {\n getRowModel(): { rows: ReadonlyArray<ChartRow> }\n getAllLeafColumns(): ReadonlyArray<ChartColumn>\n getVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n}\n\nexport type LatticeChartType = 'line' | 'area' | 'bar'\n\nexport interface LatticeChartSignature {\n Args: {\n /** The rows of a table: the chart follows its sort, its filter and its groups. */\n table?: ChartTable\n /**\n * The template form: plain rows. Each column reads the key of its id. The row id is the `id`\n * key, as text, or the index. Give `@table` or `@data`, not both.\n */\n data?: ReadonlyArray<object>\n /**\n * The engine form: the ids of the number columns, one series for each. With no `@columns`,\n * the block declares the series (`<c.Series>`).\n */\n columns?: ReadonlyArray<string>\n type: LatticeChartType\n /** The chart's name: the caption and the SVG title. */\n label: string\n /**\n * The column of the x-axis labels, or `<c.Category>`. Default: the first visible column that\n * is not a series.\n */\n category?: string\n /** A selected range: only these rows, in table order. Default: all the current rows. */\n rowIds?: ReadonlyArray<string>\n /** Locale text that replaces the owner text for this chart. */\n localeText?: LatticeLocaleTextOverride\n /** The locale of the description and the numbers. Default: the owner locale. */\n locale?: string\n }\n Blocks: {\n /** The template form: `<c.Category>` and one `<c.Series>` for each series. No element. */\n default: [ChartDeclarations]\n }\n Element: HTMLElement\n}\n\n/** The name, the color and the data key of a series. */\ninterface SeriesInfo {\n key: string\n label: string\n color: string\n}\n\n/** The data key of the x-axis labels. A column id cannot start with `__lattice`. */\nconst CATEGORY = '__lattice_category'\n\n/** The data table is for screen readers only: it is not visible. */\nconst HIDDEN = htmlSafe(\n 'position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap',\n)\n\nexport default class LatticeChart extends Component<LatticeChartSignature> {\n CATEGORY = CATEGORY\n HIDDEN = HIDDEN\n captionId = `${guidFor(this)}-caption`\n\n /** The template form: the declarations of the block. */\n registry = chartRegistry()\n\n // Nothing reads the registry before the declarations block, which renders before the\n // `figure`: a registration writes tracked state (ADR 0028).\n\n /** `@table`, or with `@data`, a table of the rows. */\n get table(): ChartTable {\n const { table, data, label } = this.args\n assert(`LatticeChart \"${label}\": give @table or @data, not both`, !table || !data)\n const rows = table ?? this.rows\n assert(`LatticeChart \"${label}\": give @table or @data`, rows !== undefined)\n return rows\n }\n\n /** With `@data`: the rows as a chart table. The columns are the keys of the first row. */\n @cached get rows(): ChartTable | undefined {\n const data = this.args.data\n if (data === undefined) return undefined\n const rows = data.map((datum, index) => {\n const record = datum as Record<string, unknown>\n const id = record['id']\n return {\n id: is.string(id) || is.number(id) ? String(id) : String(index),\n getValue: (key: string) => record[key],\n }\n })\n const columns = Object.keys(data[0] ?? {}).map(id => ({ id, columnDef: {} }))\n return { getRowModel: () => ({ rows }), getAllLeafColumns: () => columns }\n }\n\n /** The declarations of one kind, in template order. */\n private declared(kind: DeclaredPart['kind']): DeclaredPart[] {\n return this.registry.items.filter(part => part.kind === kind)\n }\n\n /** The ids of the series columns: `@columns`, or the `<c.Series>` declarations. */\n @cached get seriesIds(): ReadonlyArray<string> {\n const declared = this.declared('series').map(part => part.column)\n const columns = this.args.columns\n if (columns !== undefined) {\n assert(\n `LatticeChart \"${this.args.label}\": give @columns or <c.Series>, not both`,\n declared.length === 0,\n )\n return columns\n }\n const twice = declared.filter((id, i) => declared.indexOf(id) !== i)\n assert(\n `LatticeChart \"${this.args.label}\": two series have the column \"${twice.join('\", \"')}\"`,\n twice.length === 0,\n )\n return declared\n }\n\n /**\n * The name and the color of each series: the `@label` and the `@color` of its declaration, or\n * the column header and the chart token of its place.\n */\n get seriesInfo(): SeriesInfo[] {\n const parts = new Map(this.declared('series').map(part => [part.column, part]))\n const declared = this.args.columns === undefined\n return this.seriesIds.map((key, i) => {\n const part = declared ? parts.get(key) : undefined\n return {\n key,\n label: part?.label ?? this.headerOf(key),\n color: part?.color ?? `var(--chart-${(i % 5) + 1})`,\n }\n })\n }\n\n get l() {\n return latticeLocale(getOwner(this), this.args.localeText, this.args.locale)\n }\n\n /** The header text of a column, or its id. */\n headerOf = (id: string) => {\n const header = this.table.getAllLeafColumns().find(c => c.id === id)?.columnDef.header\n return is.string(header) ? header : id\n }\n\n get seriesNames(): string[] {\n return this.seriesInfo.map(series => series.label)\n }\n\n get categoryName(): string {\n const category = this.category\n const label = this.declared('category')[0]?.label\n if (label !== undefined) return label\n return category ? this.headerOf(category) : this.l.t('charts.chart.category')\n }\n\n /** The SVG `<desc>`: the kind, the series, the category and the number of points. */\n get description(): string {\n const l = this.l\n return l.t('charts.chart.description', {\n type: l.t(`charts.chart.${this.args.type}`),\n series: new Intl.ListFormat(l.locale, { type: 'conjunction' }).format(this.seriesNames),\n category: this.categoryName,\n points: l.plural('charts.chart.points', this.data.length),\n })\n }\n\n /** The rows of the data table: the category, then a text for each series. */\n get tableRows(): { category: string; values: string[] }[] {\n const number = new Intl.NumberFormat(this.l.locale)\n return this.data.map(datum => ({\n category: String(datum[CATEGORY]),\n values: this.seriesIds.map(id => {\n const value = datum[id]\n return is.number(value) ? number.format(value) : ''\n }),\n }))\n }\n\n get columns() {\n const table = this.table\n return table.getVisibleLeafColumns?.() ?? table.getAllLeafColumns()\n }\n\n /** The column of the x-axis labels: `@category`, `<c.Category>`, or the first other column. */\n get category() {\n const declared = this.declared('category')\n assert(\n `LatticeChart \"${this.args.label}\": give @category or <c.Category>, not both`,\n this.args.category === undefined || declared.length === 0,\n )\n assert(`LatticeChart \"${this.args.label}\": give one <c.Category>`, declared.length <= 1)\n const series = this.seriesIds\n return (\n this.args.category ??\n declared[0]?.column ??\n this.columns.find(c => !series.includes(c.id))?.id\n )\n }\n\n get config(): ChartConfig {\n return Object.fromEntries(\n this.seriesInfo.map(series => [series.key, { label: series.label, color: series.color }]),\n )\n }\n\n get series() {\n return this.seriesIds.map(key => ({ key, color: `var(--color-${key})` }))\n }\n\n get data() {\n const ids = this.args.rowIds ? new Set(this.args.rowIds) : undefined\n const category = this.category\n const series = this.seriesIds\n return this.table\n .getRowModel()\n .rows.filter(row => !ids || ids.has(row.id))\n .map(row => {\n const datum: Record<string, unknown> = {\n [CATEGORY]: category ? String(row.getValue(category) ?? '') : row.id,\n }\n for (const id of series) {\n const value = row.getValue(id)\n datum[id] = is.number(value) ? value : null\n }\n return datum\n })\n }\n\n get isBar() {\n return this.args.type === 'bar'\n }\n\n get isArea() {\n return this.args.type === 'area'\n }\n\n <template>\n {{~! The template form (ADR 0028): the declarations render first, and render no element. ~}}\n {{~#if (has-block)~}}\n <DeclareMode @registry={{this.registry}} as |c|>{{yield c}}</DeclareMode>\n {{~/if~}}\n <figure class='lt-chart' aria-labelledby={{this.captionId}} ...attributes>\n <figcaption class='lt-chart-caption' id={{this.captionId}}>{{@label}}</figcaption>\n <ChartContainer @config={{this.config}} as |chart|>\n {{#if this.isBar}}\n <chart.BarChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Bar @dataKey={{s.key}} @fill={{s.color}} />\n {{/each}}\n </chart.BarChart>\n {{else if this.isArea}}\n <chart.AreaChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Area @dataKey={{s.key}} @fill={{s.color}} @stroke={{s.color}} />\n {{/each}}\n </chart.AreaChart>\n {{else}}\n <chart.LineChart @data={{this.data}} @title={{@label}} @desc={{this.description}} as |c|>\n <c.CartesianGrid @vertical={{false}} />\n <c.XAxis @dataKey={{this.CATEGORY}} />\n <c.YAxis />\n <c.ChartTooltip />\n {{#each this.series as |s|}}\n <c.Line @dataKey={{s.key}} @stroke={{s.color}} />\n {{/each}}\n </chart.LineChart>\n {{/if}}\n </ChartContainer>\n <table class='lt-chart-data' style={{this.HIDDEN}}>\n <caption>{{@label}}</caption>\n <thead>\n <tr>\n <th scope='col'>{{this.categoryName}}</th>\n {{#each this.seriesNames as |name|}}\n <th scope='col'>{{name}}</th>\n {{/each}}\n </tr>\n </thead>\n <tbody>\n {{#each this.tableRows as |row|}}\n <tr>\n <th scope='row'>{{row.category}}</th>\n {{#each row.values as |value|}}\n <td>{{value}}</td>\n {{/each}}\n </tr>\n {{/each}}\n </tbody>\n </table>\n </figure>\n </template>\n}\n","// Chart a range: a chart of the selected cells of a grid. The rows of the range are the points.\n// The number columns of the range are the series, and the first other column is the x-axis.\n// An app opens it from a context menu item (the `export` block of `GridContextMenu`).\nimport Component from '@glimmer/component'\nimport is from '@sindresorhus/is'\nimport type { GridRange } from '@ember-lattice/ember'\nimport LatticeChart from './lattice-chart.gts'\nimport type { ChartColumn, ChartTable, LatticeChartType } from './lattice-chart.gts'\n\n/** A table with the parts that a range needs: the cell selection and the pinned column order. */\nexport interface ChartRangeTable extends ChartTable {\n getCellSelectionBounds?(): ReadonlyArray<GridRange>\n getStartVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n getCenterVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n getEndVisibleLeafColumns?(): ReadonlyArray<ChartColumn>\n}\n\nexport interface RangeChartArgs {\n rowIds: string[]\n columns: string[]\n category: string | undefined\n}\n\n/** The columns in the order of the grid: start pinned, center, end pinned. */\nfunction displayColumns(table: ChartRangeTable): ReadonlyArray<ChartColumn> {\n const center =\n table.getCenterVisibleLeafColumns?.() ??\n table.getVisibleLeafColumns?.() ??\n table.getAllLeafColumns()\n return [\n ...(table.getStartVisibleLeafColumns?.() ?? []),\n ...center,\n ...(table.getEndVisibleLeafColumns?.() ?? []),\n ]\n}\n\n/** The `LatticeChart` args of a range: its row IDs, its number columns and its category. */\nexport function rangeChartArgs(table: ChartRangeTable, range: GridRange): RangeChartArgs {\n const rows = table.getRowModel().rows.slice(range.minRowIndex, range.maxRowIndex + 1)\n const ids = displayColumns(table)\n .slice(range.minColumnIndex, range.maxColumnIndex + 1)\n .map(c => c.id)\n // A column is a series when its values in the range are numbers (blanks are allowed).\n const isNumber = (id: string) =>\n rows.some(r => is.number(r.getValue(id))) &&\n rows.every(r => is.number(r.getValue(id)) || is.nullOrUndefined(r.getValue(id)))\n return {\n rowIds: rows.map(r => r.id),\n columns: ids.filter(isNumber),\n category: ids.find(id => !isNumber(id)),\n }\n}\n\nexport interface RangeChartSignature {\n Args: {\n table: ChartRangeTable\n type: LatticeChartType\n label: string\n /** The range. Default: the last range of the table cell selection. */\n range?: GridRange\n }\n Element: HTMLElement\n}\n\nexport class RangeChart extends Component<RangeChartSignature> {\n get range(): GridRange | undefined {\n return this.args.range ?? this.args.table.getCellSelectionBounds?.().at(-1)\n }\n\n get chart(): RangeChartArgs | undefined {\n const range = this.range\n return range ? rangeChartArgs(this.args.table, range) : undefined\n }\n\n <template>\n {{#if this.chart}}\n <LatticeChart\n @table={{@table}}\n @columns={{this.chart.columns}}\n @rowIds={{this.chart.rowIds}}\n @category={{this.chart.category}}\n @type={{@type}}\n @label={{@label}}\n ...attributes\n />\n {{/if}}\n </template>\n}\n"],"names":["W","H","PAD","numbersOf","value","is","array","filter","v","number","Number","isFinite","sparklineLabel","l","latticeLocale","undefined","nums","length","t","Intl","NumberFormat","locale","maximumFractionDigits","min","max","last","Math","at","map","n","format","scale","lo","hi","from","to","Sparkline","Component","args","type","label","getOwner","localeText","isLinear","points","y","step","i","dot","x","linePath","join","areaPath","line","xs","rects","columns","band","zero","start","abs","across","width","height","setComponentTemplate","precompileTemplate","strictMode","LineSparkline","scope","templateOnly","AreaSparkline","BarSparkline","ColumnSparkline","chartRegistry","DeclarationRegistry","SeriesDeclaration","marker","document","createComment","kind","constructor","owner","registry","add","willDestroy","remove","column","color","CategoryDeclaration","DeclareMode","record","CATEGORY","HIDDEN","htmlSafe","LatticeChart","captionId","guidFor","table","data","assert","rows","datum","index","id","string","String","getValue","key","Object","keys","columnDef","getRowModel","getAllLeafColumns","prototype","cached","declared","items","part","seriesIds","twice","indexOf","seriesInfo","parts","Map","get","headerOf","header","find","c","seriesNames","series","categoryName","category","description","ListFormat","plural","tableRows","values","getVisibleLeafColumns","includes","config","fromEntries","ids","rowIds","Set","row","has","isBar","isArea","ChartContainer","displayColumns","center","getCenterVisibleLeafColumns","getStartVisibleLeafColumns","getEndVisibleLeafColumns","rangeChartArgs","range","slice","minRowIndex","maxRowIndex","minColumnIndex","maxColumnIndex","isNumber","some","r","every","nullOrUndefined","RangeChart","getCellSelectionBounds","chart"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAuBA,MAAMA,CAAA,GAAI,GAAA;AACV,MAAMC,CAAA,GAAI,EAAA;AACV,MAAMC,GAAA,GAAM,CAAA;AAEZ,MAAMC,SAAA,GAAaC,KAAc,IAC/BC,EAAA,CAAGC,KAAK,CAACF,KAAA,CAAA,GAASA,KAAA,CAAMG,MAAM,CAAEC,CAAA,IAAmBH,EAAA,CAAGI,MAAM,CAACD,CAAA,CAAA,IAAME,MAAA,CAAOC,QAAQ,CAACH,CAAA,CAAA,CAAA,GAAM,EAAE;AAE7F;;;;AAIO,SAASI,cAAAA,CACdR,KAAc,EACdS,CAAG,GAAgBC,aAAA,CAAcC,SAAA,CAAU,EACpC;AACP,EAAA,MAAMC,OAAOb,SAAA,CAAUC,KAAA,CAAA;AACvB,EAAA,IAAIY,KAAKC,MAAM,KAAK,GAAG,OAAOJ,CAAA,CAAEK,CAAC,CAAC,yBAAA,CAAA;EAClC,MAAMT,SAAS,IAAIU,IAAA,CAAKC,YAAY,CAACP,CAAA,CAAEQ,MAAM,EAAE;AAAEC,IAAAA,qBAAA,EAAuB;AAAE,GAAA,CAAA;EAC1E,MAAM,CAACC,GAAA,EAAKC,GAAA,EAAKC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CAACsH,KAAK,IAAI,IAAI,CAACtH,IAAI,CAAC2D,KAAK,CAACuE,sBAAsB,IAAA,CAAK7I,GAAG,EAAC,CAAA;AAC3E,EAAA;EAEA,IAAI8I,KAAAA,GAAoC;AACtC,IAAA,MAAMb,KAAA,GAAQ,IAAI,CAACA,KAAK;AACxB,IAAA,OAAOA,KAAA,GAAQD,eAAe,IAAI,CAACrH,IAAI,CAAC2D,KAAK,EAAE2D,KAAA,CAAA,GAAS7I,SAAA;AAC1D,EAAA;AAEA,EAAA;IAAAiD,oBAAA,CAAAC,kBAAA,CAAA,mNAAA,EAYA;MAAAC,UAAA,EAAA,IAAA;AAAAE,MAAAA,KAAA,EAAAA,OAAA;AAAA0B,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-lattice/charts",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Sparklines and integrated charts for Lattice, through the Joinery chart add-on.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -42,8 +42,8 @@
42
42
  "NOTICE"
43
43
  ],
44
44
  "dependencies": {
45
- "@ember-lattice/core": "1.0.0",
46
- "@ember-lattice/ember": "1.0.0",
45
+ "@ember-lattice/core": "1.1.0",
46
+ "@ember-lattice/ember": "1.1.0",
47
47
  "@embroider/addon-shim": "^1.10.3",
48
48
  "@sindresorhus/is": "^7.2.0",
49
49
  "decorator-transforms": "^2.4.0"