@aiconstructions/graficos 0.0.0-stage → 0.2.1
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/ALTERACOES.md +53 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +188 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { scaleLinear, scaleTime } from "d3-scale";
|
|
4
|
+
import { domAnimation, LazyMotion, useReducedMotion } from "motion/react";
|
|
5
|
+
import {
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import { cn } from "../../lib/utils";
|
|
13
|
+
import { useChartDataOverride } from "../chart-data-override";
|
|
14
|
+
import { ChartLoadingLabel } from "../chart-loading-label";
|
|
15
|
+
import { useElementSize } from "../chart-parent-size";
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_CHART_STATUS,
|
|
18
|
+
resolveRestingChartPhase
|
|
19
|
+
} from "../chart-phase";
|
|
20
|
+
import {
|
|
21
|
+
HEATMAP_DEFAULT_ENTER_DURATION_MS,
|
|
22
|
+
HEATMAP_DEFAULT_LOADING_CELL_MAX_OPACITY,
|
|
23
|
+
HEATMAP_DEFAULT_LOADING_CELL_RANDOMNESS,
|
|
24
|
+
HEATMAP_LOADING_CHART_OPACITY,
|
|
25
|
+
HEATMAP_LOADING_CONCEAL_MS,
|
|
26
|
+
resolveHeatmapWaveTiming
|
|
27
|
+
} from "./heatmap-animation";
|
|
28
|
+
import {
|
|
29
|
+
buildHeatmapColorScaleFromStyles,
|
|
30
|
+
buildHeatmapFillScale,
|
|
31
|
+
resolveHeatmapLevelStyles
|
|
32
|
+
} from "./heatmap-colors";
|
|
33
|
+
import {
|
|
34
|
+
HeatmapInteractionRoot,
|
|
35
|
+
HeatmapProvider,
|
|
36
|
+
useHeatmap,
|
|
37
|
+
useHeatmapInteraction
|
|
38
|
+
} from "./heatmap-context";
|
|
39
|
+
import { HeatmapPatternDefs } from "./heatmap-pattern-defs";
|
|
40
|
+
import { resolveHeatmapSeparatorConfigWithData } from "./heatmap-resolve-separator";
|
|
41
|
+
import {
|
|
42
|
+
filterHeatmapColumns,
|
|
43
|
+
getHeatmapColumnXOffset,
|
|
44
|
+
getHeatmapPlotInnerWidth,
|
|
45
|
+
getHeatmapSeparatorCount,
|
|
46
|
+
getHeatmapTimeExtent,
|
|
47
|
+
rotateHeatmapColumnBins
|
|
48
|
+
} from "./heatmap-utils";
|
|
49
|
+
const DEFAULT_MARGIN = { top: 28, right: 16, bottom: 0, left: 40 };
|
|
50
|
+
function computeHeatmapDimensions({
|
|
51
|
+
width,
|
|
52
|
+
parentHeight,
|
|
53
|
+
margin,
|
|
54
|
+
columnCount,
|
|
55
|
+
rowCount,
|
|
56
|
+
binSize,
|
|
57
|
+
layout,
|
|
58
|
+
separator
|
|
59
|
+
}) {
|
|
60
|
+
const innerWidth = Math.max(width - margin.left - margin.right, 0);
|
|
61
|
+
const availableHeight = Math.max(
|
|
62
|
+
parentHeight - margin.top - margin.bottom,
|
|
63
|
+
0
|
|
64
|
+
);
|
|
65
|
+
const separatorCount = separator ? getHeatmapSeparatorCount(separator) : 0;
|
|
66
|
+
const totalSpacing = separatorCount * (separator?.spacing ?? 0);
|
|
67
|
+
let binWidth;
|
|
68
|
+
let binHeight;
|
|
69
|
+
if (binSize > 0) {
|
|
70
|
+
binWidth = binSize;
|
|
71
|
+
binHeight = binSize;
|
|
72
|
+
} else if (layout === "fluid") {
|
|
73
|
+
const cellSize = Math.max((innerWidth - totalSpacing) / columnCount, 0);
|
|
74
|
+
binWidth = cellSize;
|
|
75
|
+
binHeight = cellSize;
|
|
76
|
+
} else {
|
|
77
|
+
const cellSize = Math.min(
|
|
78
|
+
Math.max((innerWidth - totalSpacing) / columnCount, 0),
|
|
79
|
+
availableHeight / rowCount
|
|
80
|
+
);
|
|
81
|
+
binWidth = cellSize;
|
|
82
|
+
binHeight = cellSize;
|
|
83
|
+
}
|
|
84
|
+
const plotInnerWidth = getHeatmapPlotInnerWidth(
|
|
85
|
+
columnCount,
|
|
86
|
+
binWidth,
|
|
87
|
+
separator
|
|
88
|
+
);
|
|
89
|
+
const innerHeight = rowCount * binHeight;
|
|
90
|
+
const height = layout === "fluid" ? margin.top + innerHeight + margin.bottom : Math.max(parentHeight, margin.top + innerHeight + margin.bottom);
|
|
91
|
+
const chartWidth = binSize > 0 && layout === "fluid" ? margin.left + plotInnerWidth + margin.right : width;
|
|
92
|
+
return {
|
|
93
|
+
binWidth,
|
|
94
|
+
binHeight,
|
|
95
|
+
innerWidth: plotInnerWidth,
|
|
96
|
+
innerHeight,
|
|
97
|
+
height,
|
|
98
|
+
width: chartWidth
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function HeatmapChartInner({
|
|
102
|
+
width,
|
|
103
|
+
height: parentHeight,
|
|
104
|
+
data,
|
|
105
|
+
xDomain,
|
|
106
|
+
sizingColumnCount: sizingColumnCountProp,
|
|
107
|
+
margin,
|
|
108
|
+
binSize,
|
|
109
|
+
gap,
|
|
110
|
+
layout,
|
|
111
|
+
colorScale,
|
|
112
|
+
fillScale,
|
|
113
|
+
levelStyles,
|
|
114
|
+
chartStatus,
|
|
115
|
+
chartPhase,
|
|
116
|
+
isLoaded,
|
|
117
|
+
revealEpoch,
|
|
118
|
+
animationDuration,
|
|
119
|
+
enterTransition,
|
|
120
|
+
enterStaggerScale,
|
|
121
|
+
animateCells,
|
|
122
|
+
loadingOpacity,
|
|
123
|
+
showLoadingCells,
|
|
124
|
+
loadingCellMaxOpacity,
|
|
125
|
+
loadingCellRandomness,
|
|
126
|
+
revealMode,
|
|
127
|
+
loadingLabel,
|
|
128
|
+
showLoadingLabel,
|
|
129
|
+
columnSeparators,
|
|
130
|
+
weekStartDay,
|
|
131
|
+
children
|
|
132
|
+
}) {
|
|
133
|
+
const containerRef = useRef(null);
|
|
134
|
+
const filteredData = useMemo(
|
|
135
|
+
() => filterHeatmapColumns(data, xDomain),
|
|
136
|
+
[data, xDomain]
|
|
137
|
+
);
|
|
138
|
+
const visibleData = useMemo(
|
|
139
|
+
() => rotateHeatmapColumnBins(filteredData, weekStartDay),
|
|
140
|
+
[filteredData, weekStartDay]
|
|
141
|
+
);
|
|
142
|
+
const visibleColumnCount = Math.max(visibleData.length, 1);
|
|
143
|
+
const columnCount = xDomain && sizingColumnCountProp != null ? Math.max(sizingColumnCountProp, 1) : visibleColumnCount;
|
|
144
|
+
const rowCount = Math.max(visibleData[0]?.bins.length ?? 7, 1);
|
|
145
|
+
const separatorLayout = useMemo(
|
|
146
|
+
() => resolveHeatmapSeparatorConfigWithData(
|
|
147
|
+
children,
|
|
148
|
+
visibleData,
|
|
149
|
+
columnSeparators
|
|
150
|
+
),
|
|
151
|
+
[children, columnSeparators, visibleData]
|
|
152
|
+
);
|
|
153
|
+
const {
|
|
154
|
+
binWidth,
|
|
155
|
+
binHeight,
|
|
156
|
+
innerWidth,
|
|
157
|
+
innerHeight,
|
|
158
|
+
height,
|
|
159
|
+
width: chartWidth
|
|
160
|
+
} = useMemo(
|
|
161
|
+
() => computeHeatmapDimensions({
|
|
162
|
+
width,
|
|
163
|
+
parentHeight,
|
|
164
|
+
margin,
|
|
165
|
+
columnCount,
|
|
166
|
+
rowCount,
|
|
167
|
+
binSize,
|
|
168
|
+
layout,
|
|
169
|
+
separator: separatorLayout
|
|
170
|
+
}),
|
|
171
|
+
[
|
|
172
|
+
binSize,
|
|
173
|
+
columnCount,
|
|
174
|
+
layout,
|
|
175
|
+
margin,
|
|
176
|
+
parentHeight,
|
|
177
|
+
rowCount,
|
|
178
|
+
separatorLayout,
|
|
179
|
+
width
|
|
180
|
+
]
|
|
181
|
+
);
|
|
182
|
+
const xScale = useMemo(
|
|
183
|
+
() => (columnIndex) => columnIndex * binWidth + getHeatmapColumnXOffset(columnIndex, separatorLayout),
|
|
184
|
+
[binWidth, separatorLayout]
|
|
185
|
+
);
|
|
186
|
+
const yScale = useMemo(
|
|
187
|
+
() => (rowIndex) => rowIndex * binHeight,
|
|
188
|
+
[binHeight]
|
|
189
|
+
);
|
|
190
|
+
const timeExtent = useMemo(() => getHeatmapTimeExtent(data), [data]);
|
|
191
|
+
const timeXScale = useMemo(() => {
|
|
192
|
+
const domain = timeExtent ?? [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
|
|
193
|
+
return scaleTime().domain(domain).range([0, innerWidth]);
|
|
194
|
+
}, [innerWidth, timeExtent]);
|
|
195
|
+
const brushYScale = useMemo(
|
|
196
|
+
() => scaleLinear().domain([0, 1]).range([innerHeight, 0]),
|
|
197
|
+
[innerHeight]
|
|
198
|
+
);
|
|
199
|
+
const contextValue = useMemo(
|
|
200
|
+
() => ({
|
|
201
|
+
data: visibleData,
|
|
202
|
+
width: chartWidth,
|
|
203
|
+
height,
|
|
204
|
+
innerWidth,
|
|
205
|
+
innerHeight,
|
|
206
|
+
margin,
|
|
207
|
+
binWidth,
|
|
208
|
+
binHeight,
|
|
209
|
+
gap,
|
|
210
|
+
weekStartDay,
|
|
211
|
+
xScale,
|
|
212
|
+
yScale,
|
|
213
|
+
separatorLayout,
|
|
214
|
+
timeXScale,
|
|
215
|
+
brushYScale,
|
|
216
|
+
isReady: chartWidth >= 10 && height >= 10,
|
|
217
|
+
colorScale,
|
|
218
|
+
fillScale,
|
|
219
|
+
levelStyles,
|
|
220
|
+
containerRef,
|
|
221
|
+
chartStatus,
|
|
222
|
+
chartPhase,
|
|
223
|
+
isLoaded,
|
|
224
|
+
revealEpoch,
|
|
225
|
+
animationDuration,
|
|
226
|
+
enterTransition,
|
|
227
|
+
enterStaggerScale,
|
|
228
|
+
animateCells,
|
|
229
|
+
loadingOpacity,
|
|
230
|
+
showLoadingCells,
|
|
231
|
+
loadingCellMaxOpacity,
|
|
232
|
+
loadingCellRandomness,
|
|
233
|
+
revealMode,
|
|
234
|
+
loadingLabel,
|
|
235
|
+
showLoadingLabel
|
|
236
|
+
}),
|
|
237
|
+
[
|
|
238
|
+
animateCells,
|
|
239
|
+
animationDuration,
|
|
240
|
+
binHeight,
|
|
241
|
+
binWidth,
|
|
242
|
+
brushYScale,
|
|
243
|
+
chartPhase,
|
|
244
|
+
chartStatus,
|
|
245
|
+
chartWidth,
|
|
246
|
+
colorScale,
|
|
247
|
+
fillScale,
|
|
248
|
+
enterStaggerScale,
|
|
249
|
+
enterTransition,
|
|
250
|
+
gap,
|
|
251
|
+
height,
|
|
252
|
+
innerHeight,
|
|
253
|
+
innerWidth,
|
|
254
|
+
isLoaded,
|
|
255
|
+
loadingCellMaxOpacity,
|
|
256
|
+
loadingCellRandomness,
|
|
257
|
+
loadingLabel,
|
|
258
|
+
levelStyles,
|
|
259
|
+
loadingOpacity,
|
|
260
|
+
margin,
|
|
261
|
+
revealMode,
|
|
262
|
+
separatorLayout,
|
|
263
|
+
showLoadingCells,
|
|
264
|
+
showLoadingLabel,
|
|
265
|
+
revealEpoch,
|
|
266
|
+
timeXScale,
|
|
267
|
+
visibleData,
|
|
268
|
+
weekStartDay,
|
|
269
|
+
xScale,
|
|
270
|
+
yScale
|
|
271
|
+
]
|
|
272
|
+
);
|
|
273
|
+
if (chartWidth < 10 || height < 10) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
return /* @__PURE__ */ jsx(HeatmapProvider, { value: contextValue, children: /* @__PURE__ */ jsx(HeatmapInteractionRoot, { children: /* @__PURE__ */ jsx(HeatmapChartSurface, { layout, children }) }) });
|
|
277
|
+
}
|
|
278
|
+
function HeatmapChartSurface({
|
|
279
|
+
layout,
|
|
280
|
+
children
|
|
281
|
+
}) {
|
|
282
|
+
const {
|
|
283
|
+
containerRef,
|
|
284
|
+
height,
|
|
285
|
+
width,
|
|
286
|
+
margin,
|
|
287
|
+
levelStyles,
|
|
288
|
+
chartPhase,
|
|
289
|
+
loadingOpacity,
|
|
290
|
+
loadingLabel,
|
|
291
|
+
showLoadingLabel
|
|
292
|
+
} = useHeatmap();
|
|
293
|
+
const { clearInteraction } = useHeatmapInteraction();
|
|
294
|
+
const reducedOpacity = chartPhase === "loading" || chartPhase === "exitingReady" ? loadingOpacity : 1;
|
|
295
|
+
return /* @__PURE__ */ jsxs(
|
|
296
|
+
"div",
|
|
297
|
+
{
|
|
298
|
+
className: cn("relative w-full", layout === "fill" && "h-full"),
|
|
299
|
+
onPointerLeave: clearInteraction,
|
|
300
|
+
ref: containerRef,
|
|
301
|
+
style: { opacity: reducedOpacity },
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsxs(
|
|
304
|
+
"svg",
|
|
305
|
+
{
|
|
306
|
+
"aria-hidden": "true",
|
|
307
|
+
className: "overflow-visible",
|
|
308
|
+
height,
|
|
309
|
+
width,
|
|
310
|
+
children: [
|
|
311
|
+
/* @__PURE__ */ jsx(HeatmapPatternDefs, { levelStyles }),
|
|
312
|
+
/* @__PURE__ */ jsx("g", { transform: `translate(${margin.left},${margin.top})`, children })
|
|
313
|
+
]
|
|
314
|
+
}
|
|
315
|
+
),
|
|
316
|
+
showLoadingLabel && loadingLabel?.trim() ? /* @__PURE__ */ jsx(
|
|
317
|
+
"div",
|
|
318
|
+
{
|
|
319
|
+
className: "pointer-events-none absolute",
|
|
320
|
+
style: {
|
|
321
|
+
top: margin.top,
|
|
322
|
+
left: margin.left,
|
|
323
|
+
width: Math.max(width - margin.left - margin.right, 0),
|
|
324
|
+
height: Math.max(height - margin.top - margin.bottom, 0)
|
|
325
|
+
},
|
|
326
|
+
children: /* @__PURE__ */ jsx(
|
|
327
|
+
ChartLoadingLabel,
|
|
328
|
+
{
|
|
329
|
+
exiting: chartPhase !== "loading",
|
|
330
|
+
text: loadingLabel
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
}
|
|
334
|
+
) : null
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
function useHeatmapChartLifecycle({
|
|
340
|
+
chartStatus,
|
|
341
|
+
animationDuration,
|
|
342
|
+
revealSignature = "",
|
|
343
|
+
animate,
|
|
344
|
+
revealDurationMs
|
|
345
|
+
}) {
|
|
346
|
+
const reducedMotion = useReducedMotion();
|
|
347
|
+
const animateCells = animate && !reducedMotion;
|
|
348
|
+
const animateEnter = animateCells && animationDuration > 0;
|
|
349
|
+
const [chartPhase, setChartPhase] = useState(() => {
|
|
350
|
+
if (animateEnter && chartStatus === "ready") {
|
|
351
|
+
return "revealing";
|
|
352
|
+
}
|
|
353
|
+
return resolveRestingChartPhase(chartStatus);
|
|
354
|
+
});
|
|
355
|
+
const [isLoaded, setIsLoaded] = useState(() => !animateEnter);
|
|
356
|
+
const [revealEpoch, setRevealEpoch] = useState(
|
|
357
|
+
() => animateEnter && chartStatus === "ready" ? 1 : 0
|
|
358
|
+
);
|
|
359
|
+
const [revealMode, setRevealMode] = useState(
|
|
360
|
+
() => animateEnter && chartStatus === "ready" ? "enter" : null
|
|
361
|
+
);
|
|
362
|
+
const [prev, setPrev] = useState({
|
|
363
|
+
chartStatus,
|
|
364
|
+
animateEnter,
|
|
365
|
+
animationDuration,
|
|
366
|
+
revealSignature
|
|
367
|
+
});
|
|
368
|
+
if (prev.chartStatus !== chartStatus || prev.animateEnter !== animateEnter || prev.animationDuration !== animationDuration || prev.revealSignature !== revealSignature) {
|
|
369
|
+
setPrev({ chartStatus, animateEnter, animationDuration, revealSignature });
|
|
370
|
+
if (prev.chartStatus !== chartStatus) {
|
|
371
|
+
if (chartStatus === "ready" && prev.chartStatus === "loading") {
|
|
372
|
+
setRevealMode("fromLoading");
|
|
373
|
+
setIsLoaded(false);
|
|
374
|
+
setChartPhase("revealing");
|
|
375
|
+
} else if (chartStatus === "loading" && prev.chartStatus === "ready") {
|
|
376
|
+
setRevealMode(null);
|
|
377
|
+
setIsLoaded(false);
|
|
378
|
+
setChartPhase("exitingReady");
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (!animateEnter) {
|
|
382
|
+
setIsLoaded(true);
|
|
383
|
+
setChartPhase(resolveRestingChartPhase(chartStatus));
|
|
384
|
+
} else if (chartStatus === "ready" && chartPhase === "ready") {
|
|
385
|
+
setRevealMode("enter");
|
|
386
|
+
setRevealEpoch((epoch) => epoch + 1);
|
|
387
|
+
setIsLoaded(false);
|
|
388
|
+
setChartPhase("revealing");
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const finishReveal = useCallback(() => {
|
|
392
|
+
setIsLoaded(true);
|
|
393
|
+
setChartPhase("ready");
|
|
394
|
+
setRevealMode(null);
|
|
395
|
+
}, []);
|
|
396
|
+
useEffect(() => {
|
|
397
|
+
if (chartPhase !== "exitingReady") {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const timer = window.setTimeout(() => {
|
|
401
|
+
setChartPhase("loading");
|
|
402
|
+
}, HEATMAP_LOADING_CONCEAL_MS);
|
|
403
|
+
return () => window.clearTimeout(timer);
|
|
404
|
+
}, [chartPhase]);
|
|
405
|
+
useEffect(() => {
|
|
406
|
+
if (!animateEnter || chartPhase !== "revealing") {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const finishTimer = window.setTimeout(finishReveal, revealDurationMs + 100);
|
|
410
|
+
return () => window.clearTimeout(finishTimer);
|
|
411
|
+
}, [animateEnter, revealDurationMs, chartPhase, finishReveal, revealEpoch]);
|
|
412
|
+
return {
|
|
413
|
+
chartPhase,
|
|
414
|
+
isLoaded,
|
|
415
|
+
revealEpoch,
|
|
416
|
+
revealMode,
|
|
417
|
+
animateCells
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function HeatmapChart({
|
|
421
|
+
data: dataProp,
|
|
422
|
+
xDomain,
|
|
423
|
+
sizingColumnCount,
|
|
424
|
+
layout = "fluid",
|
|
425
|
+
margin: marginProp,
|
|
426
|
+
binSize = 0,
|
|
427
|
+
gap = 2,
|
|
428
|
+
colorScale: colorScaleProp,
|
|
429
|
+
levelColors,
|
|
430
|
+
levelStyles: levelStylesProp,
|
|
431
|
+
aspectRatio,
|
|
432
|
+
className = "",
|
|
433
|
+
status = DEFAULT_CHART_STATUS,
|
|
434
|
+
loadingLabel,
|
|
435
|
+
animationDuration = HEATMAP_DEFAULT_ENTER_DURATION_MS,
|
|
436
|
+
enterTransition,
|
|
437
|
+
revealSignature = "",
|
|
438
|
+
enterStaggerScale = 1,
|
|
439
|
+
animate = true,
|
|
440
|
+
loadingOpacity = HEATMAP_LOADING_CHART_OPACITY,
|
|
441
|
+
showLoadingCells = true,
|
|
442
|
+
loadingCellMaxOpacity = HEATMAP_DEFAULT_LOADING_CELL_MAX_OPACITY,
|
|
443
|
+
loadingCellRandomness = HEATMAP_DEFAULT_LOADING_CELL_RANDOMNESS,
|
|
444
|
+
columnSeparators,
|
|
445
|
+
weekStartDay = 0,
|
|
446
|
+
children
|
|
447
|
+
}) {
|
|
448
|
+
const { data } = useChartDataOverride("HeatmapChart", {
|
|
449
|
+
data: dataProp
|
|
450
|
+
});
|
|
451
|
+
const marginTop = marginProp?.top ?? DEFAULT_MARGIN.top;
|
|
452
|
+
const marginRight = marginProp?.right ?? DEFAULT_MARGIN.right;
|
|
453
|
+
const marginBottom = marginProp?.bottom ?? DEFAULT_MARGIN.bottom;
|
|
454
|
+
const marginLeft = marginProp?.left ?? DEFAULT_MARGIN.left;
|
|
455
|
+
const margin = useMemo(
|
|
456
|
+
() => ({
|
|
457
|
+
top: marginTop,
|
|
458
|
+
right: marginRight,
|
|
459
|
+
bottom: marginBottom,
|
|
460
|
+
left: marginLeft
|
|
461
|
+
}),
|
|
462
|
+
[marginBottom, marginLeft, marginRight, marginTop]
|
|
463
|
+
);
|
|
464
|
+
const levelStyles = useMemo(
|
|
465
|
+
() => resolveHeatmapLevelStyles(levelColors, levelStylesProp),
|
|
466
|
+
[levelColors, levelStylesProp]
|
|
467
|
+
);
|
|
468
|
+
const colorScale = useMemo(
|
|
469
|
+
() => colorScaleProp ?? buildHeatmapColorScaleFromStyles(levelStyles),
|
|
470
|
+
[colorScaleProp, levelStyles]
|
|
471
|
+
);
|
|
472
|
+
const fillScale = useMemo(
|
|
473
|
+
() => buildHeatmapFillScale(levelStyles),
|
|
474
|
+
[levelStyles]
|
|
475
|
+
);
|
|
476
|
+
const revealDurationMs = resolveHeatmapWaveTiming({
|
|
477
|
+
animationDurationMs: animationDuration,
|
|
478
|
+
enterTransition,
|
|
479
|
+
enterStaggerScale,
|
|
480
|
+
columnCount: data.length,
|
|
481
|
+
rowCount: data[0]?.bins.length ?? 7
|
|
482
|
+
}).totalMs;
|
|
483
|
+
const { chartPhase, isLoaded, revealEpoch, revealMode, animateCells } = useHeatmapChartLifecycle({
|
|
484
|
+
chartStatus: status,
|
|
485
|
+
animationDuration,
|
|
486
|
+
revealSignature,
|
|
487
|
+
animate,
|
|
488
|
+
revealDurationMs
|
|
489
|
+
});
|
|
490
|
+
const showLoadingLabel = Boolean(
|
|
491
|
+
loadingLabel?.trim() && status === "loading" && (chartPhase === "loading" || chartPhase === "exitingReady")
|
|
492
|
+
);
|
|
493
|
+
const parentRef = useRef(null);
|
|
494
|
+
const { width, height: parentHeight } = useElementSize(parentRef, 300);
|
|
495
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
496
|
+
"div",
|
|
497
|
+
{
|
|
498
|
+
className: cn(
|
|
499
|
+
"relative w-full",
|
|
500
|
+
layout === "fill" && "h-full min-h-0",
|
|
501
|
+
className
|
|
502
|
+
),
|
|
503
|
+
ref: parentRef,
|
|
504
|
+
style: aspectRatio ? { aspectRatio } : void 0,
|
|
505
|
+
children: /* @__PURE__ */ jsx(
|
|
506
|
+
HeatmapChartInner,
|
|
507
|
+
{
|
|
508
|
+
animateCells,
|
|
509
|
+
animationDuration,
|
|
510
|
+
binSize,
|
|
511
|
+
chartPhase,
|
|
512
|
+
chartStatus: status,
|
|
513
|
+
colorScale,
|
|
514
|
+
columnSeparators,
|
|
515
|
+
data,
|
|
516
|
+
enterStaggerScale,
|
|
517
|
+
enterTransition,
|
|
518
|
+
fillScale,
|
|
519
|
+
gap,
|
|
520
|
+
height: parentHeight,
|
|
521
|
+
isLoaded,
|
|
522
|
+
layout,
|
|
523
|
+
levelStyles,
|
|
524
|
+
loadingCellMaxOpacity,
|
|
525
|
+
loadingCellRandomness,
|
|
526
|
+
loadingLabel,
|
|
527
|
+
loadingOpacity,
|
|
528
|
+
margin,
|
|
529
|
+
revealEpoch,
|
|
530
|
+
revealMode,
|
|
531
|
+
showLoadingCells,
|
|
532
|
+
showLoadingLabel,
|
|
533
|
+
sizingColumnCount,
|
|
534
|
+
weekStartDay,
|
|
535
|
+
width,
|
|
536
|
+
xDomain,
|
|
537
|
+
children
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
) });
|
|
542
|
+
}
|
|
543
|
+
HeatmapChart.displayName = "HeatmapChart";
|
|
544
|
+
var heatmap_chart_default = HeatmapChart;
|
|
545
|
+
export {
|
|
546
|
+
HeatmapChart,
|
|
547
|
+
heatmap_chart_default as default
|
|
548
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { CHART_SCALE_VARS } from "../chart-scale";
|
|
2
|
+
import { getHeatmapContributionLevel } from "./heatmap-utils";
|
|
3
|
+
const HEATMAP_DEFAULT_LEVEL_COLORS = CHART_SCALE_VARS;
|
|
4
|
+
const HEATMAP_DEFAULT_LEVEL_STYLES = [
|
|
5
|
+
{
|
|
6
|
+
color: HEATMAP_DEFAULT_LEVEL_COLORS[0],
|
|
7
|
+
fillMode: "solid",
|
|
8
|
+
pattern: "none"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
color: HEATMAP_DEFAULT_LEVEL_COLORS[1],
|
|
12
|
+
fillMode: "solid",
|
|
13
|
+
pattern: "none"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
color: HEATMAP_DEFAULT_LEVEL_COLORS[2],
|
|
17
|
+
fillMode: "solid",
|
|
18
|
+
pattern: "none"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
color: HEATMAP_DEFAULT_LEVEL_COLORS[3],
|
|
22
|
+
fillMode: "solid",
|
|
23
|
+
pattern: "none"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
color: HEATMAP_DEFAULT_LEVEL_COLORS[4],
|
|
27
|
+
fillMode: "solid",
|
|
28
|
+
pattern: "none"
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
function heatmapLevelPatternId(level) {
|
|
32
|
+
return `heatmap-level-${level}`;
|
|
33
|
+
}
|
|
34
|
+
function isHeatmapLevelPattern(style) {
|
|
35
|
+
return style.fillMode === "pattern" && style.pattern != null && style.pattern !== "none";
|
|
36
|
+
}
|
|
37
|
+
function heatmapPatternStrokeFallback(color) {
|
|
38
|
+
return `color-mix(in oklch, ${color} 45%, white)`;
|
|
39
|
+
}
|
|
40
|
+
function heatmapLevelPatternRenderOptions(style) {
|
|
41
|
+
const preset = style.pattern ?? "diagonal-up";
|
|
42
|
+
return {
|
|
43
|
+
color: style.patternColor?.trim() || (preset === "accent" ? "#e879f9" : heatmapPatternStrokeFallback(style.color)),
|
|
44
|
+
tileBackground: style.patternTileBackground?.trim() || style.color,
|
|
45
|
+
scale: style.patternScale ?? 1,
|
|
46
|
+
strokeWidth: style.patternStrokeWidth,
|
|
47
|
+
radius: style.patternRadius,
|
|
48
|
+
complement: style.patternComplement,
|
|
49
|
+
fill: style.patternFill?.trim() || void 0,
|
|
50
|
+
dotFill: style.patternDotsFill
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function heatmapLevelCellFillOpacity(style) {
|
|
54
|
+
if (!isHeatmapLevelPattern(style)) {
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
return style.patternOpacity ?? 1;
|
|
58
|
+
}
|
|
59
|
+
function levelColorsFromStyles(levelStyles) {
|
|
60
|
+
return [
|
|
61
|
+
levelStyles[0].color,
|
|
62
|
+
levelStyles[1].color,
|
|
63
|
+
levelStyles[2].color,
|
|
64
|
+
levelStyles[3].color,
|
|
65
|
+
levelStyles[4].color
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function levelStylesFromColors(levelColors) {
|
|
69
|
+
return [
|
|
70
|
+
{ color: levelColors[0], fillMode: "solid", pattern: "none" },
|
|
71
|
+
{ color: levelColors[1], fillMode: "solid", pattern: "none" },
|
|
72
|
+
{ color: levelColors[2], fillMode: "solid", pattern: "none" },
|
|
73
|
+
{ color: levelColors[3], fillMode: "solid", pattern: "none" },
|
|
74
|
+
{ color: levelColors[4], fillMode: "solid", pattern: "none" }
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function resolveHeatmapLevelStyles(levelColors, levelStyles) {
|
|
78
|
+
if (levelStyles) {
|
|
79
|
+
return levelStyles;
|
|
80
|
+
}
|
|
81
|
+
if (levelColors) {
|
|
82
|
+
return levelStylesFromColors(levelColors);
|
|
83
|
+
}
|
|
84
|
+
return HEATMAP_DEFAULT_LEVEL_STYLES;
|
|
85
|
+
}
|
|
86
|
+
function buildHeatmapColorScale(levelColors) {
|
|
87
|
+
return buildHeatmapColorScaleFromStyles(levelStylesFromColors(levelColors));
|
|
88
|
+
}
|
|
89
|
+
function buildHeatmapColorScaleFromStyles(levelStyles) {
|
|
90
|
+
return (count) => {
|
|
91
|
+
const level = getHeatmapContributionLevel(count ?? 0);
|
|
92
|
+
return levelStyles[level]?.color ?? levelStyles[0].color;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function buildHeatmapFillScale(levelStyles) {
|
|
96
|
+
return (count) => {
|
|
97
|
+
const level = getHeatmapContributionLevel(count ?? 0);
|
|
98
|
+
const style = levelStyles[level] ?? levelStyles[0];
|
|
99
|
+
if (isHeatmapLevelPattern(style)) {
|
|
100
|
+
return `url(#${heatmapLevelPatternId(level)})`;
|
|
101
|
+
}
|
|
102
|
+
return style.color;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const defaultHeatmapColorScale = buildHeatmapColorScale(
|
|
106
|
+
HEATMAP_DEFAULT_LEVEL_COLORS
|
|
107
|
+
);
|
|
108
|
+
const defaultHeatmapFillScale = buildHeatmapFillScale(
|
|
109
|
+
HEATMAP_DEFAULT_LEVEL_STYLES
|
|
110
|
+
);
|
|
111
|
+
export {
|
|
112
|
+
HEATMAP_DEFAULT_LEVEL_COLORS,
|
|
113
|
+
HEATMAP_DEFAULT_LEVEL_STYLES,
|
|
114
|
+
buildHeatmapColorScale,
|
|
115
|
+
buildHeatmapColorScaleFromStyles,
|
|
116
|
+
buildHeatmapFillScale,
|
|
117
|
+
defaultHeatmapColorScale,
|
|
118
|
+
defaultHeatmapFillScale,
|
|
119
|
+
heatmapLevelCellFillOpacity,
|
|
120
|
+
heatmapLevelPatternId,
|
|
121
|
+
heatmapLevelPatternRenderOptions,
|
|
122
|
+
heatmapPatternStrokeFallback,
|
|
123
|
+
isHeatmapLevelPattern,
|
|
124
|
+
levelColorsFromStyles,
|
|
125
|
+
levelStylesFromColors,
|
|
126
|
+
resolveHeatmapLevelStyles
|
|
127
|
+
};
|