ngwr 16.4.0 → 16.5.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/charts/bar-chart/styles/_index.scss +494 -305
- package/charts/boxplot-chart/styles/_index.scss +114 -48
- package/charts/bullet-chart/styles/_index.scss +113 -42
- package/charts/calendar-heatmap/styles/_index.scss +111 -20
- package/charts/candlestick-chart/styles/_index.scss +61 -26
- package/charts/chart-legend/styles/_index.scss +119 -1
- package/charts/core/styles/_index.scss +201 -5
- package/charts/donut-chart/styles/_index.scss +76 -21
- package/charts/funnel-chart/styles/_index.scss +66 -38
- package/charts/gauge/styles/_index.scss +12 -1
- package/charts/heatmap-chart/styles/_index.scss +90 -53
- package/charts/line-chart/styles/_index.scss +143 -139
- package/charts/meter-group/styles/_index.scss +87 -25
- package/charts/radar-chart/styles/_index.scss +82 -40
- package/charts/scatter-chart/styles/_index.scss +117 -44
- package/charts/sparkline/styles/_index.scss +7 -1
- package/charts/treemap-chart/styles/_index.scss +94 -42
- package/charts/waterfall-chart/styles/_index.scss +150 -87
- package/color-picker/styles/_index.scss +7 -3
- package/copy-value/styles/_index.scss +21 -2
- package/date-stamp/styles/_index.scss +2 -1
- package/dialog/styles/_index.scss +6 -0
- package/drawer/styles/_index.scss +5 -1
- package/fesm2022/ngwr-carousel-testing.mjs +4 -1
- package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +21 -2
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +48 -4
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
- package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
- package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
- package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
- package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
- package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +299 -18
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
- package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge.mjs +98 -12
- package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
- package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
- package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
- package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +223 -31
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
- package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
- package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
- package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
- package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
- package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +44 -4
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +47 -19
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
- package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +38 -2
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +56 -8
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +13 -5
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +19 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +35 -6
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +1 -0
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +81 -13
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +5 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +5 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +5 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +5 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +5 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +5 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +5 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +5 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +5 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +5 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +5 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +5 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +5 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +5 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +5 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +5 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +5 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +5 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +5 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +5 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +5 -0
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +5 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +20 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +21 -2
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +41 -5
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +67 -12
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +2 -0
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +2 -0
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +14 -9
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +49 -16
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +16 -9
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/i18n/ar.json +5 -0
- package/i18n/cs.json +5 -0
- package/i18n/de.json +5 -0
- package/i18n/en.json +5 -0
- package/i18n/es.json +5 -0
- package/i18n/fr.json +5 -0
- package/i18n/he.json +5 -0
- package/i18n/hi.json +5 -0
- package/i18n/id.json +5 -0
- package/i18n/it.json +5 -0
- package/i18n/ja.json +5 -0
- package/i18n/ko.json +5 -0
- package/i18n/nl.json +5 -0
- package/i18n/pl.json +5 -0
- package/i18n/pt.json +5 -0
- package/i18n/ru.json +5 -0
- package/i18n/sv.json +5 -0
- package/i18n/tr.json +5 -0
- package/i18n/uk.json +5 -0
- package/i18n/vi.json +5 -0
- package/i18n/zh-TW.json +5 -0
- package/i18n/zh.json +5 -0
- package/llms-full.txt +8 -8
- package/llms.txt +7 -3
- package/package.json +1 -1
- package/popconfirm/styles/_index.scss +6 -0
- package/popover/styles/_index.scss +24 -13
- package/schematics/use/symbol-map.json +1 -0
- package/skills/ngwr/references/catalog.md +1 -1
- package/tour/styles/_index.scss +6 -0
- package/types/ngwr-carousel-testing.d.ts +6 -4
- package/types/ngwr-carousel.d.ts +14 -3
- package/types/ngwr-cascader-testing.d.ts +4 -3
- package/types/ngwr-cascader.d.ts +27 -3
- package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
- package/types/ngwr-charts-bar-chart.d.ts +220 -48
- package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
- package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
- package/types/ngwr-charts-bullet-chart.d.ts +72 -12
- package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
- package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
- package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
- package/types/ngwr-charts-chart-legend.d.ts +142 -5
- package/types/ngwr-charts-core.d.ts +259 -21
- package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
- package/types/ngwr-charts-donut-chart.d.ts +124 -16
- package/types/ngwr-charts-funnel-chart.d.ts +62 -6
- package/types/ngwr-charts-gauge-testing.d.ts +5 -1
- package/types/ngwr-charts-gauge.d.ts +72 -10
- package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
- package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
- package/types/ngwr-charts-line-chart.d.ts +215 -86
- package/types/ngwr-charts-meter-group.d.ts +96 -7
- package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
- package/types/ngwr-charts-radar-chart.d.ts +148 -28
- package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
- package/types/ngwr-charts-scatter-chart.d.ts +188 -18
- package/types/ngwr-charts-sparkline.d.ts +26 -4
- package/types/ngwr-charts-treemap-chart.d.ts +121 -23
- package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
- package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
- package/types/ngwr-color-picker.d.ts +27 -0
- package/types/ngwr-context-menu-testing.d.ts +10 -9
- package/types/ngwr-context-menu.d.ts +17 -0
- package/types/ngwr-copy-value.d.ts +8 -0
- package/types/ngwr-date-picker.d.ts +34 -2
- package/types/ngwr-dialog.d.ts +30 -10
- package/types/ngwr-drawer.d.ts +32 -1
- package/types/ngwr-dropdown-testing.d.ts +8 -5
- package/types/ngwr-dropdown.d.ts +29 -6
- package/types/ngwr-graph.d.ts +22 -6
- package/types/ngwr-lightbox.d.ts +15 -0
- package/types/ngwr-overlay.d.ts +16 -1
- package/types/ngwr-popconfirm-testing.d.ts +11 -2
- package/types/ngwr-popconfirm.d.ts +28 -1
- package/types/ngwr-popover.d.ts +59 -9
- package/types/ngwr-table.d.ts +1 -1
- package/types/ngwr-tour.d.ts +21 -2
- package/types/ngwr-tree-testing.d.ts +1 -2
- package/types/ngwr-tree.d.ts +33 -2
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-window.d.ts +14 -11
- package/window/styles/_index.scss +5 -10
|
@@ -1,11 +1,69 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Component, DestroyRef, LOCALE_ID, PLATFORM_ID, ViewEncapsulation, afterNextRender, afterRenderEffect, computed,
|
|
2
|
+
import { Component, DestroyRef, LOCALE_ID, PLATFORM_ID, ViewEncapsulation, afterNextRender, afterRenderEffect, computed, inject, input, model, signal, untracked, viewChild } from "@angular/core";
|
|
3
3
|
import { coerceBooleanProperty, coerceNumberProperty } from "@angular/cdk/coercion";
|
|
4
|
-
import {
|
|
4
|
+
import { NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
5
5
|
import { wrCheckStyles, wrClamp } from "ngwr/utils";
|
|
6
6
|
import { useI18nText } from "ngwr/i18n";
|
|
7
7
|
import { WR_CHART_LEGEND_BLOCK, WrChartLegend } from "ngwr/charts/chart-legend";
|
|
8
|
-
import { WrChartTable, useChartNumbers, wrChartAxis, wrChartColor, wrChartDash } from "ngwr/charts/core";
|
|
8
|
+
import { WrChartState, WrChartTable, useChartHover, useChartNumbers, useChartSize, useChartState, wrChartAxis, wrChartColor, wrChartDash, wrChartLongest, wrChartNumberFormat } from "ngwr/charts/core";
|
|
9
|
+
import { useChartTooltip, wrCoerceChartTooltip } from "ngwr/popover";
|
|
10
|
+
/**
|
|
11
|
+
* @license
|
|
12
|
+
*
|
|
13
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
14
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
15
|
+
*/
|
|
16
|
+
const DENSITY = 2;
|
|
17
|
+
function wrLineChartKeep(values, columns) {
|
|
18
|
+
const count = values.length;
|
|
19
|
+
const cols = Math.floor(columns);
|
|
20
|
+
const every = !(cols > 0) || count <= cols * DENSITY;
|
|
21
|
+
const kept = [];
|
|
22
|
+
let column = -1;
|
|
23
|
+
let first = -1;
|
|
24
|
+
let low = -1;
|
|
25
|
+
let high = -1;
|
|
26
|
+
let last = -1;
|
|
27
|
+
const flush = () => {
|
|
28
|
+
if (first < 0) return;
|
|
29
|
+
kept.push(first);
|
|
30
|
+
const early = Math.min(low, high);
|
|
31
|
+
const late = Math.max(low, high);
|
|
32
|
+
if (early !== first && early !== last) kept.push(early);
|
|
33
|
+
if (late !== early && late !== first && late !== last) kept.push(late);
|
|
34
|
+
if (last !== first) kept.push(last);
|
|
35
|
+
first = -1;
|
|
36
|
+
};
|
|
37
|
+
for (let i = 0; i < count; i++) {
|
|
38
|
+
const value = values[i];
|
|
39
|
+
if (value === null) {
|
|
40
|
+
flush();
|
|
41
|
+
column = -1;
|
|
42
|
+
if (kept.length > 0 && kept[kept.length - 1] !== -1) kept.push(-1);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (every) {
|
|
46
|
+
kept.push(i);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const at = Math.min(cols - 1, Math.floor(i * cols / count));
|
|
50
|
+
if (at !== column) {
|
|
51
|
+
flush();
|
|
52
|
+
column = at;
|
|
53
|
+
first = low = high = last = i;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (value < values[low]) low = i;
|
|
57
|
+
if (value > values[high]) high = i;
|
|
58
|
+
last = i;
|
|
59
|
+
}
|
|
60
|
+
flush();
|
|
61
|
+
if (kept[kept.length - 1] === -1) kept.pop();
|
|
62
|
+
return kept;
|
|
63
|
+
}
|
|
64
|
+
function wrLineChartCrowded(count, width, spacing) {
|
|
65
|
+
return count > 1 && width > 0 && width / (count - 1) < spacing;
|
|
66
|
+
}
|
|
9
67
|
/**
|
|
10
68
|
* @license
|
|
11
69
|
*
|
|
@@ -17,7 +75,9 @@ const ASSUMED_INSET = 16;
|
|
|
17
75
|
const CHAR_WIDTH = 7;
|
|
18
76
|
const LABEL_GAP = 8;
|
|
19
77
|
const HOVER_RADIUS = 6;
|
|
20
|
-
const
|
|
78
|
+
const DOT_SPACING = 6;
|
|
79
|
+
const PROBES = 3;
|
|
80
|
+
const TOOLTIP_CLASS = "wr-line-chart__tooltip";
|
|
21
81
|
var WrLineChart = class WrLineChart {
|
|
22
82
|
series = input([], ...ngDevMode ? [{ debugName: "series" }] : /* istanbul ignore next */ []);
|
|
23
83
|
ariaLabel = input(null, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
@@ -35,10 +95,26 @@ var WrLineChart = class WrLineChart {
|
|
|
35
95
|
...ngDevMode ? { debugName: "showGrid" } : /* istanbul ignore next */ {},
|
|
36
96
|
transform: coerceBooleanProperty
|
|
37
97
|
});
|
|
38
|
-
|
|
98
|
+
showAxis = input(true, {
|
|
99
|
+
...ngDevMode ? { debugName: "showAxis" } : /* istanbul ignore next */ {},
|
|
100
|
+
transform: coerceBooleanProperty
|
|
101
|
+
});
|
|
102
|
+
showLegend = input("auto", {
|
|
39
103
|
...ngDevMode ? { debugName: "showLegend" } : /* istanbul ignore next */ {},
|
|
104
|
+
transform: (value) => value === "auto" ? "auto" : coerceBooleanProperty(value)
|
|
105
|
+
});
|
|
106
|
+
legendPosition = input("bottom", ...ngDevMode ? [{ debugName: "legendPosition" }] : /* istanbul ignore next */ []);
|
|
107
|
+
loading = input(false, {
|
|
108
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
40
109
|
transform: coerceBooleanProperty
|
|
41
110
|
});
|
|
111
|
+
error = input(false, {
|
|
112
|
+
...ngDevMode ? { debugName: "error" } : /* istanbul ignore next */ {},
|
|
113
|
+
transform: coerceBooleanProperty
|
|
114
|
+
});
|
|
115
|
+
emptyLabel = input(null, ...ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []);
|
|
116
|
+
loadingLabel = input(null, ...ngDevMode ? [{ debugName: "loadingLabel" }] : /* istanbul ignore next */ []);
|
|
117
|
+
errorLabel = input(null, ...ngDevMode ? [{ debugName: "errorLabel" }] : /* istanbul ignore next */ []);
|
|
42
118
|
toggleableLegend = input(false, {
|
|
43
119
|
...ngDevMode ? { debugName: "toggleableLegend" } : /* istanbul ignore next */ {},
|
|
44
120
|
transform: coerceBooleanProperty
|
|
@@ -48,6 +124,10 @@ var WrLineChart = class WrLineChart {
|
|
|
48
124
|
...ngDevMode ? { debugName: "showDots" } : /* istanbul ignore next */ {},
|
|
49
125
|
transform: coerceBooleanProperty
|
|
50
126
|
});
|
|
127
|
+
decimate = input(true, {
|
|
128
|
+
...ngDevMode ? { debugName: "decimate" } : /* istanbul ignore next */ {},
|
|
129
|
+
transform: coerceBooleanProperty
|
|
130
|
+
});
|
|
51
131
|
showArea = input(false, {
|
|
52
132
|
...ngDevMode ? { debugName: "showArea" } : /* istanbul ignore next */ {},
|
|
53
133
|
transform: coerceBooleanProperty
|
|
@@ -62,50 +142,39 @@ var WrLineChart = class WrLineChart {
|
|
|
62
142
|
});
|
|
63
143
|
tooltip = input(true, {
|
|
64
144
|
...ngDevMode ? { debugName: "tooltip" } : /* istanbul ignore next */ {},
|
|
65
|
-
transform:
|
|
145
|
+
transform: wrCoerceChartTooltip
|
|
66
146
|
});
|
|
67
147
|
vbW = 600;
|
|
68
148
|
vbH = 300;
|
|
69
149
|
svg = viewChild.required("svg", ...ngDevMode ? [{ debugName: "svg" }] : /* istanbul ignore next */ []);
|
|
70
150
|
plot = viewChild.required("plot", ...ngDevMode ? [{ debugName: "plot" }] : /* istanbul ignore next */ []);
|
|
71
151
|
probe = viewChild("probe", ...ngDevMode ? [{ debugName: "probe" }] : /* istanbul ignore next */ []);
|
|
72
|
-
|
|
73
|
-
ordinals = new Intl.NumberFormat(inject(LOCALE_ID));
|
|
152
|
+
ordinals = wrChartNumberFormat(inject(LOCALE_ID));
|
|
74
153
|
measured = signal(null, ...ngDevMode ? [{ debugName: "measured" }] : /* istanbul ignore next */ []);
|
|
75
|
-
|
|
76
|
-
hoveredIndex = signal(null, ...ngDevMode ? [{ debugName: "hoveredIndex" }] : /* istanbul ignore next */ []);
|
|
77
|
-
activeIndex = computed(() => this.tooltip() ? this.hoveredIndex() : null, ...ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []);
|
|
78
|
-
dismissed = null;
|
|
154
|
+
drawingSize = useChartSize(this.svg);
|
|
79
155
|
constructor() {
|
|
80
156
|
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("charts/line-chart");
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const onKeydown = (event) => {
|
|
85
|
-
if (event.key !== "Escape") return;
|
|
86
|
-
this.dismissed = this.hoveredIndex();
|
|
87
|
-
this.hoveredIndex.set(null);
|
|
88
|
-
};
|
|
89
|
-
document.addEventListener("keydown", onKeydown);
|
|
90
|
-
onCleanup(() => document.removeEventListener("keydown", onKeydown));
|
|
157
|
+
useChartHover({
|
|
158
|
+
enter: () => void 0,
|
|
159
|
+
leave: () => void 0
|
|
91
160
|
});
|
|
92
161
|
if (!isPlatformBrowser(inject(PLATFORM_ID))) return;
|
|
93
162
|
const destroyRef = inject(DestroyRef);
|
|
94
163
|
afterRenderEffect(() => {
|
|
95
164
|
this.probeText();
|
|
165
|
+
this.drawingSize();
|
|
96
166
|
untracked(() => this.measure());
|
|
97
167
|
});
|
|
98
|
-
afterRenderEffect(() => {
|
|
99
|
-
const points = this.hoverPoints();
|
|
100
|
-
const tooltip = this.tooltipEl()?.nativeElement;
|
|
101
|
-
if (points.length === 0 || !tooltip) return;
|
|
102
|
-
untracked(() => this.placeTooltip(points, tooltip));
|
|
103
|
-
});
|
|
104
168
|
afterNextRender(() => {
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
169
|
+
const plot = this.plot().nativeElement;
|
|
170
|
+
const move = (event) => this.onPointerMove(event);
|
|
171
|
+
const leave = (event) => this.tip.leave(event);
|
|
172
|
+
plot.addEventListener("mousemove", move);
|
|
173
|
+
plot.addEventListener("mouseleave", leave);
|
|
174
|
+
destroyRef.onDestroy(() => {
|
|
175
|
+
plot.removeEventListener("mousemove", move);
|
|
176
|
+
plot.removeEventListener("mouseleave", leave);
|
|
177
|
+
});
|
|
109
178
|
});
|
|
110
179
|
}
|
|
111
180
|
resolvedSeries = computed(() => this.series().map((s, i) => ({
|
|
@@ -120,6 +189,29 @@ var WrLineChart = class WrLineChart {
|
|
|
120
189
|
color,
|
|
121
190
|
dash
|
|
122
191
|
})), ...ngDevMode ? [{ debugName: "legendItems" }] : /* istanbul ignore next */ []);
|
|
192
|
+
legendShown = computed(() => {
|
|
193
|
+
const show = this.showLegend();
|
|
194
|
+
const rows = this.legendItems().length;
|
|
195
|
+
if (show === false || rows === 0 || this.legendPosition() === "none") return false;
|
|
196
|
+
return show === true || rows > 1;
|
|
197
|
+
}, ...ngDevMode ? [{ debugName: "legendShown" }] : /* istanbul ignore next */ []);
|
|
198
|
+
legendFirst = computed(() => {
|
|
199
|
+
const position = this.legendPosition();
|
|
200
|
+
return position === "top" || position === "start";
|
|
201
|
+
}, ...ngDevMode ? [{ debugName: "legendFirst" }] : /* istanbul ignore next */ []);
|
|
202
|
+
legendSide = computed(() => {
|
|
203
|
+
const position = this.legendPosition();
|
|
204
|
+
return position === "start" || position === "end";
|
|
205
|
+
}, ...ngDevMode ? [{ debugName: "legendSide" }] : /* istanbul ignore next */ []);
|
|
206
|
+
empty = computed(() => this.resolvedSeries().every((s) => s.data.length === 0), ...ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []);
|
|
207
|
+
state = useChartState({
|
|
208
|
+
loading: this.loading,
|
|
209
|
+
error: this.error,
|
|
210
|
+
empty: this.empty,
|
|
211
|
+
emptyLabel: this.emptyLabel,
|
|
212
|
+
loadingLabel: this.loadingLabel,
|
|
213
|
+
errorLabel: this.errorLabel
|
|
214
|
+
});
|
|
123
215
|
visibleSeries = computed(() => {
|
|
124
216
|
const hidden = new Set(this.hiddenSeries());
|
|
125
217
|
return this.resolvedSeries().filter((s) => !hidden.has(s.index));
|
|
@@ -175,77 +267,90 @@ var WrLineChart = class WrLineChart {
|
|
|
175
267
|
const { min, max, ticks } = this.bounds();
|
|
176
268
|
return ticks.map((value) => ({
|
|
177
269
|
value,
|
|
270
|
+
zero: value === 0,
|
|
178
271
|
y: (max - value) / (max - min) * this.vbH
|
|
179
272
|
}));
|
|
180
273
|
}, ...ngDevMode ? [{ debugName: "yTicks" }] : /* istanbul ignore next */ []);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
274
|
+
columns = computed(() => {
|
|
275
|
+
if (!this.decimate()) return 0;
|
|
276
|
+
const width = Math.round(this.measured()?.width ?? ASSUMED_WIDTH);
|
|
277
|
+
return this.pointCount() > width * 2 ? width : 0;
|
|
278
|
+
}, ...ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []);
|
|
279
|
+
dotsShown = computed(() => {
|
|
280
|
+
if (!this.showDots()) return false;
|
|
281
|
+
if (!this.decimate()) return true;
|
|
282
|
+
return !wrLineChartCrowded(this.pointCount(), this.measured()?.width ?? ASSUMED_WIDTH, DOT_SPACING);
|
|
283
|
+
}, ...ngDevMode ? [{ debugName: "dotsShown" }] : /* istanbul ignore next */ []);
|
|
284
|
+
keptSeries = computed(() => {
|
|
285
|
+
const columns = this.columns();
|
|
286
|
+
return this.plottedSeries().map((s) => ({
|
|
287
|
+
...s,
|
|
288
|
+
kept: wrLineChartKeep(s.tops, columns)
|
|
289
|
+
}));
|
|
290
|
+
}, ...ngDevMode ? [{ debugName: "keptSeries" }] : /* istanbul ignore next */ []);
|
|
291
|
+
linePath(values, kept) {
|
|
292
|
+
let d = "";
|
|
184
293
|
let run = 0;
|
|
185
294
|
let last = "";
|
|
186
295
|
const closeRun = () => {
|
|
187
|
-
if (run === 1)
|
|
296
|
+
if (run === 1) d += ` L ${last}`;
|
|
188
297
|
run = 0;
|
|
189
298
|
};
|
|
190
|
-
|
|
191
|
-
if (
|
|
299
|
+
for (const i of kept) {
|
|
300
|
+
if (i === -1) {
|
|
192
301
|
closeRun();
|
|
193
|
-
|
|
302
|
+
continue;
|
|
194
303
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
last = `${x.toFixed(2)} ${y.toFixed(2)}`;
|
|
198
|
-
commands.push(`${run === 0 ? "M" : "L"} ${last}`);
|
|
304
|
+
last = `${this.pointX(i).toFixed(2)} ${this.pointY(values[i] ?? 0).toFixed(2)}`;
|
|
305
|
+
d += `${d ? " " : ""}${run === 0 ? "M" : "L"} ${last}`;
|
|
199
306
|
run++;
|
|
200
|
-
}
|
|
307
|
+
}
|
|
201
308
|
closeRun();
|
|
202
|
-
return
|
|
309
|
+
return d;
|
|
203
310
|
}
|
|
204
311
|
drawn = computed(() => {
|
|
205
|
-
const dots = this.
|
|
206
|
-
return this.
|
|
312
|
+
const dots = this.dotsShown();
|
|
313
|
+
return this.keptSeries().map((s) => ({
|
|
207
314
|
index: s.index,
|
|
208
315
|
color: s.color,
|
|
209
316
|
dash: s.dash,
|
|
210
|
-
d: this.
|
|
211
|
-
dots: dots ? this.dotsFor(s.tops) : ""
|
|
317
|
+
d: this.linePath(s.tops, s.kept),
|
|
318
|
+
dots: dots ? this.dotsFor(s.tops, s.kept) : ""
|
|
212
319
|
}));
|
|
213
320
|
}, ...ngDevMode ? [{ debugName: "drawn" }] : /* istanbul ignore next */ []);
|
|
214
|
-
dotsFor(values) {
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (v !== null) commands.push(this.dotPath(this.pointX(i), (max - v) / (max - min) * this.vbH));
|
|
321
|
+
dotsFor(values, kept) {
|
|
322
|
+
let d = "";
|
|
323
|
+
for (const i of kept) {
|
|
324
|
+
if (i === -1) continue;
|
|
325
|
+
d += `${d ? " " : ""}${this.dotPath(this.pointX(i), this.pointY(values[i] ?? 0))}`;
|
|
220
326
|
}
|
|
221
|
-
return
|
|
327
|
+
return d;
|
|
222
328
|
}
|
|
223
329
|
areas = computed(() => {
|
|
224
330
|
if (!this.showArea() || this.pointCount() <= 1) return [];
|
|
225
|
-
return this.
|
|
331
|
+
return this.keptSeries().flatMap((s) => {
|
|
226
332
|
const fills = [];
|
|
227
|
-
let
|
|
228
|
-
const close = (
|
|
229
|
-
if (
|
|
230
|
-
key: `${s.index}:${
|
|
333
|
+
let run = [];
|
|
334
|
+
const close = () => {
|
|
335
|
+
if (run.length >= 2) fills.push({
|
|
336
|
+
key: `${s.index}:${run[0]}`,
|
|
337
|
+
series: s.index,
|
|
231
338
|
color: s.color,
|
|
232
|
-
d: this.areaPath(s,
|
|
339
|
+
d: this.areaPath(s, run)
|
|
233
340
|
});
|
|
234
|
-
|
|
341
|
+
run = [];
|
|
235
342
|
};
|
|
236
|
-
s.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
});
|
|
240
|
-
close(s.tops.length);
|
|
343
|
+
for (const i of s.kept) if (i === -1) close();
|
|
344
|
+
else run.push(i);
|
|
345
|
+
close();
|
|
241
346
|
return fills;
|
|
242
347
|
});
|
|
243
348
|
}, ...ngDevMode ? [{ debugName: "areas" }] : /* istanbul ignore next */ []);
|
|
244
|
-
areaPath(series,
|
|
349
|
+
areaPath(series, run) {
|
|
245
350
|
const at = (i, value) => `${this.pointX(i).toFixed(2)} ${this.pointY(value).toFixed(2)}`;
|
|
246
351
|
const commands = [];
|
|
247
|
-
for (let
|
|
248
|
-
for (let
|
|
352
|
+
for (let k = 0; k < run.length; k++) commands.push(`${k === 0 ? "M" : "L"} ${at(run[k], series.tops[run[k]] ?? 0)}`);
|
|
353
|
+
for (let k = run.length - 1; k >= 0; k--) commands.push(`L ${at(run[k], series.bases?.[run[k]] ?? 0)}`);
|
|
249
354
|
commands.push("Z");
|
|
250
355
|
return commands.join(" ");
|
|
251
356
|
}
|
|
@@ -265,7 +370,7 @@ var WrLineChart = class WrLineChart {
|
|
|
265
370
|
const count = this.pointCount();
|
|
266
371
|
return count <= 1 ? 100 : Math.min(100, 100 * this.xAxis().every / (count - 1));
|
|
267
372
|
}, ...ngDevMode ? [{ debugName: "xSlot" }] : /* istanbul ignore next */ []);
|
|
268
|
-
probeText = computed(() =>
|
|
373
|
+
probeText = computed(() => wrChartLongest(this.xLabels().map((label) => label.replace(/\r\n?|\n/g, " ")), PROBES).join("\n"), ...ngDevMode ? [{ debugName: "probeText" }] : /* istanbul ignore next */ []);
|
|
269
374
|
xAxis = computed(() => {
|
|
270
375
|
const labels = this.xLabels();
|
|
271
376
|
const count = this.pointCount();
|
|
@@ -297,9 +402,7 @@ var WrLineChart = class WrLineChart {
|
|
|
297
402
|
ticks
|
|
298
403
|
};
|
|
299
404
|
}, ...ngDevMode ? [{ debugName: "xAxis" }] : /* istanbul ignore next */ []);
|
|
300
|
-
|
|
301
|
-
const i = this.activeIndex();
|
|
302
|
-
if (i === null) return [];
|
|
405
|
+
pointsAt(i) {
|
|
303
406
|
return this.plottedSeries().flatMap((s) => {
|
|
304
407
|
const value = s.data[i];
|
|
305
408
|
const plotted = s.tops[i];
|
|
@@ -315,26 +418,63 @@ var WrLineChart = class WrLineChart {
|
|
|
315
418
|
y: this.pointY(plotted)
|
|
316
419
|
}];
|
|
317
420
|
});
|
|
318
|
-
}
|
|
319
|
-
|
|
421
|
+
}
|
|
422
|
+
tip = useChartTooltip(this.tooltip, (index) => this.readout(index), (x, y) => this.indexAt(x, y));
|
|
423
|
+
activeIndex = computed(() => this.state() ? null : this.tip.active(), ...ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []);
|
|
424
|
+
hoverPoints = computed(() => {
|
|
320
425
|
const i = this.activeIndex();
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
426
|
+
return i === null ? [] : this.pointsAt(i);
|
|
427
|
+
}, ...ngDevMode ? [{ debugName: "hoverPoints" }] : /* istanbul ignore next */ []);
|
|
428
|
+
readout(index) {
|
|
429
|
+
if (this.state()) return null;
|
|
430
|
+
const points = this.pointsAt(index);
|
|
431
|
+
if (points.length === 0) return null;
|
|
432
|
+
const box = this.svg().nativeElement.getBoundingClientRect();
|
|
433
|
+
const x = box.left + points[0].x / this.vbW * box.width;
|
|
434
|
+
let top = Number.POSITIVE_INFINITY;
|
|
435
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
436
|
+
for (const point of points) {
|
|
437
|
+
const y = box.top + point.y / this.vbH * box.height;
|
|
438
|
+
if (y < top) top = y;
|
|
439
|
+
if (y > bottom) bottom = y;
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
datum: {
|
|
443
|
+
label: this.xLabels()[index] ?? this.ordinals.format(index + 1),
|
|
444
|
+
value: "",
|
|
445
|
+
rows: points.map(({ label, text, color }) => ({
|
|
446
|
+
label,
|
|
447
|
+
value: text,
|
|
448
|
+
color
|
|
449
|
+
})),
|
|
450
|
+
className: TOOLTIP_CLASS
|
|
451
|
+
},
|
|
452
|
+
anchor: {
|
|
453
|
+
x: x - HOVER_RADIUS,
|
|
454
|
+
y: top - HOVER_RADIUS,
|
|
455
|
+
width: 12,
|
|
456
|
+
height: bottom - top + 12
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
}
|
|
324
460
|
onPointerMove(event) {
|
|
325
|
-
if (!this.tooltip()) return;
|
|
461
|
+
if (!this.tooltip() || this.tip.active() !== null) return;
|
|
462
|
+
const index = this.indexAt(event.clientX, event.clientY);
|
|
463
|
+
if (index === null) this.tip.leave(event);
|
|
464
|
+
else this.tip.enter(index);
|
|
465
|
+
}
|
|
466
|
+
indexAt(clientX, clientY) {
|
|
326
467
|
const count = this.pointCount();
|
|
468
|
+
if (count === 0 || this.state()) return null;
|
|
327
469
|
const box = this.svg().nativeElement.getBoundingClientRect();
|
|
328
|
-
if (
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
this.dismissed = null;
|
|
337
|
-
this.hoveredIndex.set(null);
|
|
470
|
+
if (box.width <= 0) return null;
|
|
471
|
+
const measured = this.measured();
|
|
472
|
+
if (measured && box.height > 0) {
|
|
473
|
+
const { inset, insetY } = measured;
|
|
474
|
+
if (clientX < box.left - inset || clientX > box.right + inset || clientY < box.top - insetY || clientY > box.bottom + insetY) return null;
|
|
475
|
+
}
|
|
476
|
+
const ratio = (clientX - box.left) / box.width;
|
|
477
|
+
return count === 1 ? 0 : wrClamp(Math.round(ratio * (count - 1)), 0, count - 1);
|
|
338
478
|
}
|
|
339
479
|
dotPath(x, y) {
|
|
340
480
|
return `M ${x.toFixed(2)} ${y.toFixed(2)} h 0`;
|
|
@@ -342,62 +482,19 @@ var WrLineChart = class WrLineChart {
|
|
|
342
482
|
measure() {
|
|
343
483
|
const box = this.svg().nativeElement.getBoundingClientRect();
|
|
344
484
|
if (box.width <= 0) return;
|
|
345
|
-
const
|
|
485
|
+
const plot = this.plot().nativeElement.getBoundingClientRect();
|
|
486
|
+
const inset = box.left - plot.left;
|
|
487
|
+
const insetY = Math.max(0, box.top - plot.top);
|
|
346
488
|
const label = this.probe()?.nativeElement.getBoundingClientRect().width ?? 0;
|
|
347
489
|
const last = this.measured();
|
|
348
|
-
if (last?.width === box.width && last.inset === inset && last.label === label) return;
|
|
490
|
+
if (last?.width === box.width && last.inset === inset && last.insetY === insetY && last.label === label) return;
|
|
349
491
|
this.measured.set({
|
|
350
492
|
width: box.width,
|
|
351
493
|
inset,
|
|
494
|
+
insetY,
|
|
352
495
|
label
|
|
353
496
|
});
|
|
354
497
|
}
|
|
355
|
-
placeTooltip(points, tooltip) {
|
|
356
|
-
const box = this.svg().nativeElement.getBoundingClientRect();
|
|
357
|
-
const plot = this.plot().nativeElement.getBoundingClientRect();
|
|
358
|
-
const rect = tooltip.getBoundingClientRect();
|
|
359
|
-
if (box.height <= 0 || rect.height <= 0 || rect.width <= 0) return;
|
|
360
|
-
const current = this.tooltipPlacement();
|
|
361
|
-
const inset = current === "below" ? box.bottom - rect.bottom : rect.top - box.top;
|
|
362
|
-
const { width, height } = rect;
|
|
363
|
-
const x = box.left + points[0].x / this.vbW * box.width;
|
|
364
|
-
const ys = points.map((p) => box.top + p.y / this.vbH * box.height);
|
|
365
|
-
const across = (left) => wrClamp(left, plot.left, plot.right - width);
|
|
366
|
-
const top = box.top + inset;
|
|
367
|
-
const candidates = [
|
|
368
|
-
{
|
|
369
|
-
placement: "top",
|
|
370
|
-
left: across(x - width / 2),
|
|
371
|
-
top
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
placement: "below",
|
|
375
|
-
left: across(x - width / 2),
|
|
376
|
-
top: box.bottom - inset - height
|
|
377
|
-
},
|
|
378
|
-
x - plot.left > plot.right - x ? {
|
|
379
|
-
placement: "left",
|
|
380
|
-
left: across(x - BESIDE - width),
|
|
381
|
-
top
|
|
382
|
-
} : {
|
|
383
|
-
placement: "right",
|
|
384
|
-
left: across(x + BESIDE),
|
|
385
|
-
top
|
|
386
|
-
}
|
|
387
|
-
];
|
|
388
|
-
const covers = (c) => x + HOVER_RADIUS > c.left && x - HOVER_RADIUS < c.left + width ? ys.filter((y) => y + HOVER_RADIUS > c.top && y - HOVER_RADIUS < c.top + height).length : 0;
|
|
389
|
-
let best = candidates[0];
|
|
390
|
-
let fewest = covers(best);
|
|
391
|
-
for (const candidate of candidates.slice(1)) {
|
|
392
|
-
if (fewest === 0) break;
|
|
393
|
-
const count = covers(candidate);
|
|
394
|
-
if (count < fewest) {
|
|
395
|
-
best = candidate;
|
|
396
|
-
fewest = count;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
if (best.placement !== current) this.tooltipPlacement.set(best.placement);
|
|
400
|
-
}
|
|
401
498
|
tickLabels = computed(() => this.numbers.ticks(this.yTicks().map((tick) => tick.value), this.bounds().step), ...ngDevMode ? [{ debugName: "tickLabels" }] : /* istanbul ignore next */ []);
|
|
402
499
|
yAxis = computed(() => {
|
|
403
500
|
const labels = this.tickLabels();
|
|
@@ -480,6 +577,13 @@ var WrLineChart = class WrLineChart {
|
|
|
480
577
|
isRequired: false,
|
|
481
578
|
transformFunction: null
|
|
482
579
|
},
|
|
580
|
+
showAxis: {
|
|
581
|
+
classPropertyName: "showAxis",
|
|
582
|
+
publicName: "showAxis",
|
|
583
|
+
isSignal: true,
|
|
584
|
+
isRequired: false,
|
|
585
|
+
transformFunction: null
|
|
586
|
+
},
|
|
483
587
|
showLegend: {
|
|
484
588
|
classPropertyName: "showLegend",
|
|
485
589
|
publicName: "showLegend",
|
|
@@ -487,6 +591,48 @@ var WrLineChart = class WrLineChart {
|
|
|
487
591
|
isRequired: false,
|
|
488
592
|
transformFunction: null
|
|
489
593
|
},
|
|
594
|
+
legendPosition: {
|
|
595
|
+
classPropertyName: "legendPosition",
|
|
596
|
+
publicName: "legendPosition",
|
|
597
|
+
isSignal: true,
|
|
598
|
+
isRequired: false,
|
|
599
|
+
transformFunction: null
|
|
600
|
+
},
|
|
601
|
+
loading: {
|
|
602
|
+
classPropertyName: "loading",
|
|
603
|
+
publicName: "loading",
|
|
604
|
+
isSignal: true,
|
|
605
|
+
isRequired: false,
|
|
606
|
+
transformFunction: null
|
|
607
|
+
},
|
|
608
|
+
error: {
|
|
609
|
+
classPropertyName: "error",
|
|
610
|
+
publicName: "error",
|
|
611
|
+
isSignal: true,
|
|
612
|
+
isRequired: false,
|
|
613
|
+
transformFunction: null
|
|
614
|
+
},
|
|
615
|
+
emptyLabel: {
|
|
616
|
+
classPropertyName: "emptyLabel",
|
|
617
|
+
publicName: "emptyLabel",
|
|
618
|
+
isSignal: true,
|
|
619
|
+
isRequired: false,
|
|
620
|
+
transformFunction: null
|
|
621
|
+
},
|
|
622
|
+
loadingLabel: {
|
|
623
|
+
classPropertyName: "loadingLabel",
|
|
624
|
+
publicName: "loadingLabel",
|
|
625
|
+
isSignal: true,
|
|
626
|
+
isRequired: false,
|
|
627
|
+
transformFunction: null
|
|
628
|
+
},
|
|
629
|
+
errorLabel: {
|
|
630
|
+
classPropertyName: "errorLabel",
|
|
631
|
+
publicName: "errorLabel",
|
|
632
|
+
isSignal: true,
|
|
633
|
+
isRequired: false,
|
|
634
|
+
transformFunction: null
|
|
635
|
+
},
|
|
490
636
|
toggleableLegend: {
|
|
491
637
|
classPropertyName: "toggleableLegend",
|
|
492
638
|
publicName: "toggleableLegend",
|
|
@@ -508,6 +654,13 @@ var WrLineChart = class WrLineChart {
|
|
|
508
654
|
isRequired: false,
|
|
509
655
|
transformFunction: null
|
|
510
656
|
},
|
|
657
|
+
decimate: {
|
|
658
|
+
classPropertyName: "decimate",
|
|
659
|
+
publicName: "decimate",
|
|
660
|
+
isSignal: true,
|
|
661
|
+
isRequired: false,
|
|
662
|
+
transformFunction: null
|
|
663
|
+
},
|
|
511
664
|
showArea: {
|
|
512
665
|
classPropertyName: "showArea",
|
|
513
666
|
publicName: "showArea",
|
|
@@ -540,10 +693,12 @@ var WrLineChart = class WrLineChart {
|
|
|
540
693
|
outputs: { hiddenSeries: "hiddenSeriesChange" },
|
|
541
694
|
host: {
|
|
542
695
|
properties: {
|
|
696
|
+
"class.wr-chart--legend-side": "legendShown() && legendSide()",
|
|
697
|
+
"class.wr-line-chart--axis": "showAxis()",
|
|
543
698
|
"class.wr-line-chart--area": "showArea()",
|
|
544
699
|
"class.wr-line-chart--stacked": "stacked()"
|
|
545
700
|
},
|
|
546
|
-
classAttribute: "wr-line-chart"
|
|
701
|
+
classAttribute: "wr-line-chart wr-chart--legend"
|
|
547
702
|
},
|
|
548
703
|
viewQueries: [
|
|
549
704
|
{
|
|
@@ -566,35 +721,48 @@ var WrLineChart = class WrLineChart {
|
|
|
566
721
|
predicate: ["probe"],
|
|
567
722
|
descendants: true,
|
|
568
723
|
isSignal: true
|
|
724
|
+
}
|
|
725
|
+
],
|
|
726
|
+
ngImport: i0,
|
|
727
|
+
template: "@let hovered = activeIndex();\n@let shown = state();\n\n<!-- The legend, drawn before the body or after it so it is in the DOM where it is on\n screen: a toggleable legend's rows are tab stops, and their order follows it. Every\n row keys its series by the series' own dash rather than a solid block: a coloured\n square leaves the reader to match it to the LINE, and matching by colour is the step\n the patterns exist to remove. Rows are tracked by position, so two series that share\n a label are two rows. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-line-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSeries\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<!-- Two columns: the y-axis labels at inline start, the drawing beside them, and the\n x labels under the drawing only, so their percentages are the drawing's. -->\n<div class=\"wr-line-chart__body\">\n @if (showAxis()) {\n <!-- The tick labels are HTML beside the drawing rather than `<text>` inside it: the\n drawing stretches with `preserveAspectRatio=\"none\"` and its type stretched with\n it. In flow, so the column is exactly as wide as the longest label; each one\n hands the stylesheet the y of its own gridline, as the x labels hand it their x.\n Hidden, as they were inside the plot's `img`: the plot's name is what is\n announced. -->\n <div class=\"wr-line-chart__y-axis\" aria-hidden=\"true\">\n @for (tick of yAxis(); track $index) {\n <span class=\"wr-line-chart__tick\" [style.--wr-line-chart-y]=\"tick.y\">{{ tick.label }}</span>\n }\n </div>\n }\n\n <!-- The pointer is heard on the plot by one native listener pair the component adds,\n and an x is found by position. -->\n <div\n #plot\n class=\"wr-line-chart__plot\"\n role=\"img\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [style.height.px]=\"height()\"\n >\n <!-- Named, where it was the only unnamed element in the component. The legend\n swatch is an `<svg>` too now, so `querySelector('svg')` no longer means\n \"the chart\" — and a plot that nothing can address by name is one a\n consumer's stylesheet and a spec both have to reach by position. -->\n <svg #svg class=\"wr-line-chart__svg\" [attr.viewBox]=\"viewBox()\" preserveAspectRatio=\"none\">\n @if (showGrid()) {\n @for (tick of yTicks(); track tick.value) {\n <!-- The colour is the stylesheet's, from `--wr-line-chart-grid-color`, so forced\n colors can swap it for the system's own; the line at zero takes the\n stronger `--wr-line-chart-zero-color`. -->\n <line\n class=\"wr-line-chart__grid-line\"\n [class.wr-line-chart__grid-line--zero]=\"tick.zero\"\n x1=\"0\"\n [attr.x2]=\"vbW\"\n [attr.y1]=\"tick.y\"\n [attr.y2]=\"tick.y\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n\n @if (!shown) {\n <!-- Every fill before every line, so the lines and their dashes stay on top where\n the fills overlap and the series are still told apart by shape. The opacity is\n the stylesheet's, from `--wr-line-chart-area-opacity`. `data-wr-series` is the\n series' row in the legend, which the shared hover dims by. -->\n @for (area of areas(); track area.key) {\n <path\n class=\"wr-line-chart__area\"\n [attr.d]=\"area.d\"\n [attr.fill]=\"area.color\"\n [attr.data-wr-series]=\"area.series\"\n stroke=\"none\"\n />\n }\n\n <!-- By position, not by label: two series may share one, and a duplicate key\n makes Angular re-create rows it cannot tell apart. Each is drawn at its\n plotted values, which under `stacked` are the tops of its band. Every path is\n built once per data change (`drawn`), so hovering rebuilds none of them. The\n width is the stylesheet's, from `--wr-line-chart-line-width`. -->\n @for (s of drawn(); track s.index) {\n <path\n class=\"wr-line-chart__line\"\n [attr.d]=\"s.d\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n [attr.stroke-dasharray]=\"s.dash || null\"\n [attr.data-wr-series]=\"s.index\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n <!-- Every dot of the series in one path, a subpath each, so a long series costs\n one element rather than one per point. A hole in the data gets no dot. A dot\n is a zero-length line with a round cap and a non-scaling stroke, which stays\n a circle however the drawing stretches; a `<circle>` scaled with it, into\n a 3 × 5px oval on a phone and a 9 × 5px one at 1920px. Its size is the\n stylesheet's, from `--wr-line-chart-dot-size`. -->\n @if (s.dots) {\n <path\n class=\"wr-line-chart__dot\"\n [attr.d]=\"s.dots\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n [attr.data-wr-series]=\"s.index\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n }\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <line\n class=\"wr-line-chart__crosshair\"\n [attr.x1]=\"pointX(hovered)\"\n [attr.x2]=\"pointX(hovered)\"\n y1=\"0\"\n [attr.y2]=\"vbH\"\n vector-effect=\"non-scaling-stroke\"\n />\n <!-- A marker in the series' colour inside a ring of the surface, drawn the way a\n dot is and for the same reason: the ring first, a wider stroke under the\n marker's. The ring's colour is the stylesheet's, from\n `--wr-line-chart-hover-center`. -->\n @for (p of hoverPoints(); track p.index) {\n <path\n class=\"wr-line-chart__hover-dot-ring\"\n [attr.d]=\"dotPath(p.x, p.y)\"\n fill=\"none\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n <path\n class=\"wr-line-chart__hover-dot\"\n [attr.d]=\"dotPath(p.x, p.y)\"\n fill=\"none\"\n [attr.stroke]=\"p.color\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n </svg>\n </div>\n\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the grid and the axis the chart keeps.\n Beside the plot, in its grid cell, and not inside it: the plot is an `img`, which\n makes everything it holds presentational, and the message is a live region. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n\n @if (xLabels().length > 0) {\n <!-- The strip is as wide as the plot, and hands the stylesheet the distance between\n two printed labels; each label hands it the x of the point it names. Both are\n percentages of the drawing's width, so they track the drawing at any size: the\n stylesheet centres a label on its point and ellipsises it past its slot. Laying the\n labels out as equal centred flex slots instead is bar-chart geometry: only the\n middle label landed on its dot, and the outer ones sat up to half a column away.\n The hidden copy of the longest few labels, a line each, is what the room they\n need is measured against: it is as wide as the widest of them. -->\n <div class=\"wr-line-chart__x-labels\" [style.--wr-line-chart-x-slot]=\"xSlot()\">\n <span #probe class=\"wr-line-chart__x-probe\" aria-hidden=\"true\">{{ probeText() }}</span>\n @for (tick of xAxis().ticks; track tick.index) {\n <span class=\"wr-line-chart__x-label\" [style.--wr-line-chart-x]=\"tick.x\">{{ tick.label }}</span>\n }\n </div>\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n@if (dataTable() && !shown) {\n <!-- The figures for a screen reader, beside the plot's `img` and never inside it:\n `img` makes everything it holds presentational. Clipped to nothing by its own\n stylesheet, so it takes no room and draws nothing. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n",
|
|
728
|
+
dependencies: [
|
|
729
|
+
{
|
|
730
|
+
kind: "directive",
|
|
731
|
+
type: NgTemplateOutlet,
|
|
732
|
+
selector: "[ngTemplateOutlet]",
|
|
733
|
+
inputs: [
|
|
734
|
+
"ngTemplateOutletContext",
|
|
735
|
+
"ngTemplateOutlet",
|
|
736
|
+
"ngTemplateOutletInjector"
|
|
737
|
+
]
|
|
569
738
|
},
|
|
570
739
|
{
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
740
|
+
kind: "component",
|
|
741
|
+
type: WrChartLegend,
|
|
742
|
+
selector: "ul[wr-chart-legend]",
|
|
743
|
+
inputs: [
|
|
744
|
+
"items",
|
|
745
|
+
"position",
|
|
746
|
+
"toggleable",
|
|
747
|
+
"hiddenSeries",
|
|
748
|
+
"ariaLabel",
|
|
749
|
+
"hiddenLabel"
|
|
750
|
+
],
|
|
751
|
+
outputs: ["hiddenSeriesChange", "toggled"]
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
kind: "component",
|
|
755
|
+
type: WrChartState,
|
|
756
|
+
selector: "wr-chart-state",
|
|
757
|
+
inputs: ["kind", "label"]
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
kind: "component",
|
|
761
|
+
type: WrChartTable,
|
|
762
|
+
selector: "wr-chart-table",
|
|
763
|
+
inputs: ["data"]
|
|
576
764
|
}
|
|
577
765
|
],
|
|
578
|
-
ngImport: i0,
|
|
579
|
-
template: "@let hovered = activeIndex();\n@if (showLegend() && resolvedSeries().length > 0) {\n <!-- Every row keys its series by the series' own dash rather than a solid block: a\n coloured square leaves the reader to match it to the LINE, and matching by colour\n is the step the patterns exist to remove. Rows are tracked by position, so two\n series that share a label are two rows. -->\n <ul\n wr-chart-legend\n class=\"wr-line-chart__legend\"\n [items]=\"legendItems()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSeries\"\n ></ul>\n}\n\n<!-- Two columns: the y-axis labels at inline start, the drawing beside them, and the\n x labels under the drawing only, so their percentages are the drawing's. -->\n<div class=\"wr-line-chart__body\">\n @if (showGrid()) {\n <!-- The tick labels are HTML beside the drawing rather than `<text>` inside it: the\n drawing stretches with `preserveAspectRatio=\"none\"` and its type stretched with\n it. In flow, so the column is exactly as wide as the longest label; each one\n hands the stylesheet the y of its own gridline, as the x labels hand it their x.\n Hidden, as they were inside the plot's `img`: the plot's name is what is\n announced. -->\n <div class=\"wr-line-chart__y-axis\" aria-hidden=\"true\">\n @for (tick of yAxis(); track $index) {\n <span class=\"wr-line-chart__tick\" [style.--wr-line-chart-y]=\"tick.y\">{{ tick.label }}</span>\n }\n </div>\n }\n\n <div\n #plot\n class=\"wr-line-chart__plot\"\n role=\"img\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [style.height.px]=\"height()\"\n (mousemove)=\"onPointerMove($event)\"\n (mouseleave)=\"onPointerLeave()\"\n >\n <!-- Named, where it was the only unnamed element in the component. The legend\n swatch is an `<svg>` too now, so `querySelector('svg')` no longer means\n \"the chart\" — and a plot that nothing can address by name is one a\n consumer's stylesheet and a spec both have to reach by position. -->\n <svg #svg class=\"wr-line-chart__svg\" [attr.viewBox]=\"viewBox()\" preserveAspectRatio=\"none\">\n @if (showGrid()) {\n @for (tick of yTicks(); track tick.value) {\n <!-- The colour is the stylesheet's, from `--wr-line-chart-grid-color`, so forced\n colors can swap it for the system's own. -->\n <line\n class=\"wr-line-chart__grid-line\"\n x1=\"0\"\n [attr.x2]=\"vbW\"\n [attr.y1]=\"tick.y\"\n [attr.y2]=\"tick.y\"\n stroke-width=\"1\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n\n <!-- Every fill before every line, so the lines and their dashes stay on top where\n the fills overlap and the series are still told apart by shape. The opacity is\n the stylesheet's, from `--wr-line-chart-area-opacity`. -->\n @for (area of areas(); track area.key) {\n <path class=\"wr-line-chart__area\" [attr.d]=\"area.d\" [attr.fill]=\"area.color\" stroke=\"none\" />\n }\n\n <!-- By position, not by label: two series may share one, and a duplicate key\n makes Angular re-create rows it cannot tell apart. Each is drawn at its\n plotted values, which under `stacked` are the tops of its band. Every path is\n built once per data change (`drawn`), so hovering rebuilds none of them. -->\n @for (s of drawn(); track s.index) {\n <path\n class=\"wr-line-chart__line\"\n [attr.d]=\"s.d\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n [attr.stroke-dasharray]=\"s.dash || null\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n <!-- Every dot of the series in one path, a subpath each, so a long series costs\n one element rather than one per point. A hole in the data gets no dot. A dot\n is a zero-length line with a round cap and a non-scaling stroke, which stays\n a 6px circle however the drawing stretches; a `<circle>` scaled with it, into\n a 3 × 5px oval on a phone and a 9 × 5px one at 1920px. -->\n @if (s.dots) {\n <path\n class=\"wr-line-chart__dot\"\n [attr.d]=\"s.dots\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n stroke-width=\"6\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <line\n class=\"wr-line-chart__crosshair\"\n [attr.x1]=\"pointX(hovered)\"\n [attr.x2]=\"pointX(hovered)\"\n y1=\"0\"\n [attr.y2]=\"vbH\"\n stroke-width=\"1\"\n stroke-dasharray=\"3 3\"\n vector-effect=\"non-scaling-stroke\"\n />\n <!-- A ring of the series' colour round a surface-coloured centre, drawn the way a\n dot is and for the same reason. The centre's colour is the stylesheet's, from\n `--wr-line-chart-hover-center`. -->\n @for (p of hoverPoints(); track p.index) {\n <path\n class=\"wr-line-chart__hover-dot\"\n [attr.d]=\"dotPath(p.x, p.y)\"\n fill=\"none\"\n [attr.stroke]=\"p.color\"\n stroke-width=\"12\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n <path\n class=\"wr-line-chart__hover-dot-center\"\n [attr.d]=\"dotPath(p.x, p.y)\"\n fill=\"none\"\n stroke-width=\"8\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n </svg>\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <!-- The layer covers the plot and is what the tooltip's `cqw` measures. It is out of\n flow, so the containment it turns on costs the plot's own sizing nothing. The\n tooltip takes the same `--wr-line-chart-x` the x labels take, and the same\n clamp: centred on its point, never past either end. At the top of the plot, or\n where that would cover a marker it reads, at the bottom (`--below`) or beside the\n crosshair (`--left`, `--right`). -->\n <div class=\"wr-line-chart__tooltip-layer\">\n <div\n #tooltip\n class=\"wr-line-chart__tooltip\"\n [class.wr-line-chart__tooltip--below]=\"tooltipPlacement() === 'below'\"\n [class.wr-line-chart__tooltip--left]=\"tooltipPlacement() === 'left'\"\n [class.wr-line-chart__tooltip--right]=\"tooltipPlacement() === 'right'\"\n [style.--wr-line-chart-x]=\"xPercent(hovered)\"\n >\n <div class=\"wr-line-chart__tooltip-label\">{{ hoverLabel() }}</div>\n @for (p of hoverPoints(); track p.index) {\n <div class=\"wr-line-chart__tooltip-row\">\n <span class=\"wr-line-chart__swatch\" [style.background]=\"p.color\"></span>\n <span class=\"wr-line-chart__tooltip-name\">{{ p.label }}</span>\n <span class=\"wr-line-chart__tooltip-value\">{{ p.text }}</span>\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n @if (xLabels().length > 0) {\n <!-- The strip is as wide as the plot, and hands the stylesheet the distance between\n two printed labels; each label hands it the x of the point it names. Both are\n percentages of the drawing's width, so they track the drawing at any size: the\n stylesheet centres a label on its point and ellipsises it past its slot. Laying the\n labels out as equal centred flex slots instead is bar-chart geometry: only the\n middle label landed on its dot, and the outer ones sat up to half a column away.\n The hidden copy of every label, a line each, is what the room they need is\n measured against: it is as wide as the widest. -->\n <div class=\"wr-line-chart__x-labels\" [style.--wr-line-chart-x-slot]=\"xSlot()\">\n <span #probe class=\"wr-line-chart__x-probe\" aria-hidden=\"true\">{{ probeText() }}</span>\n @for (tick of xAxis().ticks; track tick.index) {\n <span class=\"wr-line-chart__x-label\" [style.--wr-line-chart-x]=\"tick.x\">{{ tick.label }}</span>\n }\n </div>\n }\n</div>\n\n@if (dataTable()) {\n <!-- The figures for a screen reader, beside the plot's `img` and never inside it:\n `img` makes everything it holds presentational. Clipped to nothing by its own\n stylesheet, so it takes no room and draws nothing. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n",
|
|
580
|
-
dependencies: [{
|
|
581
|
-
kind: "component",
|
|
582
|
-
type: WrChartLegend,
|
|
583
|
-
selector: "ul[wr-chart-legend]",
|
|
584
|
-
inputs: [
|
|
585
|
-
"items",
|
|
586
|
-
"toggleable",
|
|
587
|
-
"hiddenSeries",
|
|
588
|
-
"ariaLabel",
|
|
589
|
-
"hiddenLabel"
|
|
590
|
-
],
|
|
591
|
-
outputs: ["hiddenSeriesChange", "toggled"]
|
|
592
|
-
}, {
|
|
593
|
-
kind: "component",
|
|
594
|
-
type: WrChartTable,
|
|
595
|
-
selector: "wr-chart-table",
|
|
596
|
-
inputs: ["data"]
|
|
597
|
-
}],
|
|
598
766
|
viewProviders: [{
|
|
599
767
|
provide: WR_CHART_LEGEND_BLOCK,
|
|
600
768
|
useValue: "wr-line-chart"
|
|
@@ -613,16 +781,23 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
613
781
|
selector: "wr-line-chart",
|
|
614
782
|
encapsulation: ViewEncapsulation.None,
|
|
615
783
|
host: {
|
|
616
|
-
class: "wr-line-chart",
|
|
784
|
+
class: "wr-line-chart wr-chart--legend",
|
|
785
|
+
"[class.wr-chart--legend-side]": "legendShown() && legendSide()",
|
|
786
|
+
"[class.wr-line-chart--axis]": "showAxis()",
|
|
617
787
|
"[class.wr-line-chart--area]": "showArea()",
|
|
618
788
|
"[class.wr-line-chart--stacked]": "stacked()"
|
|
619
789
|
},
|
|
620
|
-
imports: [
|
|
790
|
+
imports: [
|
|
791
|
+
NgTemplateOutlet,
|
|
792
|
+
WrChartLegend,
|
|
793
|
+
WrChartState,
|
|
794
|
+
WrChartTable
|
|
795
|
+
],
|
|
621
796
|
viewProviders: [{
|
|
622
797
|
provide: WR_CHART_LEGEND_BLOCK,
|
|
623
798
|
useValue: "wr-line-chart"
|
|
624
799
|
}],
|
|
625
|
-
template: "@let hovered = activeIndex();\n@
|
|
800
|
+
template: "@let hovered = activeIndex();\n@let shown = state();\n\n<!-- The legend, drawn before the body or after it so it is in the DOM where it is on\n screen: a toggleable legend's rows are tab stops, and their order follows it. Every\n row keys its series by the series' own dash rather than a solid block: a coloured\n square leaves the reader to match it to the LINE, and matching by colour is the step\n the patterns exist to remove. Rows are tracked by position, so two series that share\n a label are two rows. -->\n<ng-template #legend>\n <ul\n wr-chart-legend\n class=\"wr-line-chart__legend\"\n [items]=\"legendItems()\"\n [position]=\"legendPosition()\"\n [toggleable]=\"toggleableLegend()\"\n [(hiddenSeries)]=\"hiddenSeries\"\n ></ul>\n</ng-template>\n\n@if (legendShown() && legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n<!-- Two columns: the y-axis labels at inline start, the drawing beside them, and the\n x labels under the drawing only, so their percentages are the drawing's. -->\n<div class=\"wr-line-chart__body\">\n @if (showAxis()) {\n <!-- The tick labels are HTML beside the drawing rather than `<text>` inside it: the\n drawing stretches with `preserveAspectRatio=\"none\"` and its type stretched with\n it. In flow, so the column is exactly as wide as the longest label; each one\n hands the stylesheet the y of its own gridline, as the x labels hand it their x.\n Hidden, as they were inside the plot's `img`: the plot's name is what is\n announced. -->\n <div class=\"wr-line-chart__y-axis\" aria-hidden=\"true\">\n @for (tick of yAxis(); track $index) {\n <span class=\"wr-line-chart__tick\" [style.--wr-line-chart-y]=\"tick.y\">{{ tick.label }}</span>\n }\n </div>\n }\n\n <!-- The pointer is heard on the plot by one native listener pair the component adds,\n and an x is found by position. -->\n <div\n #plot\n class=\"wr-line-chart__plot\"\n role=\"img\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [style.height.px]=\"height()\"\n >\n <!-- Named, where it was the only unnamed element in the component. The legend\n swatch is an `<svg>` too now, so `querySelector('svg')` no longer means\n \"the chart\" — and a plot that nothing can address by name is one a\n consumer's stylesheet and a spec both have to reach by position. -->\n <svg #svg class=\"wr-line-chart__svg\" [attr.viewBox]=\"viewBox()\" preserveAspectRatio=\"none\">\n @if (showGrid()) {\n @for (tick of yTicks(); track tick.value) {\n <!-- The colour is the stylesheet's, from `--wr-line-chart-grid-color`, so forced\n colors can swap it for the system's own; the line at zero takes the\n stronger `--wr-line-chart-zero-color`. -->\n <line\n class=\"wr-line-chart__grid-line\"\n [class.wr-line-chart__grid-line--zero]=\"tick.zero\"\n x1=\"0\"\n [attr.x2]=\"vbW\"\n [attr.y1]=\"tick.y\"\n [attr.y2]=\"tick.y\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n\n @if (!shown) {\n <!-- Every fill before every line, so the lines and their dashes stay on top where\n the fills overlap and the series are still told apart by shape. The opacity is\n the stylesheet's, from `--wr-line-chart-area-opacity`. `data-wr-series` is the\n series' row in the legend, which the shared hover dims by. -->\n @for (area of areas(); track area.key) {\n <path\n class=\"wr-line-chart__area\"\n [attr.d]=\"area.d\"\n [attr.fill]=\"area.color\"\n [attr.data-wr-series]=\"area.series\"\n stroke=\"none\"\n />\n }\n\n <!-- By position, not by label: two series may share one, and a duplicate key\n makes Angular re-create rows it cannot tell apart. Each is drawn at its\n plotted values, which under `stacked` are the tops of its band. Every path is\n built once per data change (`drawn`), so hovering rebuilds none of them. The\n width is the stylesheet's, from `--wr-line-chart-line-width`. -->\n @for (s of drawn(); track s.index) {\n <path\n class=\"wr-line-chart__line\"\n [attr.d]=\"s.d\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n [attr.stroke-dasharray]=\"s.dash || null\"\n [attr.data-wr-series]=\"s.index\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n <!-- Every dot of the series in one path, a subpath each, so a long series costs\n one element rather than one per point. A hole in the data gets no dot. A dot\n is a zero-length line with a round cap and a non-scaling stroke, which stays\n a circle however the drawing stretches; a `<circle>` scaled with it, into\n a 3 × 5px oval on a phone and a 9 × 5px one at 1920px. Its size is the\n stylesheet's, from `--wr-line-chart-dot-size`. -->\n @if (s.dots) {\n <path\n class=\"wr-line-chart__dot\"\n [attr.d]=\"s.dots\"\n fill=\"none\"\n [attr.stroke]=\"s.color\"\n [attr.data-wr-series]=\"s.index\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n }\n\n @if (hovered !== null && hoverPoints().length > 0) {\n <line\n class=\"wr-line-chart__crosshair\"\n [attr.x1]=\"pointX(hovered)\"\n [attr.x2]=\"pointX(hovered)\"\n y1=\"0\"\n [attr.y2]=\"vbH\"\n vector-effect=\"non-scaling-stroke\"\n />\n <!-- A marker in the series' colour inside a ring of the surface, drawn the way a\n dot is and for the same reason: the ring first, a wider stroke under the\n marker's. The ring's colour is the stylesheet's, from\n `--wr-line-chart-hover-center`. -->\n @for (p of hoverPoints(); track p.index) {\n <path\n class=\"wr-line-chart__hover-dot-ring\"\n [attr.d]=\"dotPath(p.x, p.y)\"\n fill=\"none\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n <path\n class=\"wr-line-chart__hover-dot\"\n [attr.d]=\"dotPath(p.x, p.y)\"\n fill=\"none\"\n [attr.stroke]=\"p.color\"\n stroke-linecap=\"round\"\n vector-effect=\"non-scaling-stroke\"\n />\n }\n }\n </svg>\n </div>\n\n @if (shown) {\n <!-- Empty, loading or failed: the message, over the grid and the axis the chart keeps.\n Beside the plot, in its grid cell, and not inside it: the plot is an `img`, which\n makes everything it holds presentational, and the message is a live region. -->\n <wr-chart-state [kind]=\"shown.kind\" [label]=\"shown.label\" />\n }\n\n @if (xLabels().length > 0) {\n <!-- The strip is as wide as the plot, and hands the stylesheet the distance between\n two printed labels; each label hands it the x of the point it names. Both are\n percentages of the drawing's width, so they track the drawing at any size: the\n stylesheet centres a label on its point and ellipsises it past its slot. Laying the\n labels out as equal centred flex slots instead is bar-chart geometry: only the\n middle label landed on its dot, and the outer ones sat up to half a column away.\n The hidden copy of the longest few labels, a line each, is what the room they\n need is measured against: it is as wide as the widest of them. -->\n <div class=\"wr-line-chart__x-labels\" [style.--wr-line-chart-x-slot]=\"xSlot()\">\n <span #probe class=\"wr-line-chart__x-probe\" aria-hidden=\"true\">{{ probeText() }}</span>\n @for (tick of xAxis().ticks; track tick.index) {\n <span class=\"wr-line-chart__x-label\" [style.--wr-line-chart-x]=\"tick.x\">{{ tick.label }}</span>\n }\n </div>\n }\n</div>\n\n@if (legendShown() && !legendFirst()) {\n <ng-container [ngTemplateOutlet]=\"legend\" />\n}\n\n@if (dataTable() && !shown) {\n <!-- The figures for a screen reader, beside the plot's `img` and never inside it:\n `img` makes everything it holds presentational. Clipped to nothing by its own\n stylesheet, so it takes no room and draws nothing. -->\n <wr-chart-table [data]=\"tableData()\" />\n}\n"
|
|
626
801
|
}]
|
|
627
802
|
}],
|
|
628
803
|
ctorParameters: () => [],
|
|
@@ -675,6 +850,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
675
850
|
required: false
|
|
676
851
|
}]
|
|
677
852
|
}],
|
|
853
|
+
showAxis: [{
|
|
854
|
+
type: i0.Input,
|
|
855
|
+
args: [{
|
|
856
|
+
isSignal: true,
|
|
857
|
+
alias: "showAxis",
|
|
858
|
+
required: false
|
|
859
|
+
}]
|
|
860
|
+
}],
|
|
678
861
|
showLegend: [{
|
|
679
862
|
type: i0.Input,
|
|
680
863
|
args: [{
|
|
@@ -683,6 +866,54 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
683
866
|
required: false
|
|
684
867
|
}]
|
|
685
868
|
}],
|
|
869
|
+
legendPosition: [{
|
|
870
|
+
type: i0.Input,
|
|
871
|
+
args: [{
|
|
872
|
+
isSignal: true,
|
|
873
|
+
alias: "legendPosition",
|
|
874
|
+
required: false
|
|
875
|
+
}]
|
|
876
|
+
}],
|
|
877
|
+
loading: [{
|
|
878
|
+
type: i0.Input,
|
|
879
|
+
args: [{
|
|
880
|
+
isSignal: true,
|
|
881
|
+
alias: "loading",
|
|
882
|
+
required: false
|
|
883
|
+
}]
|
|
884
|
+
}],
|
|
885
|
+
error: [{
|
|
886
|
+
type: i0.Input,
|
|
887
|
+
args: [{
|
|
888
|
+
isSignal: true,
|
|
889
|
+
alias: "error",
|
|
890
|
+
required: false
|
|
891
|
+
}]
|
|
892
|
+
}],
|
|
893
|
+
emptyLabel: [{
|
|
894
|
+
type: i0.Input,
|
|
895
|
+
args: [{
|
|
896
|
+
isSignal: true,
|
|
897
|
+
alias: "emptyLabel",
|
|
898
|
+
required: false
|
|
899
|
+
}]
|
|
900
|
+
}],
|
|
901
|
+
loadingLabel: [{
|
|
902
|
+
type: i0.Input,
|
|
903
|
+
args: [{
|
|
904
|
+
isSignal: true,
|
|
905
|
+
alias: "loadingLabel",
|
|
906
|
+
required: false
|
|
907
|
+
}]
|
|
908
|
+
}],
|
|
909
|
+
errorLabel: [{
|
|
910
|
+
type: i0.Input,
|
|
911
|
+
args: [{
|
|
912
|
+
isSignal: true,
|
|
913
|
+
alias: "errorLabel",
|
|
914
|
+
required: false
|
|
915
|
+
}]
|
|
916
|
+
}],
|
|
686
917
|
toggleableLegend: [{
|
|
687
918
|
type: i0.Input,
|
|
688
919
|
args: [{
|
|
@@ -710,6 +941,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
710
941
|
required: false
|
|
711
942
|
}]
|
|
712
943
|
}],
|
|
944
|
+
decimate: [{
|
|
945
|
+
type: i0.Input,
|
|
946
|
+
args: [{
|
|
947
|
+
isSignal: true,
|
|
948
|
+
alias: "decimate",
|
|
949
|
+
required: false
|
|
950
|
+
}]
|
|
951
|
+
}],
|
|
713
952
|
showArea: [{
|
|
714
953
|
type: i0.Input,
|
|
715
954
|
args: [{
|
|
@@ -753,10 +992,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
753
992
|
probe: [{
|
|
754
993
|
type: i0.ViewChild,
|
|
755
994
|
args: ["probe", { isSignal: true }]
|
|
756
|
-
}],
|
|
757
|
-
tooltipEl: [{
|
|
758
|
-
type: i0.ViewChild,
|
|
759
|
-
args: ["tooltip", { isSignal: true }]
|
|
760
995
|
}]
|
|
761
996
|
}
|
|
762
997
|
});
|