@pioneer-code/pioneer-charts 22.2.28 → 22.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@pioneer-code/pioneer-charts)
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
|
|
9
|
-
Pioneer Charts is an Angular library for building beautiful, customizable, and responsive data visualizations. It leverages [D3.js](https://d3js.org/) for rendering and provides bar, line/area, plot, pie, donut, dot plot and
|
|
9
|
+
Pioneer Charts is an Angular library for building beautiful, customizable, and responsive data visualizations. It leverages [D3.js](https://d3js.org/) for rendering and provides bar, line/area, plot, pie, donut, dot plot, proximity and state timeline charts, plus a legend component.
|
|
10
10
|
|
|
11
11
|
## Documentation
|
|
12
12
|
|
|
@@ -26,6 +26,7 @@ Each chart has its own page with live examples, markup and its full configuratio
|
|
|
26
26
|
- [Angular Donut Chart](https://pioneercharts.com/docs/components/charts/donut-chart) - with a total or any label in its center
|
|
27
27
|
- [Angular Dot Plot Chart](https://pioneercharts.com/docs/components/charts/dot-plot-chart) - values stacked into columns along one axis
|
|
28
28
|
- [Angular Proximity Chart](https://pioneercharts.com/docs/components/charts/proximity-chart) - one item in the middle, its closest matches around it
|
|
29
|
+
- [Angular State Timeline Chart](https://pioneercharts.com/docs/components/charts/state-timeline) - a row of days or hours for each service or device, colored by its worst state
|
|
29
30
|
- [Angular Sparklines](https://pioneercharts.com/docs/components/charts/sparkline) - small, axis-free trend lines for tables and dashboard tiles
|
|
30
31
|
- [Legend](https://pioneercharts.com/docs/components/charts/legend) - a chart's series, with click events
|
|
31
32
|
|
|
@@ -37,7 +38,7 @@ Or see them all together on the [chart examples](https://pioneercharts.com/chart
|
|
|
37
38
|
|
|
38
39
|
## Features
|
|
39
40
|
|
|
40
|
-
- Bar (vertical and horizontal), line, area, plot, pie, donut, dot plot and
|
|
41
|
+
- Bar (vertical and horizontal), line, area, plot, pie, donut, dot plot, proximity and state timeline charts, plus a legend.
|
|
41
42
|
- Beautiful default theme, customizable via CSS or by overriding the source Sass variables ([theming guide](https://pioneercharts.com/docs/guides/theme)).
|
|
42
43
|
- Strongly typed configuration contracts.
|
|
43
44
|
- Outputs for user interaction (bar, slice, dot, and legend clicks), plus the size a dot plot fitted its marks to.
|
|
@@ -5979,6 +5979,351 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImpor
|
|
|
5979
5979
|
// The shared <pcac-pie-donut-chart> and its PcacPieDonutChartConfig stay internal, like the
|
|
5980
5980
|
// line/area/plot charts' base: consumers use the pie and donut wrappers and their configs.
|
|
5981
5981
|
|
|
5982
|
+
/** One state a period can be in, such as OK or Error: its key, its name and its color. */
|
|
5983
|
+
class PcacStateTimelineState {
|
|
5984
|
+
/** The state's key, matching the keys in a period's `data`. */
|
|
5985
|
+
key = '';
|
|
5986
|
+
/** The state's name in the tooltip and for screen readers. Defaults to its `key`. */
|
|
5987
|
+
label;
|
|
5988
|
+
/**
|
|
5989
|
+
* Any CSS color. Defaults to the theme: pale green for the first state, strong red for the last,
|
|
5990
|
+
* and amber for any in between. Choose colors that differ in lightness so people with color
|
|
5991
|
+
* blindness can tell them apart.
|
|
5992
|
+
*/
|
|
5993
|
+
color;
|
|
5994
|
+
}
|
|
5995
|
+
/**
|
|
5996
|
+
* A state timeline shows how something's status changed over time. Each row is one thing you're
|
|
5997
|
+
* tracking, like a service or a device, split into periods such as days or hours. Each period is
|
|
5998
|
+
* colored by the worst state it reached, so one hour of Error in an otherwise good day still shows.
|
|
5999
|
+
*
|
|
6000
|
+
* `data` is a list of rows. A row's `key` is its name, shown to its left unless `rowLabels` is
|
|
6001
|
+
* false, and its `data` is its periods, oldest first. Each period has:
|
|
6002
|
+
* - `key`: its name, shown in the tooltip and read by screen readers (`'Fri, Nov 20'`).
|
|
6003
|
+
* - `value`: how long it is, in any unit. Leave it out and the length is the total of its states.
|
|
6004
|
+
* - `data`: how much time it spent in each state, in the same unit, keyed by the state's `key`.
|
|
6005
|
+
*
|
|
6006
|
+
* Any time not covered by a state is unknown: a partly unknown period is striped, and an entirely
|
|
6007
|
+
* unknown one is plain gray. The color is lighter when the worst state lasted a short time and
|
|
6008
|
+
* full strength when it lasted all of the period's known time. Every period in a row is the same
|
|
6009
|
+
* width. A row or period with `hide` set is left out.
|
|
6010
|
+
*/
|
|
6011
|
+
class PcacStateTimelineConfig extends PcacChartConfig {
|
|
6012
|
+
/**
|
|
6013
|
+
* Height in pixels, split evenly between the rows with 4px between them. Default 24, which fits
|
|
6014
|
+
* one row; set a larger height for more rows.
|
|
6015
|
+
*/
|
|
6016
|
+
height = 24;
|
|
6017
|
+
/** The states a period can be in, from least to most severe. Each period shows its worst. */
|
|
6018
|
+
states = [];
|
|
6019
|
+
/**
|
|
6020
|
+
* Space between periods, in px. Default 2. It shrinks to 1px, then to none, when periods get
|
|
6021
|
+
* too narrow.
|
|
6022
|
+
*/
|
|
6023
|
+
gap = 2;
|
|
6024
|
+
/** Show each row's name to its left. Default true. */
|
|
6025
|
+
rowLabels = true;
|
|
6026
|
+
}
|
|
6027
|
+
|
|
6028
|
+
/** A time as a number to add up, or 0 when it isn't a positive one. */
|
|
6029
|
+
function time(value) {
|
|
6030
|
+
const n = typeof value === 'number' ? value : typeof value === 'string' && value.trim() !== '' ? Number(value) : NaN;
|
|
6031
|
+
return Number.isFinite(n) && n > 0 ? n : 0;
|
|
6032
|
+
}
|
|
6033
|
+
/** The time the period spent in each of `states`, in their order. */
|
|
6034
|
+
function stateTimes(period, states) {
|
|
6035
|
+
return states.map((state) => (period.data ?? []).filter((d) => d.key === state.key).reduce((sum, d) => sum + time(d.value), 0));
|
|
6036
|
+
}
|
|
6037
|
+
/**
|
|
6038
|
+
* The worst state the period was in, by the order of `states`, and its share of what's known of
|
|
6039
|
+
* the period. Time in a state not among `states` is unknown, as is any of the period's length
|
|
6040
|
+
* (`value`) the states don't cover; with no length, all of it is known.
|
|
6041
|
+
*/
|
|
6042
|
+
function periodState(period, states) {
|
|
6043
|
+
const times = stateTimes(period, states);
|
|
6044
|
+
const known = times.reduce((sum, t) => sum + t, 0);
|
|
6045
|
+
// Never less than what's known: a clock's rounding can give a little more than the length
|
|
6046
|
+
const length = Math.max(time(period.value), known);
|
|
6047
|
+
if (known === 0) {
|
|
6048
|
+
return { state: null, share: 0, unknownShare: 1 };
|
|
6049
|
+
}
|
|
6050
|
+
let worst = times.length - 1;
|
|
6051
|
+
while (times[worst] === 0) {
|
|
6052
|
+
worst--;
|
|
6053
|
+
}
|
|
6054
|
+
return { state: worst, share: times[worst] / known, unknownShare: (length - known) / length };
|
|
6055
|
+
}
|
|
6056
|
+
/** Every shown row's shown periods, in order, each with what it was in. */
|
|
6057
|
+
function placePeriods(rows, states) {
|
|
6058
|
+
const placed = [];
|
|
6059
|
+
rows.filter((row) => !row.hide).forEach((row, rowIndex) => {
|
|
6060
|
+
(row.data ?? []).filter((period) => !period.hide).forEach((data, index) => {
|
|
6061
|
+
placed.push({ data, row, rowIndex, index, ...periodState(data, states) });
|
|
6062
|
+
});
|
|
6063
|
+
});
|
|
6064
|
+
return placed;
|
|
6065
|
+
}
|
|
6066
|
+
/**
|
|
6067
|
+
* The space between `count` periods across `width` px: `gap` while it takes no more than a quarter
|
|
6068
|
+
* of each period's room, then 1px, then none when even 1px would leave a period under a pixel.
|
|
6069
|
+
*/
|
|
6070
|
+
function periodGap(width, count, gap) {
|
|
6071
|
+
if (count <= 0 || gap <= 0) {
|
|
6072
|
+
return 0;
|
|
6073
|
+
}
|
|
6074
|
+
const room = width / count;
|
|
6075
|
+
if (gap <= room / 4) {
|
|
6076
|
+
return gap;
|
|
6077
|
+
}
|
|
6078
|
+
return room - 1 >= 1 ? 1 : 0;
|
|
6079
|
+
}
|
|
6080
|
+
/**
|
|
6081
|
+
* What a period was in, in words: `'Error 25%, OK 75%'`, each state it was in worst first with its
|
|
6082
|
+
* share of the period, then the share unknown; `'unknown'` when nothing is known of it.
|
|
6083
|
+
*/
|
|
6084
|
+
function periodSummary(period, states) {
|
|
6085
|
+
if (period.state === null) {
|
|
6086
|
+
return 'unknown';
|
|
6087
|
+
}
|
|
6088
|
+
const times = stateTimes(period.data, states);
|
|
6089
|
+
const length = Math.max(time(period.data.value), times.reduce((sum, t) => sum + t, 0));
|
|
6090
|
+
const parts = states
|
|
6091
|
+
.map((state, i) => ({ name: state.label ?? state.key, share: times[i] / length }))
|
|
6092
|
+
.filter((part) => part.share > 0)
|
|
6093
|
+
.reverse();
|
|
6094
|
+
if (period.unknownShare > 0) {
|
|
6095
|
+
parts.push({ name: 'unknown', share: period.unknownShare });
|
|
6096
|
+
}
|
|
6097
|
+
const percents = wholePercents(parts.map((part) => part.share));
|
|
6098
|
+
return parts.map((part, i) => `${part.name} ${percents[i] === 0 ? '<1' : percents[i]}%`).join(', ');
|
|
6099
|
+
}
|
|
6100
|
+
/**
|
|
6101
|
+
* Shares that add up to 1 as whole percents that add up to 100: each rounded down, then the
|
|
6102
|
+
* percents left over given one each to the shares nearest their next percent (on a tie, the
|
|
6103
|
+
* earlier: the worse state). Rounded each on its own, 12.5% and 87.5% would read 13% and 88%.
|
|
6104
|
+
*/
|
|
6105
|
+
function wholePercents(shares) {
|
|
6106
|
+
const percents = shares.map((share) => Math.floor(share * 100));
|
|
6107
|
+
const left = 100 - percents.reduce((sum, p) => sum + p, 0);
|
|
6108
|
+
shares
|
|
6109
|
+
.map((share, i) => ({ i, remainder: share * 100 - percents[i] }))
|
|
6110
|
+
.sort((a, b) => b.remainder - a.remainder || a.i - b.i)
|
|
6111
|
+
.slice(0, left)
|
|
6112
|
+
.forEach(({ i }) => percents[i]++);
|
|
6113
|
+
return percents;
|
|
6114
|
+
}
|
|
6115
|
+
/** The period's name and what it was in, for screen readers: `'Nov 20: Error 25%, OK 75%'`. */
|
|
6116
|
+
function periodLabel(period, states) {
|
|
6117
|
+
return `${period.data.key}: ${periodSummary(period, states)}`;
|
|
6118
|
+
}
|
|
6119
|
+
|
|
6120
|
+
/** Room kept round the plot for a focused period's ring (2px, 2px out), in px. */
|
|
6121
|
+
const FOCUS_ROOM = 4;
|
|
6122
|
+
/** Space between rows, in px. */
|
|
6123
|
+
const ROW_GAP = 4;
|
|
6124
|
+
/** Space between a row's label and its periods, in px. */
|
|
6125
|
+
const LABEL_GAP = 8;
|
|
6126
|
+
/** The most of the chart's width the row labels take; a longer one is cut off at the left edge. */
|
|
6127
|
+
const MAX_LABEL_SHARE = 0.4;
|
|
6128
|
+
/** A label's width where text can't be measured (no layout), per character, in px: 11px text. */
|
|
6129
|
+
const LABEL_CHAR_WIDTH = 6.5;
|
|
6130
|
+
/** Each chart's own stripes pattern, by a number no other chart on the page has. */
|
|
6131
|
+
let nextStripesId = 0;
|
|
6132
|
+
/**
|
|
6133
|
+
* Provided per-component (see PcacStateTimeline's `providers`), like every builder that extends
|
|
6134
|
+
* PcacChart: it holds per-chart-instance state, which a root singleton would share between charts.
|
|
6135
|
+
*/
|
|
6136
|
+
class StateTimelineBuilder extends PcacChart {
|
|
6137
|
+
periodClickedSource = new Subject();
|
|
6138
|
+
periodClicked$ = this.periodClickedSource.asObservable();
|
|
6139
|
+
chartTypeLabel = 'State timeline';
|
|
6140
|
+
stripesId = `pcac-state-stripes-${nextStripesId++}`;
|
|
6141
|
+
buildChart(chartElm, config) {
|
|
6142
|
+
this.hideTooltip();
|
|
6143
|
+
const states = config?.states ?? [];
|
|
6144
|
+
const placed = placePeriods(config?.data ?? [], states);
|
|
6145
|
+
if (!placed.length) {
|
|
6146
|
+
this.clearChart(chartElm);
|
|
6147
|
+
return;
|
|
6148
|
+
}
|
|
6149
|
+
const rows = config.data.filter((row) => !row.hide);
|
|
6150
|
+
const labelRoom = (config.rowLabels ?? true) ? this.labelRoom(chartElm, rows) : 0;
|
|
6151
|
+
this.margin = { top: FOCUS_ROOM, right: FOCUS_ROOM, bottom: FOCUS_ROOM, left: FOCUS_ROOM + labelRoom };
|
|
6152
|
+
if (!this.initializeChartState(chartElm, config)) {
|
|
6153
|
+
return;
|
|
6154
|
+
}
|
|
6155
|
+
this.buildContainer(chartElm);
|
|
6156
|
+
this.drawStripes();
|
|
6157
|
+
const rowHeight = Math.max(1, (this.height - ROW_GAP * (rows.length - 1)) / rows.length);
|
|
6158
|
+
const gap = config.gap ?? new PcacStateTimelineConfig().gap;
|
|
6159
|
+
// Each row shares the width between its own periods
|
|
6160
|
+
const counts = rows.map((_, i) => placed.filter((p) => p.rowIndex === i).length);
|
|
6161
|
+
const layout = (p) => {
|
|
6162
|
+
const count = counts[p.rowIndex];
|
|
6163
|
+
const space = periodGap(this.width, count, gap);
|
|
6164
|
+
const width = (this.width - space * (count - 1)) / count;
|
|
6165
|
+
return { x: p.index * (width + space), y: p.rowIndex * (rowHeight + ROW_GAP), width };
|
|
6166
|
+
};
|
|
6167
|
+
if (labelRoom) {
|
|
6168
|
+
this.svg.append('g')
|
|
6169
|
+
.attr('class', 'pcac-state-row-labels')
|
|
6170
|
+
.attr('aria-hidden', 'true')
|
|
6171
|
+
.selectAll('text')
|
|
6172
|
+
.data(rows)
|
|
6173
|
+
.enter().append('text')
|
|
6174
|
+
.attr('class', 'pcac-state-row-label')
|
|
6175
|
+
.attr('x', -LABEL_GAP)
|
|
6176
|
+
.attr('y', (_, i) => i * (rowHeight + ROW_GAP) + rowHeight / 2)
|
|
6177
|
+
.attr('text-anchor', 'end')
|
|
6178
|
+
.attr('dominant-baseline', 'middle')
|
|
6179
|
+
.text((row) => String(row.key ?? ''));
|
|
6180
|
+
}
|
|
6181
|
+
this.drawPeriods(placed, config, rowHeight, layout);
|
|
6182
|
+
this.restoreTabStop(chartElm);
|
|
6183
|
+
}
|
|
6184
|
+
/** Room for the longest row label and its gap, never more than MAX_LABEL_SHARE of the chart. */
|
|
6185
|
+
labelRoom(chartElm, rows) {
|
|
6186
|
+
const svg = chartElm.nativeElement;
|
|
6187
|
+
const container = svg.parentNode;
|
|
6188
|
+
const widths = rows.map((row) => {
|
|
6189
|
+
const text = String(row.key ?? '');
|
|
6190
|
+
const probe = select(svg).append('text').attr('class', 'pcac-state-row-label').text(text);
|
|
6191
|
+
const node = probe.node();
|
|
6192
|
+
const width = typeof node.getComputedTextLength === 'function' ? node.getComputedTextLength() : text.length * LABEL_CHAR_WIDTH;
|
|
6193
|
+
probe.remove();
|
|
6194
|
+
return width;
|
|
6195
|
+
});
|
|
6196
|
+
const longest = Math.max(0, ...widths);
|
|
6197
|
+
return longest ? Math.min(longest + LABEL_GAP, (container?.clientWidth ?? 0) * MAX_LABEL_SHARE) : 0;
|
|
6198
|
+
}
|
|
6199
|
+
/** The stripes laid over a period part of which is unknown, this chart's own. */
|
|
6200
|
+
drawStripes() {
|
|
6201
|
+
this.svg.append('defs')
|
|
6202
|
+
.append('pattern')
|
|
6203
|
+
.attr('id', this.stripesId)
|
|
6204
|
+
.attr('patternUnits', 'userSpaceOnUse')
|
|
6205
|
+
.attr('width', 6)
|
|
6206
|
+
.attr('height', 6)
|
|
6207
|
+
.attr('patternTransform', 'rotate(45)')
|
|
6208
|
+
.append('rect')
|
|
6209
|
+
.attr('class', 'pcac-state-stripe')
|
|
6210
|
+
.attr('width', 3)
|
|
6211
|
+
.attr('height', 6);
|
|
6212
|
+
}
|
|
6213
|
+
drawPeriods(placed, config, rowHeight, layout) {
|
|
6214
|
+
const self = this;
|
|
6215
|
+
const states = config.states;
|
|
6216
|
+
const last = states.length - 1;
|
|
6217
|
+
const role = (p) => p.state === null ? 'unknown'
|
|
6218
|
+
: p.state === 0 ? 'ok'
|
|
6219
|
+
: p.state === last ? 'error'
|
|
6220
|
+
: 'warning';
|
|
6221
|
+
// The default tooltip shows the period's name over what it was in; a template gets the period itself
|
|
6222
|
+
const tooltipData = (p) => this.tooltipTemplate() ? p.data : { ...p.data, value: periodSummary(p, states) };
|
|
6223
|
+
const tooltipOptions = (p, anchor) => ({
|
|
6224
|
+
index: p.index,
|
|
6225
|
+
parent: p.row,
|
|
6226
|
+
parentIndex: p.rowIndex,
|
|
6227
|
+
anchor,
|
|
6228
|
+
});
|
|
6229
|
+
const fillOf = (group) => select(group).select('.pcac-state-fill').node();
|
|
6230
|
+
const highlight = (group, on) => select(group).classed('is-active', on);
|
|
6231
|
+
const groups = this.svg.append('g')
|
|
6232
|
+
.attr('class', 'pcac-state-periods')
|
|
6233
|
+
.selectAll('g')
|
|
6234
|
+
.data(placed)
|
|
6235
|
+
.enter().append('g')
|
|
6236
|
+
.attr('class', (p) => `pcac-state-period pcac-state-${role(p)}`)
|
|
6237
|
+
.style('--pcac-state-share', (p) => String(Math.round(p.share * 1000) / 1000))
|
|
6238
|
+
.style('--pcac-state-color', (p) => (p.state === null ? null : states[p.state].color) ?? null)
|
|
6239
|
+
.on('mouseover', function (event, p) {
|
|
6240
|
+
highlight(this, true);
|
|
6241
|
+
self.showTooltip(event, tooltipData(p), tooltipOptions(p, fillOf(this)));
|
|
6242
|
+
})
|
|
6243
|
+
.on('mouseout', function () {
|
|
6244
|
+
highlight(this, false);
|
|
6245
|
+
self.hideTooltip();
|
|
6246
|
+
})
|
|
6247
|
+
.on('click', (_event, p) => this.periodClickedSource.next(p.data));
|
|
6248
|
+
makeMarksAccessible(groups, {
|
|
6249
|
+
label: (p) => {
|
|
6250
|
+
const name = p.row.key === null || p.row.key === undefined || p.row.key === '' ? '' : `${p.row.key}, `;
|
|
6251
|
+
return `${name}${periodLabel(p, states)}`;
|
|
6252
|
+
},
|
|
6253
|
+
activate: (p) => this.periodClickedSource.next(p.data),
|
|
6254
|
+
focus: (group, p) => {
|
|
6255
|
+
highlight(group, true);
|
|
6256
|
+
this.showMarkTooltip(group, tooltipData(p), tooltipOptions(p, fillOf(group)));
|
|
6257
|
+
},
|
|
6258
|
+
blur: (group) => {
|
|
6259
|
+
highlight(group, false);
|
|
6260
|
+
this.hideMarkTooltip(group);
|
|
6261
|
+
},
|
|
6262
|
+
});
|
|
6263
|
+
const box = (selection) => selection
|
|
6264
|
+
.attr('x', (p) => layout(p).x)
|
|
6265
|
+
.attr('y', (p) => layout(p).y)
|
|
6266
|
+
.attr('width', (p) => layout(p).width)
|
|
6267
|
+
.attr('height', rowHeight)
|
|
6268
|
+
.attr('rx', 2);
|
|
6269
|
+
box(groups.append('rect').attr('class', 'pcac-state-fill'));
|
|
6270
|
+
box(groups.filter((p) => p.state !== null && p.unknownShare > 0)
|
|
6271
|
+
.append('rect')
|
|
6272
|
+
.attr('class', 'pcac-state-stripes')
|
|
6273
|
+
.attr('fill', `url(#${this.stripesId})`));
|
|
6274
|
+
groups.attr('opacity', 0)
|
|
6275
|
+
.transition()
|
|
6276
|
+
.duration(this.transitionService.getTransitionDuration() / 2)
|
|
6277
|
+
.attr('opacity', 1);
|
|
6278
|
+
}
|
|
6279
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: StateTimelineBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
6280
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: StateTimelineBuilder });
|
|
6281
|
+
}
|
|
6282
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: StateTimelineBuilder, decorators: [{
|
|
6283
|
+
type: Injectable
|
|
6284
|
+
}] });
|
|
6285
|
+
|
|
6286
|
+
/** A state timeline: rows of periods, each colored by the worst state it was in (see PcacStateTimelineConfig). */
|
|
6287
|
+
class PcacStateTimeline {
|
|
6288
|
+
chartBuilder = inject(StateTimelineBuilder);
|
|
6289
|
+
config = input.required(/* @ts-ignore */
|
|
6290
|
+
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
6291
|
+
chartElm = viewChild.required('chart', /* @ts-ignore */
|
|
6292
|
+
...(ngDevMode ? [{ debugName: "chartElm" }] : /* istanbul ignore next */ []));
|
|
6293
|
+
/** A period clicked, or Enter or Space on one focused: the period itself, from its row's `data`. */
|
|
6294
|
+
periodClicked = outputFromObservable(this.chartBuilder.periodClicked$);
|
|
6295
|
+
/**
|
|
6296
|
+
* Optional consumer `<ng-template pcacTooltip>`, replacing the default tooltip (see
|
|
6297
|
+
* PcacTooltipDirective): its `$implicit` is the period, `parent` its row, `index` its place in
|
|
6298
|
+
* the row and `parentIndex` the row's among those drawn.
|
|
6299
|
+
*/
|
|
6300
|
+
tooltipTemplate = contentChild(PcacTooltipDirective, /* @ts-ignore */
|
|
6301
|
+
...(ngDevMode ? [{ debugName: "tooltipTemplate" }] : /* istanbul ignore next */ []));
|
|
6302
|
+
constructor() {
|
|
6303
|
+
effect(() => this.buildChart());
|
|
6304
|
+
// A getter, so the builder reads the query at hover time rather than in the effect above.
|
|
6305
|
+
this.chartBuilder.tooltipTemplate = () => this.tooltipTemplate()?.templateRef;
|
|
6306
|
+
inject(PcacChartResizeService).observe(this.chartElm, () => {
|
|
6307
|
+
if (this.chartBuilder.containerSizeChanged(this.chartElm())) {
|
|
6308
|
+
this.buildChart();
|
|
6309
|
+
}
|
|
6310
|
+
});
|
|
6311
|
+
}
|
|
6312
|
+
buildChart() {
|
|
6313
|
+
const config = this.config();
|
|
6314
|
+
// Handed over even when empty: the builder clears what it last drew rather than leaving it.
|
|
6315
|
+
if (config) {
|
|
6316
|
+
this.chartBuilder.buildChart(this.chartElm(), config);
|
|
6317
|
+
}
|
|
6318
|
+
}
|
|
6319
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: PcacStateTimeline, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
6320
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.6", type: PcacStateTimeline, isStandalone: true, selector: "pcac-state-timeline", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { periodClicked: "periodClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, providers: [StateTimelineBuilder], queries: [{ propertyName: "tooltipTemplate", first: true, predicate: PcacTooltipDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-state-timeline\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-state-timeline svg{width:100%;display:block}.pcac-state-timeline .pcac-state-period{cursor:pointer}.pcac-state-timeline .pcac-state-ok{--pcac-state-theme-color: var(--pcac-state-timeline-ok-color, #98c9b2)}.pcac-state-timeline .pcac-state-warning{--pcac-state-theme-color: var(--pcac-state-timeline-warning-color, #d97706)}.pcac-state-timeline .pcac-state-error{--pcac-state-theme-color: var(--pcac-state-timeline-error-color, #bb2d3b)}.pcac-state-timeline .pcac-state-fill{fill:color-mix(in srgb,var(--pcac-state-color, var(--pcac-state-theme-color)) calc(75% + var(--pcac-state-share, 1) * 25%),var(--pcac-state-timeline-background-color, #fff))}.pcac-state-timeline .pcac-state-unknown .pcac-state-fill{fill:var(--pcac-state-timeline-unknown-color, #e9ecef)}.pcac-state-timeline .pcac-state-stripe{fill:var(--pcac-state-timeline-unknown-color, #e9ecef);fill-opacity:.85}.pcac-state-timeline .pcac-state-period.is-active .pcac-state-fill{stroke:currentColor;stroke-width:1.5px}.pcac-state-timeline .pcac-state-row-label{font-size:11px;fill:var(--pcac-state-timeline-row-label-color, #495057)}pcac-state-timeline.pcac-height-full{display:block;height:100%}pcac-state-timeline.pcac-height-full .pcac-state-timeline{height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
6321
|
+
}
|
|
6322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: PcacStateTimeline, decorators: [{
|
|
6323
|
+
type: Component,
|
|
6324
|
+
args: [{ selector: 'pcac-state-timeline', host: { '[class.pcac-height-full]': 'config().heightFull' }, encapsulation: ViewEncapsulation.None, providers: [StateTimelineBuilder], template: "<section class=\"pcac-state-timeline\">\n <svg #chart></svg>\n</section>\n", styles: [".pcac-state-timeline svg{width:100%;display:block}.pcac-state-timeline .pcac-state-period{cursor:pointer}.pcac-state-timeline .pcac-state-ok{--pcac-state-theme-color: var(--pcac-state-timeline-ok-color, #98c9b2)}.pcac-state-timeline .pcac-state-warning{--pcac-state-theme-color: var(--pcac-state-timeline-warning-color, #d97706)}.pcac-state-timeline .pcac-state-error{--pcac-state-theme-color: var(--pcac-state-timeline-error-color, #bb2d3b)}.pcac-state-timeline .pcac-state-fill{fill:color-mix(in srgb,var(--pcac-state-color, var(--pcac-state-theme-color)) calc(75% + var(--pcac-state-share, 1) * 25%),var(--pcac-state-timeline-background-color, #fff))}.pcac-state-timeline .pcac-state-unknown .pcac-state-fill{fill:var(--pcac-state-timeline-unknown-color, #e9ecef)}.pcac-state-timeline .pcac-state-stripe{fill:var(--pcac-state-timeline-unknown-color, #e9ecef);fill-opacity:.85}.pcac-state-timeline .pcac-state-period.is-active .pcac-state-fill{stroke:currentColor;stroke-width:1.5px}.pcac-state-timeline .pcac-state-row-label{font-size:11px;fill:var(--pcac-state-timeline-row-label-color, #495057)}pcac-state-timeline.pcac-height-full{display:block;height:100%}pcac-state-timeline.pcac-height-full .pcac-state-timeline{height:100%}\n"] }]
|
|
6325
|
+
}], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], chartElm: [{ type: i0.ViewChild, args: ['chart', { isSignal: true }] }], periodClicked: [{ type: i0.Output, args: ["periodClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
6326
|
+
|
|
5982
6327
|
/*
|
|
5983
6328
|
* Public API Surface of pioneer-charts
|
|
5984
6329
|
*/
|
|
@@ -5987,5 +6332,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImpor
|
|
|
5987
6332
|
* Generated bundle index. Do not edit.
|
|
5988
6333
|
*/
|
|
5989
6334
|
|
|
5990
|
-
export { PcacAreaChart, PcacAreaChartConfig, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChart, PcacBarHorizontalChart as PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChart, PcacBarVerticalChart as PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChartConfig, PcacColorService, PcacCornerLabels, PcacData, PcacDataRange, PcacDonutChart, PcacDonutChartConfig, PcacDotPlotChart, PcacDotPlotChartConfig, PcacFormatEnum, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChart, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointGaugeConfig, PcacPointImageConfig, PcacPointRangeConfig, PcacPointRangeShow, PcacPointRangeStyle, PcacProximityChart, PcacProximityChartConfig, PcacRangeBounds, PcacReferenceLine, PcacTooltipDirective };
|
|
6335
|
+
export { PcacAreaChart, PcacAreaChartConfig, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChart, PcacBarHorizontalChart as PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChart, PcacBarVerticalChart as PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChartConfig, PcacColorService, PcacCornerLabels, PcacData, PcacDataRange, PcacDonutChart, PcacDonutChartConfig, PcacDotPlotChart, PcacDotPlotChartConfig, PcacFormatEnum, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChart, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointGaugeConfig, PcacPointImageConfig, PcacPointRangeConfig, PcacPointRangeShow, PcacPointRangeStyle, PcacProximityChart, PcacProximityChartConfig, PcacRangeBounds, PcacReferenceLine, PcacStateTimeline, PcacStateTimelineConfig, PcacStateTimelineState, PcacTooltipDirective };
|
|
5991
6336
|
//# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map
|