@cdc/chart 4.25.11 → 4.26.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.
- package/CLAUDE.local.md +79 -0
- package/dist/{cdcchart-dgT_1dIT.es.js → cdcchart-DQ00cQCm.es.js} +1 -20
- package/dist/cdcchart.js +51401 -50814
- package/examples/default.json +378 -0
- package/examples/feature/__data__/horizon-chart-data.json +373 -0
- package/examples/feature/annotations/index.json +3 -6
- package/examples/feature/horizon/horizon-chart.json +395 -0
- package/examples/feature/pie/planet-pie-example-config.json +48 -2
- package/examples/line-chart-states.json +1085 -0
- package/examples/private/123.json +694 -0
- package/examples/private/DEV-12100.json +1303 -0
- package/examples/private/anchor-issue.json +4094 -0
- package/examples/private/backwards-slider.json +10430 -0
- package/examples/private/cat-y.json +1235 -0
- package/examples/private/data-points.json +228 -0
- package/examples/private/georgia.csv +160 -0
- package/examples/private/height.json +3915 -0
- package/examples/private/links.json +569 -0
- package/examples/private/quadrant.txt +30 -0
- package/examples/private/test-forecast.json +5510 -0
- package/examples/private/timeline-data.json +1 -0
- package/examples/private/timeline.json +389 -0
- package/examples/private/warming-stripe-test.json +2578 -0
- package/examples/private/warming-stripes.json +4763 -0
- package/examples/radar-chart-simple.json +133 -0
- package/examples/radar-chart.json +148 -0
- package/examples/tech-adoption-with-links.json +560 -0
- package/index.html +1 -36
- package/package.json +59 -60
- package/src/CdcChartComponent.tsx +206 -89
- package/src/_stories/Chart.Anchors.stories.tsx +10 -0
- package/src/_stories/Chart.BoxPlot.stories.tsx +7 -0
- package/src/_stories/Chart.CI.stories.tsx +13 -0
- package/src/_stories/Chart.Combo.stories.tsx +17 -0
- package/src/_stories/Chart.CustomColors.stories.tsx +4 -0
- package/src/_stories/Chart.DynamicSeries.stories.tsx +19 -0
- package/src/_stories/Chart.Filters.stories.tsx +4 -0
- package/src/_stories/Chart.Forecast.stories.tsx +4 -0
- package/src/_stories/Chart.HTMLInDataTable.stories.tsx +22 -0
- package/src/_stories/Chart.Legend.Gradient.stories.tsx +28 -0
- package/src/_stories/Chart.Patterns.stories.tsx +4 -0
- package/src/_stories/Chart.PreserveDecimals.stories.tsx +25 -0
- package/src/_stories/Chart.Regions.Categorical.stories.tsx +161 -0
- package/src/_stories/Chart.Regions.DateScale.stories.tsx +216 -0
- package/src/_stories/Chart.Regions.DateTimeScale.stories.tsx +312 -0
- package/src/_stories/Chart.ScatterPlot.stories.tsx +4 -0
- package/src/_stories/Chart.SmallMultiples.stories.tsx +16 -0
- package/src/_stories/Chart.stories.tsx +45 -0
- package/src/_stories/Chart.tooltip.stories.tsx +7 -0
- package/src/_stories/ChartAnnotation.stories.tsx +10 -0
- package/src/_stories/ChartAxisLabels.stories.tsx +4 -0
- package/src/_stories/ChartAxisTitles.stories.tsx +10 -0
- package/src/_stories/ChartBar.Editor.stories.tsx +11 -6
- package/src/_stories/ChartBrush.Editor.stories.tsx +295 -0
- package/src/_stories/ChartBrush.Matrix.Continuous.stories.tsx +41 -0
- package/src/_stories/ChartBrush.Matrix.Date.stories.tsx +114 -0
- package/src/_stories/ChartBrush.Matrix.DateTime.stories.tsx +78 -0
- package/src/_stories/ChartBrush.stories.tsx +57 -0
- package/src/_stories/ChartEditor.Editor.stories.tsx +3 -5
- package/src/_stories/ChartEditor.stories.tsx +7 -0
- package/src/_stories/ChartLine.QuadrantAngles.stories.tsx +89 -0
- package/src/_stories/ChartLine.Suppression.stories.tsx +7 -0
- package/src/_stories/ChartLine.Symbols.stories.tsx +4 -0
- package/src/_stories/ChartPrefixSuffix.stories.tsx +46 -1
- package/src/_stories/TechAdoptionWithLinks.stories.tsx +34 -0
- package/src/_stories/_mock/brush_continuous.json +86 -0
- package/src/_stories/_mock/brush_date_large.json +176 -0
- package/src/_stories/_mock/brush_enabled.json +326 -0
- package/src/_stories/_mock/brush_mock.json +2 -69
- package/src/_stories/_mock/horizontal-bars-dynamic-y-axis.json +413 -0
- package/src/_stories/_mock/line_chart_angle_near_zero_fall.json +195 -0
- package/src/_stories/_mock/line_chart_angle_near_zero_rise.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q1_steep_upward.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q2_gentle_downward.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q3_steep_downward.json +195 -0
- package/src/_stories/_mock/line_chart_angle_q4_gentle_upward.json +195 -0
- package/src/_stories/_mock/line_chart_quadrant_angles.json +264 -0
- package/src/components/Annotations/components/AnnotationDraggable.styles.css +11 -17
- package/src/components/Annotations/components/AnnotationDraggable.tsx +240 -116
- package/src/components/Annotations/components/AnnotationDropdown.styles.css +1 -2
- package/src/components/Annotations/components/AnnotationDropdown.tsx +8 -12
- package/src/components/Annotations/components/AnnotationList.styles.css +4 -10
- package/src/components/Annotations/components/AnnotationList.tsx +5 -4
- package/src/components/Annotations/components/findNearestDatum.ts +75 -85
- package/src/components/Annotations/helpers/getVisibleAnnotations.ts +38 -0
- package/src/components/AreaChart/components/AreaChart.Stacked.jsx +1 -2
- package/src/components/Axis/BottomAxis.tsx +270 -0
- package/src/components/Axis/Categorical.Axis.tsx +6 -7
- package/src/components/Axis/LeftAxis.tsx +404 -0
- package/src/components/Axis/LeftAxisGridlines.tsx +77 -0
- package/src/components/Axis/PairedBarAxis.tsx +186 -0
- package/src/components/Axis/README.md +94 -0
- package/src/components/Axis/RightAxis.tsx +108 -0
- package/src/components/Axis/axis.constants.ts +21 -0
- package/src/components/Axis/index.ts +7 -0
- package/src/components/BarChart/components/BarChart.Horizontal.tsx +178 -24
- package/src/components/BarChart/components/BarChart.StackedHorizontal.tsx +3 -1
- package/src/components/BarChart/components/BarChart.StackedVertical.tsx +1 -0
- package/src/components/BarChart/components/BarChart.Vertical.tsx +6 -8
- package/src/components/BarChart/components/BarChart.tsx +7 -1
- package/src/components/BarChart/components/context.tsx +1 -0
- package/src/components/BarChart/helpers/useBarChart.ts +14 -2
- package/src/components/Brush/BrushSelector.tsx +1390 -0
- package/src/components/Brush/MiniChartPreview.tsx +400 -0
- package/src/components/DeviationBar.jsx +9 -7
- package/src/components/EditorPanel/EditorPanel.tsx +2734 -2595
- package/src/components/EditorPanel/components/Panels/Panel.Annotate.tsx +60 -22
- package/src/components/EditorPanel/components/Panels/Panel.ForestPlotSettings.tsx +56 -34
- package/src/components/EditorPanel/components/Panels/Panel.General.tsx +137 -30
- package/src/components/EditorPanel/components/Panels/Panel.PatternSettings.tsx +2 -0
- package/src/components/EditorPanel/components/Panels/Panel.Radar.tsx +353 -0
- package/src/components/EditorPanel/components/Panels/Panel.Series.tsx +0 -1
- package/src/components/EditorPanel/components/Panels/Panel.SmallMultiples.tsx +30 -25
- package/src/components/EditorPanel/components/Panels/Panel.Visual.tsx +42 -28
- package/src/components/EditorPanel/components/Panels/index.tsx +2 -0
- package/src/components/EditorPanel/useEditorPermissions.ts +81 -39
- package/src/components/HorizonChart/HorizonChart.tsx +131 -0
- package/src/components/HorizonChart/components/HorizonBand.tsx +160 -0
- package/src/components/HorizonChart/helpers/calculateHorizonBands.ts +27 -0
- package/src/components/HorizonChart/helpers/getHorizonLayerColors.ts +40 -0
- package/src/components/HorizonChart/index.tsx +3 -0
- package/src/components/Legend/Legend.Component.tsx +52 -4
- package/src/components/Legend/Legend.tsx +4 -3
- package/src/components/Legend/LegendValueRange.tsx +77 -0
- package/src/components/Legend/helpers/createFormatLabels.tsx +164 -2
- package/src/components/Legend/helpers/generateValueRanges.ts +92 -0
- package/src/components/Legend/helpers/index.ts +10 -6
- package/src/components/LineChart/helpers/README.md +292 -0
- package/src/components/LineChart/helpers/labelPositioning.test.ts +245 -0
- package/src/components/LineChart/helpers/labelPositioning.ts +304 -0
- package/src/components/LineChart/index.tsx +44 -8
- package/src/components/LinearChart/README.md +109 -0
- package/src/components/LinearChart/VisualizationRenderer.tsx +267 -0
- package/src/components/LinearChart/linearChart.constants.ts +84 -0
- package/src/components/LinearChart/tests/LinearChart.test.tsx +201 -0
- package/src/components/LinearChart/tests/mockConfigContext.ts +129 -0
- package/src/components/LinearChart/utils/tickFormatting.ts +146 -0
- package/src/components/LinearChart.tsx +338 -1082
- package/src/components/PairedBarChart.jsx +20 -3
- package/src/components/PieChart/PieChart.tsx +1 -1
- package/src/components/RadarChart/RadarAxis.tsx +78 -0
- package/src/components/RadarChart/RadarChart.tsx +298 -0
- package/src/components/RadarChart/RadarGrid.tsx +64 -0
- package/src/components/RadarChart/RadarPolygon.tsx +91 -0
- package/src/components/RadarChart/helpers.ts +83 -0
- package/src/components/RadarChart/index.tsx +3 -0
- package/src/components/Regions/components/Regions.tsx +365 -122
- package/src/components/ScatterPlot/ScatterPlot.jsx +2 -2
- package/src/components/SmallMultiples/SmallMultipleTile.tsx +5 -1
- package/src/components/WarmingStripes/WarmingStripes.tsx +230 -0
- package/src/components/WarmingStripes/WarmingStripesGradientLegend.css +35 -0
- package/src/components/WarmingStripes/WarmingStripesGradientLegend.tsx +104 -0
- package/src/components/WarmingStripes/index.tsx +3 -0
- package/src/data/initial-state.js +17 -2
- package/src/helpers/calculateHorizontalBarCategoryLabelWidth.ts +57 -0
- package/src/helpers/getExcludedData.ts +4 -0
- package/src/helpers/getMinMax.ts +12 -7
- package/src/helpers/handleChartAriaLabels.ts +19 -19
- package/src/helpers/handleLineType.ts +22 -18
- package/src/helpers/sizeHelpers.ts +0 -20
- package/src/helpers/smallMultiplesHelpers.ts +1 -1
- package/src/hooks/useChartHoverAnalytics.tsx +10 -9
- package/src/hooks/useProgrammaticTooltip.ts +23 -2
- package/src/hooks/useScales.ts +18 -1
- package/src/hooks/useTooltip.tsx +34 -10
- package/src/scss/DataTable.scss +0 -4
- package/src/scss/main.scss +22 -3
- package/src/selectors/README.md +68 -0
- package/src/store/chart.reducer.ts +2 -0
- package/src/test/CdcChart.test.jsx +1 -1
- package/src/types/ChartConfig.ts +21 -0
- package/src/types/ChartContext.ts +1 -0
- package/src/types/Horizon.ts +64 -0
- package/src/types/Label.ts +1 -0
- package/src/utils/analyticsTracking.ts +19 -0
- package/LICENSE +0 -201
- package/src/components/Annotations/components/helpers/index.tsx +0 -46
- package/src/components/Brush/BrushChart.tsx +0 -128
- package/src/components/Brush/BrushController.tsx +0 -71
- package/src/components/Brush/types.tsx +0 -8
- package/src/components/BrushChart.tsx +0 -223
package/CLAUDE.local.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @cdc/chart — Package Rules
|
|
2
|
+
|
|
3
|
+
## Entry Point Pattern
|
|
4
|
+
- `CdcChart.tsx` (wrapper) — handles data fetching, config loading, CSV parsing. Does NOT set up state or context.
|
|
5
|
+
- `CdcChartComponent.tsx` (main, ~1540 lines) — sets up useReducer, both context providers, data transformation, and chart rendering orchestration.
|
|
6
|
+
- Do not confuse the two. Data loading changes go in the wrapper; rendering/state changes go in the main component.
|
|
7
|
+
|
|
8
|
+
## Chart Types
|
|
9
|
+
Each visualization type is a **separate component** in `src/components/`:
|
|
10
|
+
|
|
11
|
+
| visualizationType | Component | Notes |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `'Bar'` | `BarChart/` | Has sub-components: Horizontal, Vertical, StackedHorizontal, StackedVertical |
|
|
14
|
+
| `'Line'` | `LineChart/` | Circle and BumpCircle sub-components |
|
|
15
|
+
| `'Pie'` | `PieChart/` | |
|
|
16
|
+
| `'Scatter Plot'` | `ScatterPlot/` | |
|
|
17
|
+
| `'Area Chart'` | `AreaChart/` | |
|
|
18
|
+
| `'Box Plot'` | `BoxPlot/` | |
|
|
19
|
+
| `'Forest Plot'` | `ForestPlot/` | |
|
|
20
|
+
| `'Sankey'` | `Sankey/` | Uses d3-sankey |
|
|
21
|
+
| `'Bump Chart'` | `BumpChart/` | |
|
|
22
|
+
| `'Combo'` | `Combo/` | Mixed bar + line |
|
|
23
|
+
| `'Forecasting'` | `Forecasting/` | |
|
|
24
|
+
| `'Deviation Bar'` | `DeviationBar/` | |
|
|
25
|
+
| `'Paired Bar'` | `PairedBar/` | |
|
|
26
|
+
| `'Spark Line'` | `Sparkline/` | |
|
|
27
|
+
| `'Warming Stripes'` | `WarmingStripes/` | |
|
|
28
|
+
|
|
29
|
+
CdcChartComponent routes to the correct component based on `config.visualizationType`:
|
|
30
|
+
- Pie → `<PieChart />`
|
|
31
|
+
- Sankey → `<SankeyChart />`
|
|
32
|
+
- Spark Line → `<SparkLine />`
|
|
33
|
+
- Everything else → `<LinearChart />` (shared SVG container)
|
|
34
|
+
|
|
35
|
+
## State Management
|
|
36
|
+
|
|
37
|
+
### Actions (16 types in `store/chart.actions.ts`):
|
|
38
|
+
`SET_CONFIG`, `UPDATE_CONFIG`, `SET_COLOR_SCALE`, `SET_STATE_DATA`, `SET_EXCLUDED_DATA`, `SET_FILTERED_DATA`, `SET_SERIES_HIGHLIGHT`, `SET_VIEWPORT`, `SET_VIZ_VIEWPORT`, `SET_DIMENSIONS`, `SET_CONTAINER`, `SET_LOADED_EVENT`, `SET_DRAG_ANNOTATIONS`, `SET_LOADING`, `SET_BRUSH_DATA`
|
|
39
|
+
|
|
40
|
+
### Context (`ConfigContext.tsx`):
|
|
41
|
+
- `ConfigContext` — read-only state (ChartContext type)
|
|
42
|
+
- `ChartDispatchContext` — dispatch function
|
|
43
|
+
- ChartContext provides: `config`, `colorScale`, `transformedData`, `rawData`, `tableData`, formatting functions (`formatDate`, `formatNumber`, `parseDate`), accessibility helpers, refs (`legendRef`, `parentRef`, `svgRef`), viewport info, and editor flags.
|
|
44
|
+
|
|
45
|
+
## Key Hooks (in `src/hooks/`)
|
|
46
|
+
- `useScales` (528 lines) — generates xScale, yScale, seriesScale for all chart types. Returns `{ xScale, yScale, seriesScale, min, max, leftMax, rightMax }`.
|
|
47
|
+
- `useTooltip` (720 lines) — tooltip mouse handlers, series filtering, formatting. Returns handlers and `TooltipListItem` component.
|
|
48
|
+
- `useReduceData` — memoized min/max/stats computation.
|
|
49
|
+
- `useRightAxis` — dual Y-axis support (series can specify `axis: 'right'`).
|
|
50
|
+
- `useHighlightedBars` — bar highlighting logic.
|
|
51
|
+
- `useIntersectionObserver` — lazy loading / viewport detection.
|
|
52
|
+
|
|
53
|
+
## Where to Put New Code
|
|
54
|
+
|
|
55
|
+
| What you're adding | Where it goes |
|
|
56
|
+
|---|---|
|
|
57
|
+
| New chart type | `src/components/<ChartType>/` with `index.tsx` exporting main component |
|
|
58
|
+
| Chart-specific helper | `src/helpers/<name>.ts` |
|
|
59
|
+
| Chart-specific hook | `src/hooks/use<Name>.ts` |
|
|
60
|
+
| Chart-specific type | `src/types/<Name>.ts` |
|
|
61
|
+
| New action | `src/store/chart.actions.ts` (add type) + `src/store/chart.reducer.ts` (add case) |
|
|
62
|
+
| Story | `src/_stories/<ChartType>.stories.tsx` with mock data in `src/_stories/_mock/` |
|
|
63
|
+
|
|
64
|
+
## Non-Obvious Patterns
|
|
65
|
+
- **Runtime config**: `config.runtime` is computed at render time by `getNewRuntime()` — contains `seriesKeys`, `seriesLabelsAll`, `barSeriesKeys`, `lineSeriesKeys`. Not part of initial state.
|
|
66
|
+
- **Dynamic categories**: Series can have `dynamicCategory` field where the series key becomes a category value from pivoted data. Check `originalDataKey` for the source column.
|
|
67
|
+
- **Brush data priority**: `getTransformedData()` uses brushData > filteredData > excludedData (first non-empty wins).
|
|
68
|
+
- **Two viewports**: `currentViewport` = overall container size, `vizViewport` = chart area only. Tick counts and legend layout depend on these.
|
|
69
|
+
- **Color scale precedence**: `customColorsOrdered` (1:1 mapping) > `customColors` > palette name > fallback palette.
|
|
70
|
+
- **Preliminary data / suppression**: `config.preliminaryData` stores effect/suppression icons that affect legend, tooltips, and line styles.
|
|
71
|
+
- **Image ID**: Each chart gets a unique `imageId` (`cove-<random>`) for SVG gradient/pattern IDs to avoid collisions when multiple charts are on one page.
|
|
72
|
+
- **Line-to-bar conversion**: `allowLineToBarGraph` + `isConvertLineToBarGraph()` — line charts can auto-convert to bars under certain conditions.
|
|
73
|
+
- **Small multiples**: `config.smallMultiples.mode` can be `'by-column'` or `'by-series'`. Each tile gets its own data slice. `synchronizedTooltips` enables cross-tile hover.
|
|
74
|
+
|
|
75
|
+
## SCSS
|
|
76
|
+
- `src/scss/main.scss` — all styles scoped under `.cdc-open-viz-module.type-chart`
|
|
77
|
+
- Imports `@cdc/core/styles/utils/breakpoints` for responsive mixins
|
|
78
|
+
- Animation keyframes: `revealLolly`, `dash`, `growBar`, `growBarH`
|
|
79
|
+
- Legend positions: `.legend-top`, `.legend-left`, `.legend-right`, `.legend-bottom`
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
|
3
|
-
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
|
4
|
-
* Released under MIT License
|
|
5
|
-
*/
|
|
6
|
-
/*! *****************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
|
|
9
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
purpose with or without fee is hereby granted.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
-
***************************************************************************** */
|
|
20
1
|
var mr = function(e, A) {
|
|
21
2
|
return mr = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, r) {
|
|
22
3
|
t.__proto__ = r;
|
|
@@ -3551,7 +3532,7 @@ var qi = 1, Ur = 2, Fr = 3, Tt = 4, St = 5, ji = 7, Ot = 8, hr = 9, dr = 10, Mt
|
|
|
3551
3532
|
var i = (t = A.getContext("webgl2")) !== null && t !== void 0 ? t : A.getContext("webgl");
|
|
3552
3533
|
if (i) {
|
|
3553
3534
|
var a = i.getContextAttributes();
|
|
3554
|
-
|
|
3535
|
+
a?.preserveDrawingBuffer === !1 && this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false", A);
|
|
3555
3536
|
}
|
|
3556
3537
|
s.drawImage(A, 0, 0);
|
|
3557
3538
|
}
|