@pioneer-code/pioneer-charts 22.2.1 → 22.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -518,7 +518,7 @@ class PcacTooltipBuilder {
|
|
|
518
518
|
* projected `pcacTooltip` template. This only ever renders the default content.
|
|
519
519
|
*/
|
|
520
520
|
showBarTooltip(event, data, valueFormat, keyFormat) {
|
|
521
|
-
this.showTooltip(event, undefined, { $implicit: data, parent: null, isThreshold: false, index: 0, parentIndex: null }, valueFormat, keyFormat);
|
|
521
|
+
this.showTooltip(event, undefined, { $implicit: data, parent: null, isThreshold: false, index: 0, parentIndex: null, coincident: [] }, valueFormat, keyFormat);
|
|
522
522
|
}
|
|
523
523
|
hideTooltip() {
|
|
524
524
|
this.tooltip.style('display', 'none');
|
|
@@ -835,6 +835,7 @@ class PcacChart {
|
|
|
835
835
|
isThreshold: options.isThreshold ?? false,
|
|
836
836
|
index: options.index,
|
|
837
837
|
parentIndex: options.parentIndex ?? null,
|
|
838
|
+
coincident: options.coincident ?? [],
|
|
838
839
|
}, options.valueFormat, options.keyFormat);
|
|
839
840
|
}
|
|
840
841
|
hideTooltip() {
|
|
@@ -1329,6 +1330,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
1329
1330
|
* <div class="my-tooltip">{{ orders[g!][i].customer }}: {{ point.value | number }}</div>
|
|
1330
1331
|
* </ng-template>
|
|
1331
1332
|
* ```
|
|
1333
|
+
*
|
|
1334
|
+
* `coincident` lists the other points at the hovered coordinate, each located the same way:
|
|
1335
|
+
*
|
|
1336
|
+
* ```html
|
|
1337
|
+
* <ng-template pcacTooltip let-point let-others="coincident">
|
|
1338
|
+
* <div class="my-tooltip">
|
|
1339
|
+
* {{ point.key }}, {{ point.value }}
|
|
1340
|
+
* @for (other of others; track other.parentIndex) { <div>Also here: {{ other.parent.key }}</div> }
|
|
1341
|
+
* </div>
|
|
1342
|
+
* </ng-template>
|
|
1343
|
+
* ```
|
|
1332
1344
|
*/
|
|
1333
1345
|
class PcacTooltipDirective {
|
|
1334
1346
|
templateRef = inject(TemplateRef);
|
|
@@ -1929,6 +1941,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
1929
1941
|
type: Injectable
|
|
1930
1942
|
}] });
|
|
1931
1943
|
|
|
1944
|
+
/**
|
|
1945
|
+
* How the plot chart spreads out points that share a coordinate (see
|
|
1946
|
+
* `PcacPlotChartConfig.pointFanOut`). Each group of coincident points is placed evenly around
|
|
1947
|
+
* a ring centered on the shared coordinate, starting at 12 o'clock and going clockwise in data
|
|
1948
|
+
* order (series order, then point order), so every point stays visible and hoverable.
|
|
1949
|
+
*/
|
|
1950
|
+
class PcacPointFanOutConfig {
|
|
1951
|
+
/**
|
|
1952
|
+
* Ring radius in px, the same for every group. When not set, each group gets the smallest
|
|
1953
|
+
* radius at which its neighbours sit `gap` px apart - so a pair barely moves while a group of
|
|
1954
|
+
* five spreads as far as it has to.
|
|
1955
|
+
*/
|
|
1956
|
+
radius;
|
|
1957
|
+
/**
|
|
1958
|
+
* Space between neighbouring points on the ring, in px, when `radius` is not set. Measured
|
|
1959
|
+
* between their image boxes (or hovered dots), not their centers.
|
|
1960
|
+
*/
|
|
1961
|
+
gap = 4;
|
|
1962
|
+
/**
|
|
1963
|
+
* Draw a dot at the shared coordinate - the value the group's points actually have - with a
|
|
1964
|
+
* spoke out to each of them. Styled by the theme's `.fan-out-anchor` / `.fan-out-spoke` rules.
|
|
1965
|
+
*/
|
|
1966
|
+
showAnchor = true;
|
|
1967
|
+
}
|
|
1968
|
+
class PcacPlotChartConfig extends PcacLineAreaChartConfig {
|
|
1969
|
+
/**
|
|
1970
|
+
* Spread points that share a coordinate around it instead of drawing them on top of one
|
|
1971
|
+
* another (where only the last series' point shows, and only it can be hovered). Off when not
|
|
1972
|
+
* set; `{}` turns it on with every `PcacPointFanOutConfig` default. The fanned points keep
|
|
1973
|
+
* their true value in the tooltip, and the hovered point's tooltip context lists the others at
|
|
1974
|
+
* its coordinate in `coincident` (see `PcacTooltipContext`).
|
|
1975
|
+
*
|
|
1976
|
+
* Plot chart only: a line or area chart's points are joined in series order, so moving one
|
|
1977
|
+
* would kink the line.
|
|
1978
|
+
*/
|
|
1979
|
+
pointFanOut;
|
|
1980
|
+
}
|
|
1981
|
+
|
|
1932
1982
|
class PlaChartScales {
|
|
1933
1983
|
x;
|
|
1934
1984
|
y;
|
|
@@ -2023,6 +2073,80 @@ function buildZoomBehavior(width, height, zoomedFn) {
|
|
|
2023
2073
|
.on("zoom", zoomedFn);
|
|
2024
2074
|
}
|
|
2025
2075
|
|
|
2076
|
+
/**
|
|
2077
|
+
* Finds every set of points that share a coordinate across all of the chart's visible series.
|
|
2078
|
+
* Coincidence is decided from the data rather than from scaled pixels, so this can run before
|
|
2079
|
+
* the scales exist (the space the fan-out needs has to be reserved before the plot area, and so
|
|
2080
|
+
* the scales, is sized): two points coincide when they have the same y `value` and the same x
|
|
2081
|
+
* position under `xFormat` - the same numeric `key` (`Decimal`), the same instant (`DateTime`), or
|
|
2082
|
+
* the same index within their series (every other format, which positions by index). Mirrors
|
|
2083
|
+
* `getXFormat()`, which is what actually places them. Hidden series and points without a value
|
|
2084
|
+
* are left out, as they aren't drawn.
|
|
2085
|
+
*/
|
|
2086
|
+
function findCoincidentGroups(series, xFormat) {
|
|
2087
|
+
const byPosition = new Map();
|
|
2088
|
+
series.forEach((s, seriesIndex) => {
|
|
2089
|
+
if (s.hide) {
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
s.data.forEach((data, index) => {
|
|
2093
|
+
if (data.value === null || data.value === undefined) {
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
const key = `${xPositionKey(xFormat, data, index)}|${data.value}`;
|
|
2097
|
+
let members = byPosition.get(key);
|
|
2098
|
+
if (!members) {
|
|
2099
|
+
members = [];
|
|
2100
|
+
byPosition.set(key, members);
|
|
2101
|
+
}
|
|
2102
|
+
members.push({ data, series: s, index, seriesIndex });
|
|
2103
|
+
});
|
|
2104
|
+
});
|
|
2105
|
+
return Array.from(byPosition.values())
|
|
2106
|
+
.filter((members) => members.length > 1)
|
|
2107
|
+
.map((members) => ({ members }));
|
|
2108
|
+
}
|
|
2109
|
+
function xPositionKey(xFormat, data, index) {
|
|
2110
|
+
switch (xFormat) {
|
|
2111
|
+
case PcacFormatEnum.DateTime:
|
|
2112
|
+
return data.key ? new Date(data.key).getTime() : 'none';
|
|
2113
|
+
case PcacFormatEnum.Decimal:
|
|
2114
|
+
return data.key ? Number(data.key) : 'none';
|
|
2115
|
+
default:
|
|
2116
|
+
return index;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
/**
|
|
2120
|
+
* The smallest ring radius at which `count` marks of `size` px sit `gap` px apart from their
|
|
2121
|
+
* neighbours: the chord between adjacent ring positions is `2r sin(π/n)`, so solve it for
|
|
2122
|
+
* `size + gap`. A pair (n = 2) lands `size + gap` apart along a diameter, as expected.
|
|
2123
|
+
*/
|
|
2124
|
+
function fanOutRadius(count, size, gap) {
|
|
2125
|
+
return (size + gap) / (2 * Math.sin(Math.PI / count));
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Places each group's members evenly around a ring centered on their shared coordinate, the
|
|
2129
|
+
* first member at 12 o'clock and the rest clockwise. `radius` is called per group so it can
|
|
2130
|
+
* depend on the group's size (see `fanOutRadius`). Keyed by the point objects themselves,
|
|
2131
|
+
* which are the very elements the builder binds to the DOM, so lookups are exact.
|
|
2132
|
+
*/
|
|
2133
|
+
function fanOutOffsets(groups, radius) {
|
|
2134
|
+
const offsets = new Map();
|
|
2135
|
+
for (const group of groups) {
|
|
2136
|
+
const r = radius(group);
|
|
2137
|
+
const n = group.members.length;
|
|
2138
|
+
group.members.forEach((member, i) => {
|
|
2139
|
+
const angle = -Math.PI / 2 + (i * 2 * Math.PI) / n;
|
|
2140
|
+
offsets.set(member.data, { dx: round(r * Math.cos(angle)), dy: round(r * Math.sin(angle)) });
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
return offsets;
|
|
2144
|
+
}
|
|
2145
|
+
/** Two decimal places is plenty for an SVG coordinate and keeps `cos(π/2)` from reading as `6e-17`. */
|
|
2146
|
+
function round(value) {
|
|
2147
|
+
return Math.round(value * 100) / 100;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2026
2150
|
/**
|
|
2027
2151
|
* Provided per-component (see PcacLineAreaChartComponent's `providers`), not root-scoped: this
|
|
2028
2152
|
* builder extends PcacChart, which holds mutable per-chart-instance state (margin, width,
|
|
@@ -2048,6 +2172,17 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2048
2172
|
*/
|
|
2049
2173
|
clipBuffer = 10;
|
|
2050
2174
|
pointImage;
|
|
2175
|
+
/**
|
|
2176
|
+
* Points that share a coordinate, found by `resolvePointLayout()`. `coincidentOf` looks a
|
|
2177
|
+
* point's group up for its tooltip; the rest only matter when `fanOut` is on (plot chart with
|
|
2178
|
+
* `pointFanOut`): `fanOutOffsets` is where each member is drawn relative to its true position,
|
|
2179
|
+
* and `fanOutReach` how far the farthest one sits from it, for the edge space to reserve.
|
|
2180
|
+
*/
|
|
2181
|
+
coincidentGroups = [];
|
|
2182
|
+
coincidentOf = new Map();
|
|
2183
|
+
fanOut = null;
|
|
2184
|
+
fanOutOffsets = new Map();
|
|
2185
|
+
fanOutReach = 0;
|
|
2051
2186
|
dotClicked$ = this.dotClickedSource.asObservable();
|
|
2052
2187
|
buildChart(chartElm, config, type) {
|
|
2053
2188
|
if (!config?.data?.length) {
|
|
@@ -2062,7 +2197,8 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2062
2197
|
}));
|
|
2063
2198
|
// A hidden axis keeps 8px rather than 0 so a dot on the edge of the plot isn't clipped
|
|
2064
2199
|
this.initializeAxisState(this.config, 'y', 8);
|
|
2065
|
-
this.
|
|
2200
|
+
this.resolvePointLayout(type);
|
|
2201
|
+
this.reservePointSpace();
|
|
2066
2202
|
if (!this.initializeChartState(chartElm, this.config)) {
|
|
2067
2203
|
return;
|
|
2068
2204
|
}
|
|
@@ -2097,6 +2233,9 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2097
2233
|
// points consecutively, shoving the second series' points off to the right on zoom.
|
|
2098
2234
|
this.svg.selectAll('.dots').selectAll('.point')
|
|
2099
2235
|
.attr('transform', (d, i) => this.pointTransform(d, i, newX));
|
|
2236
|
+
// A fan-out's anchor is positioned like the points it belongs to, so it moves the same way.
|
|
2237
|
+
this.svg.selectAll('.fan-out')
|
|
2238
|
+
.attr('transform', (g) => this.fanOutTransform(g, newX));
|
|
2100
2239
|
// The vertical grid hangs off the x ticks too, so redraw it against the rescaled x and
|
|
2101
2240
|
// drop it back underneath everything (append puts it on top).
|
|
2102
2241
|
this.svg.selectAll('.pcac-grid-vertical').remove();
|
|
@@ -2104,6 +2243,7 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2104
2243
|
this.svg.selectAll('.pcac-grid-vertical').lower();
|
|
2105
2244
|
// drawXAxis re-appends the x axis at the end of the group, above the dots; put them back
|
|
2106
2245
|
// on top so a point on the baseline isn't covered (see drawChart's draw order).
|
|
2246
|
+
this.svg.selectAll('.fan-outs').raise();
|
|
2107
2247
|
this.svg.selectAll('.dots').raise();
|
|
2108
2248
|
});
|
|
2109
2249
|
}
|
|
@@ -2128,27 +2268,59 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2128
2268
|
});
|
|
2129
2269
|
}
|
|
2130
2270
|
// Axes above the lines/areas (so an axis line isn't covered by a series sitting at x = 0),
|
|
2131
|
-
// but the dots above the axes: a point on the baseline or the y axis stays whole.
|
|
2271
|
+
// but the dots above the axes: a point on the baseline or the y axis stays whole. Fan-out
|
|
2272
|
+
// spokes go between the two so they run underneath the points they lead to.
|
|
2132
2273
|
this.axisBuilder.raiseAxes(this.svg);
|
|
2274
|
+
this.drawFanOuts();
|
|
2133
2275
|
this.drawDots(config);
|
|
2134
2276
|
}
|
|
2135
2277
|
/**
|
|
2136
|
-
* Resolves `pointImage
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2139
|
-
* the
|
|
2140
|
-
*
|
|
2141
|
-
* Must run between `initializeAxisState()` and `initializeChartState()`, see `reserveEdgeSpace`.
|
|
2278
|
+
* Resolves `pointImage`, finds the points that share a coordinate and, on a plot chart with
|
|
2279
|
+
* `pointFanOut`, works out where to draw each of them instead. Coincidence is found from the
|
|
2280
|
+
* data (see `findCoincidentGroups`) so this can run before the scales exist - it has to, as
|
|
2281
|
+
* `reservePointSpace()` needs the fan-out's reach before the plot area is sized. Line and area
|
|
2282
|
+
* charts still get the groups, for the tooltip's `coincident` list, but never an offset.
|
|
2142
2283
|
*/
|
|
2143
|
-
|
|
2284
|
+
resolvePointLayout(type) {
|
|
2144
2285
|
this.pointImage = { ...new PcacPointImageConfig(), ...this.config.pointImage };
|
|
2286
|
+
this.coincidentGroups = findCoincidentGroups(this.config.data, this.xAxis.format);
|
|
2287
|
+
this.coincidentOf = new Map(this.coincidentGroups.flatMap((group) => group.members.map((member) => [member.data, group])));
|
|
2288
|
+
const fanOut = type === PcacLineAreaPlotChartConfigType.Plot
|
|
2289
|
+
? this.config.pointFanOut
|
|
2290
|
+
: undefined;
|
|
2291
|
+
if (!fanOut) {
|
|
2292
|
+
this.fanOut = null;
|
|
2293
|
+
this.fanOutOffsets = new Map();
|
|
2294
|
+
this.fanOutReach = 0;
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
this.fanOut = { ...new PcacPointFanOutConfig(), ...fanOut };
|
|
2298
|
+
// A group's members are kept apart by the size of what's drawn for them: the image box when
|
|
2299
|
+
// any member has an image, else a hovered dot (r = 6).
|
|
2300
|
+
const { maxWidth, maxHeight } = this.pointImage;
|
|
2301
|
+
const markSize = (group) => group.members.some((member) => !!member.data.image) ? Math.max(maxWidth, maxHeight) : 12;
|
|
2302
|
+
const radius = (group) => this.fanOut.radius ?? fanOutRadius(group.members.length, markSize(group), this.fanOut.gap);
|
|
2303
|
+
this.fanOutOffsets = fanOutOffsets(this.coincidentGroups, radius);
|
|
2304
|
+
this.fanOutReach = Math.ceil(Math.max(0, ...this.coincidentGroups.map(radius)));
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2307
|
+
* When any point has an `image`, or a fan-out has moved points off their coordinate, makes
|
|
2308
|
+
* room for them at the edge of the domain: the clip-path buffer grows to half the box (plus
|
|
2309
|
+
* the fan-out's reach) so the `.dots` group lets it through, and the margins grow to at least
|
|
2310
|
+
* that same amount so the `<svg>` doesn't cut off what the clip-path let through (an image box
|
|
2311
|
+
* is centered on its point, so at the top of the y domain half of it sits above the plot area
|
|
2312
|
+
* - in `margin.top`, which is only 8px by default). A fanned-out plain dot needs the same
|
|
2313
|
+
* treatment, its hovered radius plus the reach. Must run after `resolvePointLayout()` and
|
|
2314
|
+
* between `initializeAxisState()` and `initializeChartState()`, see `reserveEdgeSpace`.
|
|
2315
|
+
*/
|
|
2316
|
+
reservePointSpace() {
|
|
2145
2317
|
const hasImages = this.config.data.some((series) => series.data.some((point) => !!point.image));
|
|
2146
|
-
if (!hasImages) {
|
|
2318
|
+
if (!hasImages && this.fanOutReach === 0) {
|
|
2147
2319
|
this.clipBuffer = 10;
|
|
2148
2320
|
return;
|
|
2149
2321
|
}
|
|
2150
|
-
const halfWidth = Math.ceil(this.pointImage.maxWidth / 2);
|
|
2151
|
-
const halfHeight = Math.ceil(this.pointImage.maxHeight / 2);
|
|
2322
|
+
const halfWidth = (hasImages ? Math.ceil(this.pointImage.maxWidth / 2) : 6) + this.fanOutReach;
|
|
2323
|
+
const halfHeight = (hasImages ? Math.ceil(this.pointImage.maxHeight / 2) : 6) + this.fanOutReach;
|
|
2152
2324
|
this.clipBuffer = Math.max(10, halfWidth, halfHeight);
|
|
2153
2325
|
this.reserveEdgeSpace({ top: halfHeight, bottom: halfHeight, left: halfWidth, right: halfWidth });
|
|
2154
2326
|
}
|
|
@@ -2233,13 +2405,51 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2233
2405
|
.duration(this.transitionService.getTransitionDuration())
|
|
2234
2406
|
.attr('d', this.areaGenerator);
|
|
2235
2407
|
}
|
|
2408
|
+
/**
|
|
2409
|
+
* Draws one `<g class="fan-outs">` holding a `<g class="fan-out">` per group of coincident
|
|
2410
|
+
* points: a spoke from the shared coordinate to where each member is drawn, and an anchor dot
|
|
2411
|
+
* on the coordinate itself. Only when the fan-out is on and asks for anchors. The group is
|
|
2412
|
+
* positioned by the same x translate as a point (see `drawDots`), so zoom moves it the same
|
|
2413
|
+
* way, and fades in over the points' own entry transition.
|
|
2414
|
+
*/
|
|
2415
|
+
drawFanOuts() {
|
|
2416
|
+
if (!this.fanOut?.showAnchor || this.coincidentGroups.length === 0) {
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
const y = (group) => this.scales.y(group.members[0].data.value);
|
|
2420
|
+
const groups = this.svg.append('g')
|
|
2421
|
+
.attr('class', 'fan-outs')
|
|
2422
|
+
.attr('clip-path', `url(#${this.clipPathId})`)
|
|
2423
|
+
.selectAll('.fan-out')
|
|
2424
|
+
.data(this.coincidentGroups)
|
|
2425
|
+
.enter().append('g')
|
|
2426
|
+
.attr('class', 'fan-out')
|
|
2427
|
+
.attr('transform', (group) => this.fanOutTransform(group, this.scales.x));
|
|
2428
|
+
groups.selectAll('.fan-out-spoke')
|
|
2429
|
+
.data((group) => group.members.map((member) => ({ y: y(group), ...this.offsetOf(member.data) })))
|
|
2430
|
+
.enter().append('line')
|
|
2431
|
+
.attr('class', 'fan-out-spoke')
|
|
2432
|
+
.attr('x1', 0)
|
|
2433
|
+
.attr('y1', (spoke) => spoke.y)
|
|
2434
|
+
.attr('x2', (spoke) => spoke.dx)
|
|
2435
|
+
.attr('y2', (spoke) => spoke.y + spoke.dy);
|
|
2436
|
+
groups.append('circle')
|
|
2437
|
+
.attr('class', 'fan-out-anchor')
|
|
2438
|
+
.attr('cy', y)
|
|
2439
|
+
.attr('r', 3);
|
|
2440
|
+
groups.attr('opacity', 0)
|
|
2441
|
+
.transition()
|
|
2442
|
+
.duration(this.transitionService.getTransitionDuration())
|
|
2443
|
+
.attr('opacity', 1);
|
|
2444
|
+
}
|
|
2236
2445
|
/**
|
|
2237
2446
|
* Draws one `<g class="dots">` per series holding a `<g class="point">` per data point. The
|
|
2238
2447
|
* point group carries the x position (as a translate) so that zoom only has to touch that one
|
|
2239
2448
|
* attribute regardless of what's inside; the child is either the regular `<circle class="dot">`
|
|
2240
2449
|
* or, when the point has a `PcacData.image`, an `<image class="dot-image">` in its place. Both
|
|
2241
2450
|
* animate in from the baseline the same way, and the tooltip / click handlers sit on the group
|
|
2242
|
-
* so they behave identically for either.
|
|
2451
|
+
* so they behave identically for either. A fanned-out point's offset is applied to the child,
|
|
2452
|
+
* inside the group, so it too is untouched by zoom.
|
|
2243
2453
|
*/
|
|
2244
2454
|
drawDots(config) {
|
|
2245
2455
|
const self = this;
|
|
@@ -2262,6 +2472,7 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2262
2472
|
index: series.data.indexOf(d),
|
|
2263
2473
|
parent: series,
|
|
2264
2474
|
parentIndex: index,
|
|
2475
|
+
coincident: self.coincidentWith(d),
|
|
2265
2476
|
valueFormat: self.yAxis.format,
|
|
2266
2477
|
keyFormat: self.xAxis.format,
|
|
2267
2478
|
});
|
|
@@ -2287,11 +2498,12 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2287
2498
|
.append('circle')
|
|
2288
2499
|
.attr('class', 'dot')
|
|
2289
2500
|
.attr('stroke', this.colors[index])
|
|
2501
|
+
.attr('cx', (d) => this.offsetOf(d).dx)
|
|
2290
2502
|
.attr('cy', this.scales.y(0))
|
|
2291
2503
|
.attr('fill', '#fff')
|
|
2292
2504
|
.transition()
|
|
2293
2505
|
.duration(duration)
|
|
2294
|
-
.attr('cy', (d) => this.scales.y(d.value))
|
|
2506
|
+
.attr('cy', (d) => this.scales.y(d.value) + this.offsetOf(d).dy)
|
|
2295
2507
|
.attr('r', 4);
|
|
2296
2508
|
// `preserveAspectRatio="xMidYMid meet"` is what does the "resize to fit" - the image is
|
|
2297
2509
|
// scaled uniformly to fit inside the maxWidth x maxHeight box and centered within it, so
|
|
@@ -2304,16 +2516,34 @@ class PlaChartBuilder extends PcacChart {
|
|
|
2304
2516
|
.attr('width', maxWidth)
|
|
2305
2517
|
.attr('height', maxHeight)
|
|
2306
2518
|
.attr('preserveAspectRatio', 'xMidYMid meet')
|
|
2307
|
-
.attr('x', -maxWidth / 2)
|
|
2519
|
+
.attr('x', (d) => -maxWidth / 2 + this.offsetOf(d).dx)
|
|
2308
2520
|
.attr('y', this.scales.y(0) - maxHeight / 2)
|
|
2309
2521
|
.transition()
|
|
2310
2522
|
.duration(duration)
|
|
2311
|
-
.attr('y', (d) => this.scales.y(d.value) - maxHeight / 2);
|
|
2523
|
+
.attr('y', (d) => this.scales.y(d.value) - maxHeight / 2 + this.offsetOf(d).dy);
|
|
2312
2524
|
}
|
|
2313
2525
|
}
|
|
2314
2526
|
pointTransform(d, i, xScale) {
|
|
2315
2527
|
return `translate(${getXFormat(this.xAxis.format, d, i, xScale)}, 0)`;
|
|
2316
2528
|
}
|
|
2529
|
+
/** A fan-out sits where its members would have been drawn; any member locates it. */
|
|
2530
|
+
fanOutTransform(group, xScale) {
|
|
2531
|
+
const { data, index } = group.members[0];
|
|
2532
|
+
return this.pointTransform(data, index, xScale);
|
|
2533
|
+
}
|
|
2534
|
+
offsetOf(d) {
|
|
2535
|
+
return this.fanOutOffsets.get(d) ?? { dx: 0, dy: 0 };
|
|
2536
|
+
}
|
|
2537
|
+
/** The other points at `d`'s coordinate, for the tooltip context (see `PcacTooltipContext.coincident`). */
|
|
2538
|
+
coincidentWith(d) {
|
|
2539
|
+
const group = this.coincidentOf.get(d);
|
|
2540
|
+
if (!group) {
|
|
2541
|
+
return [];
|
|
2542
|
+
}
|
|
2543
|
+
return group.members
|
|
2544
|
+
.filter((member) => member.data !== d)
|
|
2545
|
+
.map((member) => ({ data: member.data, parent: member.series, index: member.index, parentIndex: member.seriesIndex }));
|
|
2546
|
+
}
|
|
2317
2547
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
2318
2548
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PlaChartBuilder });
|
|
2319
2549
|
}
|
|
@@ -2366,11 +2596,11 @@ class PcacLineAreaChartComponent {
|
|
|
2366
2596
|
}
|
|
2367
2597
|
}
|
|
2368
2598
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2369
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.6", type: PcacLineAreaChartComponent, isStandalone: true, selector: "pcac-line-area-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dotClicked: "dotClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, providers: [PlaChartBuilder, PlaChartEffectsBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}pcac-line-chart.pcac-height-full,pcac-area-chart.pcac-height-full,pcac-plot-chart.pcac-height-full,pcac-line-area-chart.pcac-height-full{display:block;height:100%}pcac-line-area-chart.pcac-height-full .pcac-line-area-chart{height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
2599
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.6", type: PcacLineAreaChartComponent, isStandalone: true, selector: "pcac-line-area-chart", inputs: { config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: true, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, tooltipTemplate: { classPropertyName: "tooltipTemplate", publicName: "tooltipTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dotClicked: "dotClicked" }, host: { properties: { "class.pcac-height-full": "config().heightFull" } }, providers: [PlaChartBuilder, PlaChartEffectsBuilder], viewQueries: [{ propertyName: "chartElm", first: true, predicate: ["chart"], descendants: true, isSignal: true }], ngImport: i0, template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .fan-out-spoke{stroke:#ced4da;stroke-width:1px}.pcac-line-area-chart .fan-out-anchor{fill:#6c757d}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}pcac-line-chart.pcac-height-full,pcac-area-chart.pcac-height-full,pcac-plot-chart.pcac-height-full,pcac-line-area-chart.pcac-height-full{display:block;height:100%}pcac-line-area-chart.pcac-height-full .pcac-line-area-chart{height:100%}\n"], encapsulation: i0.ViewEncapsulation.None });
|
|
2370
2600
|
}
|
|
2371
2601
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: PcacLineAreaChartComponent, decorators: [{
|
|
2372
2602
|
type: Component,
|
|
2373
|
-
args: [{ selector: 'pcac-line-area-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, encapsulation: ViewEncapsulation.None, providers: [PlaChartBuilder, PlaChartEffectsBuilder], template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}pcac-line-chart.pcac-height-full,pcac-area-chart.pcac-height-full,pcac-plot-chart.pcac-height-full,pcac-line-area-chart.pcac-height-full{display:block;height:100%}pcac-line-area-chart.pcac-height-full .pcac-line-area-chart{height:100%}\n"] }]
|
|
2603
|
+
args: [{ selector: 'pcac-line-area-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, encapsulation: ViewEncapsulation.None, providers: [PlaChartBuilder, PlaChartEffectsBuilder], template: "<section class=\"pcac-line-area-chart\">\n <svg #chart></svg>\n</section>\n\n", styles: [".pcac-line-area-chart svg{width:100%;display:block}.pcac-line-area-chart .dot{stroke-width:2px}.pcac-line-area-chart .fan-out-spoke{stroke:#ced4da;stroke-width:1px}.pcac-line-area-chart .fan-out-anchor{fill:#6c757d}.pcac-line-area-chart .effects-canvas{fill:none}.pcac-line-area-chart .effect-line{stroke:#ced4da;stroke-width:1px;opacity:0}.pcac-line-area-chart .effect-circle{stroke-width:1px;fill:none;opacity:0}.pcac-line-area-chart .effect-text{font-size:11px;font-weight:700;fill:#343a40}pcac-line-chart.pcac-height-full,pcac-area-chart.pcac-height-full,pcac-plot-chart.pcac-height-full,pcac-line-area-chart.pcac-height-full{display:block;height:100%}pcac-line-area-chart.pcac-height-full .pcac-line-area-chart{height:100%}\n"] }]
|
|
2374
2604
|
}], ctorParameters: () => [], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], chartElm: [{ type: i0.ViewChild, args: ['chart', { isSignal: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }], tooltipTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipTemplate", required: false }] }] } });
|
|
2375
2605
|
|
|
2376
2606
|
class PcacPlotChart {
|
|
@@ -2392,9 +2622,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
2392
2622
|
args: [{ selector: 'pcac-plot-chart', host: { '[class.pcac-height-full]': 'config().heightFull' }, imports: [PcacLineAreaChartComponent], template: "<pcac-line-area-chart [config]=\"config()\" [tooltipTemplate]=\"tooltipTemplate()?.templateRef\" [type]=\"types.Plot\" (dotClicked)=\"dotClicked.emit($event)\"/>" }]
|
|
2393
2623
|
}], propDecorators: { config: [{ type: i0.Input, args: [{ isSignal: true, alias: "config", required: true }] }], dotClicked: [{ type: i0.Output, args: ["dotClicked"] }], tooltipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => PcacTooltipDirective), { isSignal: true }] }] } });
|
|
2394
2624
|
|
|
2395
|
-
class PcacPlotChartConfig extends PcacLineAreaChartConfig {
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
2625
|
class PcacLineChart {
|
|
2399
2626
|
config = input.required(/* @ts-ignore */
|
|
2400
2627
|
...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
|
|
@@ -2595,5 +2822,5 @@ class PcacPieChartConfig extends PcacChartConfig {
|
|
|
2595
2822
|
* Generated bundle index. Do not edit.
|
|
2596
2823
|
*/
|
|
2597
2824
|
|
|
2598
|
-
export { BarHorizontalChartBuilder, BarVerticalChartBuilder, PCAC_AXIS_LABEL_SPACE, PCAC_AXIS_SUB_LABEL_SPACE, PcacAreaChart, PcacAreaChartConfig, PcacAxisBuilder, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChart, PcacChartConfig, PcacChartResizeService, PcacColorService, PcacData, PcacFormatEnum, PcacGridBuilder, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointImageConfig, PcacTooltipBuilder, PcacTooltipDirective, PcacTransitionService, PieChartBuilder, axisLabelSpace, hasAxisSubLabels, resolveAxisConfig };
|
|
2825
|
+
export { BarHorizontalChartBuilder, BarVerticalChartBuilder, PCAC_AXIS_LABEL_SPACE, PCAC_AXIS_SUB_LABEL_SPACE, PcacAreaChart, PcacAreaChartConfig, PcacAxisBuilder, PcacAxisChartConfig, PcacAxisConfig, PcacAxisSubLabels, PcacBarHorizontalChartColorOverrideConfig, PcacBarHorizontalChartComponent, PcacBarHorizontalChartConfig, PcacBarVerticalChartColorOverrideConfig, PcacBarVerticalChartComponent, PcacBarVerticalChartConfig, PcacChart, PcacChartConfig, PcacChartResizeService, PcacColorService, PcacData, PcacFormatEnum, PcacGridBuilder, PcacLegend, PcacLegendConfig, PcacLegendConfigItem, PcacLineChart, PcacLineChartConfig, PcacPieChartComponent, PcacPieChartConfig, PcacPlotChart, PcacPlotChartConfig, PcacPointFanOutConfig, PcacPointImageConfig, PcacTooltipBuilder, PcacTooltipDirective, PcacTransitionService, PieChartBuilder, axisLabelSpace, hasAxisSubLabels, resolveAxisConfig };
|
|
2599
2826
|
//# sourceMappingURL=pioneer-code-pioneer-charts.mjs.map
|