@buildcanada/charts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +8 -0
- package/README.md +113 -0
- package/package.json +137 -0
- package/src/components/BodyPortal/BodyPortal.tsx +40 -0
- package/src/components/Button/Button.scss +110 -0
- package/src/components/Button/Button.tsx +101 -0
- package/src/components/Checkbox.scss +93 -0
- package/src/components/Checkbox.tsx +47 -0
- package/src/components/ExpandableToggle/ExpandableToggle.scss +123 -0
- package/src/components/ExpandableToggle/ExpandableToggle.tsx +60 -0
- package/src/components/GrapherTabIcon.tsx +156 -0
- package/src/components/GrapherTrendArrow.scss +16 -0
- package/src/components/GrapherTrendArrow.tsx +30 -0
- package/src/components/Halo/Halo.tsx +44 -0
- package/src/components/LabeledSwitch/LabeledSwitch.scss +109 -0
- package/src/components/LabeledSwitch/LabeledSwitch.tsx +62 -0
- package/src/components/MarkdownTextWrap/MarkdownTextWrap.tsx +1173 -0
- package/src/components/OverlayHeader.scss +18 -0
- package/src/components/OverlayHeader.tsx +29 -0
- package/src/components/RadioButton.scss +69 -0
- package/src/components/RadioButton.tsx +42 -0
- package/src/components/SimpleMarkdownText.tsx +89 -0
- package/src/components/TextInput.scss +17 -0
- package/src/components/TextInput.tsx +19 -0
- package/src/components/TextWrap/TextWrap.tsx +361 -0
- package/src/components/TextWrap/TextWrapUtils.ts +32 -0
- package/src/components/closeButton/CloseButton.scss +40 -0
- package/src/components/closeButton/CloseButton.tsx +27 -0
- package/src/components/index.ts +70 -0
- package/src/components/loadingIndicator/LoadingIndicator.scss +40 -0
- package/src/components/loadingIndicator/LoadingIndicator.tsx +28 -0
- package/src/components/markdown/remarkPlainLinks.ts +36 -0
- package/src/components/reactUtil.ts +20 -0
- package/src/components/stubs/CodeSnippet.tsx +19 -0
- package/src/components/stubs/DataCitation.tsx +16 -0
- package/src/components/stubs/IndicatorKeyData.tsx +45 -0
- package/src/components/stubs/IndicatorProcessing.tsx +15 -0
- package/src/components/stubs/IndicatorSources.tsx +15 -0
- package/src/components/styles/colors.scss +113 -0
- package/src/components/styles/mixins.scss +630 -0
- package/src/components/styles/typography.scss +579 -0
- package/src/components/styles/util.scss +89 -0
- package/src/components/styles/variables.scss +208 -0
- package/src/config/ChartsConfig.ts +163 -0
- package/src/config/ChartsProvider.tsx +157 -0
- package/src/config/index.ts +20 -0
- package/src/core-table/CoreTable.ts +1355 -0
- package/src/core-table/CoreTableColumns.ts +973 -0
- package/src/core-table/CoreTableUtils.ts +793 -0
- package/src/core-table/ErrorValues.ts +73 -0
- package/src/core-table/OwidTable.ts +1175 -0
- package/src/core-table/OwidTableSynthesizers.ts +272 -0
- package/src/core-table/OwidTableUtil.ts +76 -0
- package/src/core-table/Transforms.ts +484 -0
- package/src/core-table/index.ts +82 -0
- package/src/explorer/ColumnGrammar.ts +217 -0
- package/src/explorer/Explorer.sample.ts +212 -0
- package/src/explorer/Explorer.scss +148 -0
- package/src/explorer/Explorer.tsx +1283 -0
- package/src/explorer/ExplorerConstants.ts +85 -0
- package/src/explorer/ExplorerControls.scss +156 -0
- package/src/explorer/ExplorerControls.tsx +210 -0
- package/src/explorer/ExplorerDecisionMatrix.ts +471 -0
- package/src/explorer/ExplorerGrammar.ts +161 -0
- package/src/explorer/ExplorerProgram.ts +568 -0
- package/src/explorer/ExplorerUtils.ts +59 -0
- package/src/explorer/GrapherGrammar.ts +387 -0
- package/src/explorer/gridLang/GrammarUtils.ts +121 -0
- package/src/explorer/gridLang/GridCell.ts +298 -0
- package/src/explorer/gridLang/GridLangConstants.ts +255 -0
- package/src/explorer/gridLang/GridProgram.ts +311 -0
- package/src/explorer/gridLang/readme.md +17 -0
- package/src/explorer/index.ts +69 -0
- package/src/explorer/readme.md +19 -0
- package/src/explorer/urlMigrations/CO2UrlMigration.ts +46 -0
- package/src/explorer/urlMigrations/CovidUrlMigration.ts +37 -0
- package/src/explorer/urlMigrations/EnergyUrlMigration.ts +41 -0
- package/src/explorer/urlMigrations/ExplorerPageUrlMigrationSpec.ts +12 -0
- package/src/explorer/urlMigrations/ExplorerUrlMigrationUtils.ts +45 -0
- package/src/explorer/urlMigrations/ExplorerUrlMigrations.ts +33 -0
- package/src/explorer/urlMigrations/LegacyCovidUrlMigration.ts +144 -0
- package/src/explorer/urlMigrations/readme.md +39 -0
- package/src/grapher/axis/Axis.ts +973 -0
- package/src/grapher/axis/AxisConfig.ts +179 -0
- package/src/grapher/axis/AxisViews.tsx +597 -0
- package/src/grapher/barCharts/DiscreteBarChart.tsx +728 -0
- package/src/grapher/barCharts/DiscreteBarChartConstants.ts +60 -0
- package/src/grapher/barCharts/DiscreteBarChartHelpers.ts +338 -0
- package/src/grapher/barCharts/DiscreteBarChartState.ts +354 -0
- package/src/grapher/barCharts/DiscreteBarChartThumbnail.tsx +34 -0
- package/src/grapher/captionedChart/CaptionedChart.scss +61 -0
- package/src/grapher/captionedChart/CaptionedChart.tsx +523 -0
- package/src/grapher/captionedChart/Logos.tsx +141 -0
- package/src/grapher/captionedChart/LogosSVG.tsx +16 -0
- package/src/grapher/captionedChart/StaticChartRasterizer.tsx +178 -0
- package/src/grapher/captionedChart/assets/buildcanada-logo-square.svg +15 -0
- package/src/grapher/captionedChart/assets/buildcanada-logo.svg +15 -0
- package/src/grapher/captionedChart/assets/canadaspends.svg +7 -0
- package/src/grapher/captionedChart/readme.md +14 -0
- package/src/grapher/chart/Chart.tsx +62 -0
- package/src/grapher/chart/ChartAreaContent.tsx +172 -0
- package/src/grapher/chart/ChartDimension.ts +121 -0
- package/src/grapher/chart/ChartInterface.ts +83 -0
- package/src/grapher/chart/ChartManager.ts +113 -0
- package/src/grapher/chart/ChartTabs.ts +178 -0
- package/src/grapher/chart/ChartTypeMap.tsx +158 -0
- package/src/grapher/chart/ChartTypeSwitcher.tsx +26 -0
- package/src/grapher/chart/ChartUtils.tsx +364 -0
- package/src/grapher/chart/DimensionSlot.ts +45 -0
- package/src/grapher/chart/StaticChartWrapper.tsx +94 -0
- package/src/grapher/chart/guidedChartUtils.ts +82 -0
- package/src/grapher/color/BinningStrategies.ts +484 -0
- package/src/grapher/color/BinningStrategyEqualSizeBins.ts +132 -0
- package/src/grapher/color/BinningStrategyLogarithmic.ts +121 -0
- package/src/grapher/color/CategoricalColorAssigner.ts +97 -0
- package/src/grapher/color/ColorBrewerSchemes.ts +80 -0
- package/src/grapher/color/ColorConstants.ts +20 -0
- package/src/grapher/color/ColorScale.ts +339 -0
- package/src/grapher/color/ColorScaleBin.ts +147 -0
- package/src/grapher/color/ColorScaleConfig.ts +204 -0
- package/src/grapher/color/ColorScheme.ts +137 -0
- package/src/grapher/color/ColorSchemes.ts +149 -0
- package/src/grapher/color/ColorUtils.ts +86 -0
- package/src/grapher/color/CustomSchemes.ts +1772 -0
- package/src/grapher/color/readme.md +84 -0
- package/src/grapher/comparisonLine/ComparisonLine.tsx +31 -0
- package/src/grapher/comparisonLine/ComparisonLineConstants.ts +11 -0
- package/src/grapher/comparisonLine/ComparisonLineGenerator.ts +60 -0
- package/src/grapher/comparisonLine/ComparisonLineHelpers.ts +10 -0
- package/src/grapher/comparisonLine/CustomComparisonLine.tsx +159 -0
- package/src/grapher/comparisonLine/VerticalComparisonLine.tsx +208 -0
- package/src/grapher/controls/ActionButtons.scss +97 -0
- package/src/grapher/controls/ActionButtons.tsx +453 -0
- package/src/grapher/controls/CommandPalette.scss +50 -0
- package/src/grapher/controls/CommandPalette.tsx +74 -0
- package/src/grapher/controls/ContentSwitchers.scss +93 -0
- package/src/grapher/controls/ContentSwitchers.tsx +238 -0
- package/src/grapher/controls/Controls.scss +158 -0
- package/src/grapher/controls/DataTableFilterDropdown.scss +7 -0
- package/src/grapher/controls/DataTableFilterDropdown.tsx +168 -0
- package/src/grapher/controls/DataTableSearchField.scss +3 -0
- package/src/grapher/controls/DataTableSearchField.tsx +76 -0
- package/src/grapher/controls/Dropdown.scss +252 -0
- package/src/grapher/controls/Dropdown.tsx +235 -0
- package/src/grapher/controls/EntitySelectionToggle.tsx +135 -0
- package/src/grapher/controls/MapRegionDropdown.scss +3 -0
- package/src/grapher/controls/MapRegionDropdown.tsx +104 -0
- package/src/grapher/controls/MapResetButton.tsx +115 -0
- package/src/grapher/controls/MapZoomDropdown.scss +9 -0
- package/src/grapher/controls/MapZoomDropdown.tsx +270 -0
- package/src/grapher/controls/MapZoomToSelectionButton.tsx +87 -0
- package/src/grapher/controls/SearchField.scss +78 -0
- package/src/grapher/controls/SearchField.tsx +63 -0
- package/src/grapher/controls/SettingsMenu.scss +191 -0
- package/src/grapher/controls/SettingsMenu.tsx +399 -0
- package/src/grapher/controls/ShareMenu.scss +58 -0
- package/src/grapher/controls/ShareMenu.tsx +304 -0
- package/src/grapher/controls/SortIcon.tsx +39 -0
- package/src/grapher/controls/VerticalScrollContainer.tsx +263 -0
- package/src/grapher/controls/controlsRow/ControlsRow.tsx +168 -0
- package/src/grapher/controls/dropdown-icons.scss +4 -0
- package/src/grapher/controls/entityPicker/EntityPicker.scss +255 -0
- package/src/grapher/controls/entityPicker/EntityPicker.tsx +816 -0
- package/src/grapher/controls/entityPicker/EntityPickerConstants.ts +23 -0
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.scss +129 -0
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.tsx +463 -0
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelectorConstants.ts +3 -0
- package/src/grapher/controls/globalEntitySelector/readme.md +17 -0
- package/src/grapher/controls/settings/AbsRelToggle.tsx +64 -0
- package/src/grapher/controls/settings/AxisScaleToggle.tsx +53 -0
- package/src/grapher/controls/settings/FacetStrategySelector.tsx +110 -0
- package/src/grapher/controls/settings/FacetYDomainToggle.tsx +51 -0
- package/src/grapher/controls/settings/NoDataAreaToggle.tsx +38 -0
- package/src/grapher/controls/settings/ZoomToggle.tsx +36 -0
- package/src/grapher/core/EntitiesByRegionType.ts +174 -0
- package/src/grapher/core/EntityCodes.ts +19 -0
- package/src/grapher/core/EntityUrlBuilder.ts +200 -0
- package/src/grapher/core/FetchingGrapher.tsx +156 -0
- package/src/grapher/core/Grapher.tsx +760 -0
- package/src/grapher/core/GrapherAnalytics.ts +229 -0
- package/src/grapher/core/GrapherConstants.ts +173 -0
- package/src/grapher/core/GrapherState.tsx +3659 -0
- package/src/grapher/core/GrapherUrl.ts +184 -0
- package/src/grapher/core/GrapherUrlMigrations.ts +29 -0
- package/src/grapher/core/GrapherUseHelpers.tsx +147 -0
- package/src/grapher/core/LegacyToOwidTable.ts +841 -0
- package/src/grapher/core/grapher.entry.ts +5 -0
- package/src/grapher/core/grapher.scss +257 -0
- package/src/grapher/core/loadGrapherTableHelpers.ts +116 -0
- package/src/grapher/core/loadVariable.ts +104 -0
- package/src/grapher/core/relatedQuestion.ts +12 -0
- package/src/grapher/core/typography.scss +206 -0
- package/src/grapher/dataTable/DataTable.sample.ts +206 -0
- package/src/grapher/dataTable/DataTable.scss +249 -0
- package/src/grapher/dataTable/DataTable.tsx +1332 -0
- package/src/grapher/dataTable/DataTableConstants.ts +186 -0
- package/src/grapher/entitySelector/EntitySelector.scss +255 -0
- package/src/grapher/entitySelector/EntitySelector.tsx +1838 -0
- package/src/grapher/facet/FacetChart.tsx +943 -0
- package/src/grapher/facet/FacetChartConstants.ts +24 -0
- package/src/grapher/facet/FacetChartUtils.ts +51 -0
- package/src/grapher/facet/FacetMap.tsx +604 -0
- package/src/grapher/facet/FacetMapConstants.ts +23 -0
- package/src/grapher/facet/readme.md +13 -0
- package/src/grapher/focus/FocusArray.ts +79 -0
- package/src/grapher/footer/Footer.scss +63 -0
- package/src/grapher/footer/Footer.tsx +809 -0
- package/src/grapher/footer/FooterManager.ts +44 -0
- package/src/grapher/fullScreen/FullScreen.scss +11 -0
- package/src/grapher/fullScreen/FullScreen.tsx +61 -0
- package/src/grapher/header/Header.scss +35 -0
- package/src/grapher/header/Header.tsx +372 -0
- package/src/grapher/header/HeaderManager.ts +28 -0
- package/src/grapher/index.ts +157 -0
- package/src/grapher/interaction/InteractionState.ts +60 -0
- package/src/grapher/legend/HorizontalColorLegends.tsx +923 -0
- package/src/grapher/legend/LegendInteractionState.ts +40 -0
- package/src/grapher/legend/VerticalColorLegend.tsx +295 -0
- package/src/grapher/lineCharts/LineChart.tsx +968 -0
- package/src/grapher/lineCharts/LineChartConstants.ts +89 -0
- package/src/grapher/lineCharts/LineChartHelpers.ts +184 -0
- package/src/grapher/lineCharts/LineChartState.ts +394 -0
- package/src/grapher/lineCharts/LineChartThumbnail.tsx +437 -0
- package/src/grapher/lineCharts/Lines.tsx +258 -0
- package/src/grapher/lineLegend/LineLegend.tsx +723 -0
- package/src/grapher/lineLegend/LineLegendConstants.ts +9 -0
- package/src/grapher/lineLegend/LineLegendFilterAlgorithms.ts +143 -0
- package/src/grapher/lineLegend/LineLegendHelpers.ts +253 -0
- package/src/grapher/lineLegend/LineLegendTypes.ts +32 -0
- package/src/grapher/mapCharts/CanadaTopology.ts +17922 -0
- package/src/grapher/mapCharts/ChoroplethGlobe.tsx +949 -0
- package/src/grapher/mapCharts/ChoroplethMap.tsx +662 -0
- package/src/grapher/mapCharts/GeoFeatures.ts +184 -0
- package/src/grapher/mapCharts/GlobeController.ts +496 -0
- package/src/grapher/mapCharts/MapAnnotationPlacements.json +1040 -0
- package/src/grapher/mapCharts/MapAnnotationPlacements.ts +31 -0
- package/src/grapher/mapCharts/MapAnnotations.ts +723 -0
- package/src/grapher/mapCharts/MapChart.sample.ts +59 -0
- package/src/grapher/mapCharts/MapChart.scss +5 -0
- package/src/grapher/mapCharts/MapChart.tsx +720 -0
- package/src/grapher/mapCharts/MapChartConstants.ts +260 -0
- package/src/grapher/mapCharts/MapChartState.ts +416 -0
- package/src/grapher/mapCharts/MapChartThumbnail.tsx +25 -0
- package/src/grapher/mapCharts/MapComponents.tsx +338 -0
- package/src/grapher/mapCharts/MapConfig.ts +156 -0
- package/src/grapher/mapCharts/MapHelpers.ts +181 -0
- package/src/grapher/mapCharts/MapProjections.ts +49 -0
- package/src/grapher/mapCharts/MapSparkline.tsx +257 -0
- package/src/grapher/mapCharts/MapTooltip.scss +49 -0
- package/src/grapher/mapCharts/MapTooltip.tsx +409 -0
- package/src/grapher/mapCharts/MapTopology.ts +1766 -0
- package/src/grapher/mapCharts/d3-bboxCollide.js +204 -0
- package/src/grapher/mapCharts/d3-geo-projection.ts +198 -0
- package/src/grapher/modal/DownloadIcons.tsx +39 -0
- package/src/grapher/modal/DownloadModal.scss +300 -0
- package/src/grapher/modal/DownloadModal.tsx +1226 -0
- package/src/grapher/modal/EmbedModal.scss +40 -0
- package/src/grapher/modal/EmbedModal.tsx +160 -0
- package/src/grapher/modal/EntitySelectorModal.tsx +59 -0
- package/src/grapher/modal/Modal.scss +31 -0
- package/src/grapher/modal/Modal.tsx +90 -0
- package/src/grapher/modal/ModalHeader.scss +12 -0
- package/src/grapher/modal/ModalHeader.tsx +16 -0
- package/src/grapher/modal/SourcesDescriptions.scss +87 -0
- package/src/grapher/modal/SourcesDescriptions.tsx +89 -0
- package/src/grapher/modal/SourcesKeyDataTable.scss +49 -0
- package/src/grapher/modal/SourcesKeyDataTable.tsx +87 -0
- package/src/grapher/modal/SourcesModal.scss +301 -0
- package/src/grapher/modal/SourcesModal.tsx +568 -0
- package/src/grapher/noDataModal/NoDataModal.tsx +125 -0
- package/src/grapher/scatterCharts/ConnectedScatterLegend.tsx +143 -0
- package/src/grapher/scatterCharts/MultiColorPolyline.tsx +129 -0
- package/src/grapher/scatterCharts/NoDataSection.scss +14 -0
- package/src/grapher/scatterCharts/NoDataSection.tsx +56 -0
- package/src/grapher/scatterCharts/ScatterPlotChart.tsx +792 -0
- package/src/grapher/scatterCharts/ScatterPlotChartConstants.ts +157 -0
- package/src/grapher/scatterCharts/ScatterPlotChartState.ts +678 -0
- package/src/grapher/scatterCharts/ScatterPlotChartThumbnail.tsx +155 -0
- package/src/grapher/scatterCharts/ScatterPlotTooltip.tsx +560 -0
- package/src/grapher/scatterCharts/ScatterPoints.tsx +153 -0
- package/src/grapher/scatterCharts/ScatterPointsWithLabels.tsx +708 -0
- package/src/grapher/scatterCharts/ScatterSizeLegend.tsx +327 -0
- package/src/grapher/scatterCharts/ScatterUtils.ts +265 -0
- package/src/grapher/scatterCharts/Triangle.tsx +41 -0
- package/src/grapher/schema/README.md +33 -0
- package/src/grapher/schema/defaultGrapherConfig.ts +100 -0
- package/src/grapher/schema/grapher-schema.009.yaml +781 -0
- package/src/grapher/schema/migrations/helpers.ts +58 -0
- package/src/grapher/schema/migrations/migrate.ts +75 -0
- package/src/grapher/schema/migrations/migrations.ts +158 -0
- package/src/grapher/selection/MapSelectionArray.ts +99 -0
- package/src/grapher/selection/SelectionArray.ts +71 -0
- package/src/grapher/selection/readme.md +16 -0
- package/src/grapher/sidePanel/SidePanel.scss +10 -0
- package/src/grapher/sidePanel/SidePanel.tsx +23 -0
- package/src/grapher/slideInDrawer/SlideInDrawer.scss +57 -0
- package/src/grapher/slideInDrawer/SlideInDrawer.tsx +125 -0
- package/src/grapher/slideshowController/SlideShowController.tsx +43 -0
- package/src/grapher/slideshowController/readme.md +7 -0
- package/src/grapher/slopeCharts/MarkX.tsx +45 -0
- package/src/grapher/slopeCharts/Slope.tsx +102 -0
- package/src/grapher/slopeCharts/SlopeChart.tsx +1152 -0
- package/src/grapher/slopeCharts/SlopeChartConstants.ts +33 -0
- package/src/grapher/slopeCharts/SlopeChartHelpers.ts +73 -0
- package/src/grapher/slopeCharts/SlopeChartState.ts +392 -0
- package/src/grapher/slopeCharts/SlopeChartThumbnail.tsx +368 -0
- package/src/grapher/stackedCharts/AbstractStackedChartState.ts +370 -0
- package/src/grapher/stackedCharts/MarimekkoBars.tsx +190 -0
- package/src/grapher/stackedCharts/MarimekkoBarsForOneEntity.tsx +168 -0
- package/src/grapher/stackedCharts/MarimekkoChart.tsx +1144 -0
- package/src/grapher/stackedCharts/MarimekkoChartConstants.ts +112 -0
- package/src/grapher/stackedCharts/MarimekkoChartHelpers.ts +21 -0
- package/src/grapher/stackedCharts/MarimekkoChartState.ts +465 -0
- package/src/grapher/stackedCharts/MarimekkoChartThumbnail.tsx +168 -0
- package/src/grapher/stackedCharts/MarimekkoInternalLabels.tsx +124 -0
- package/src/grapher/stackedCharts/StackedAreaChart.tsx +678 -0
- package/src/grapher/stackedCharts/StackedAreaChartState.ts +34 -0
- package/src/grapher/stackedCharts/StackedAreaChartThumbnail.tsx +215 -0
- package/src/grapher/stackedCharts/StackedAreas.tsx +223 -0
- package/src/grapher/stackedCharts/StackedBarChart.tsx +619 -0
- package/src/grapher/stackedCharts/StackedBarChartState.ts +80 -0
- package/src/grapher/stackedCharts/StackedBarChartThumbnail.tsx +220 -0
- package/src/grapher/stackedCharts/StackedBarSegment.tsx +87 -0
- package/src/grapher/stackedCharts/StackedBars.tsx +102 -0
- package/src/grapher/stackedCharts/StackedConstants.ts +109 -0
- package/src/grapher/stackedCharts/StackedDiscreteBarChart.tsx +270 -0
- package/src/grapher/stackedCharts/StackedDiscreteBarChartState.ts +296 -0
- package/src/grapher/stackedCharts/StackedDiscreteBarChartThumbnail.tsx +27 -0
- package/src/grapher/stackedCharts/StackedDiscreteBars.tsx +648 -0
- package/src/grapher/stackedCharts/StackedUtils.ts +142 -0
- package/src/grapher/tabs/Tabs.scss +169 -0
- package/src/grapher/tabs/Tabs.tsx +54 -0
- package/src/grapher/tabs/TabsWithDropdown.scss +62 -0
- package/src/grapher/tabs/TabsWithDropdown.tsx +114 -0
- package/src/grapher/testData/OwidTestData.sample.ts +273 -0
- package/src/grapher/testData/OwidTestData.ts +64 -0
- package/src/grapher/timeline/TimelineComponent.scss +139 -0
- package/src/grapher/timeline/TimelineComponent.tsx +658 -0
- package/src/grapher/timeline/TimelineController.ts +368 -0
- package/src/grapher/timeline/readme.md +7 -0
- package/src/grapher/tooltip/Tooltip.scss +510 -0
- package/src/grapher/tooltip/Tooltip.tsx +294 -0
- package/src/grapher/tooltip/TooltipContents.tsx +383 -0
- package/src/grapher/tooltip/TooltipProps.ts +123 -0
- package/src/grapher/tooltip/TooltipState.ts +81 -0
- package/src/grapher/verticalLabels/VerticalLabels.tsx +31 -0
- package/src/grapher/verticalLabels/VerticalLabelsState.ts +154 -0
- package/src/index.ts +226 -0
- package/src/styles/charts.scss +15 -0
- package/src/types/NominalType.ts +30 -0
- package/src/types/OwidOrigin.ts +18 -0
- package/src/types/OwidSource.ts +9 -0
- package/src/types/OwidVariable.ts +133 -0
- package/src/types/OwidVariableDisplayConfigInterface.ts +49 -0
- package/src/types/analyticsTypes.ts +54 -0
- package/src/types/dbTypes/Tags.ts +11 -0
- package/src/types/domainTypes/Archive.ts +139 -0
- package/src/types/domainTypes/Author.ts +28 -0
- package/src/types/domainTypes/ContentGraph.ts +76 -0
- package/src/types/domainTypes/CoreTableTypes.ts +305 -0
- package/src/types/domainTypes/DeployStatus.ts +23 -0
- package/src/types/domainTypes/Layout.ts +34 -0
- package/src/types/domainTypes/Posts.ts +34 -0
- package/src/types/domainTypes/Search.ts +299 -0
- package/src/types/domainTypes/Site.ts +8 -0
- package/src/types/domainTypes/StaticViz.ts +64 -0
- package/src/types/domainTypes/Toc.ts +11 -0
- package/src/types/domainTypes/Tombstone.ts +19 -0
- package/src/types/domainTypes/Various.ts +79 -0
- package/src/types/gdocTypes/Gdoc.ts +280 -0
- package/src/types/grapherTypes/BinningStrategyTypes.ts +46 -0
- package/src/types/grapherTypes/GrapherConstants.ts +53 -0
- package/src/types/grapherTypes/GrapherTypes.ts +743 -0
- package/src/types/index.ts +316 -0
- package/src/types/wordpressTypes/WordpressTypes.ts +9 -0
- package/src/utils/Bounds.ts +439 -0
- package/src/utils/BrowserUtils.ts +12 -0
- package/src/utils/FuzzySearch.ts +74 -0
- package/src/utils/MultiDimDataPageConfig.ts +31 -0
- package/src/utils/OwidVariable.ts +82 -0
- package/src/utils/PointVector.ts +97 -0
- package/src/utils/PromiseCache.ts +36 -0
- package/src/utils/PromiseSwitcher.ts +52 -0
- package/src/utils/TimeBounds.ts +130 -0
- package/src/utils/Tippy.tsx +57 -0
- package/src/utils/Util.ts +2369 -0
- package/src/utils/archival/archivalDate.ts +48 -0
- package/src/utils/dayjs.ts +32 -0
- package/src/utils/formatValue.ts +242 -0
- package/src/utils/grapherConfigUtils.ts +81 -0
- package/src/utils/image.ts +225 -0
- package/src/utils/index.ts +318 -0
- package/src/utils/isPresent.ts +5 -0
- package/src/utils/metadataHelpers.ts +329 -0
- package/src/utils/persistable/Persistable.ts +82 -0
- package/src/utils/persistable/readme.md +50 -0
- package/src/utils/regions.json +5635 -0
- package/src/utils/regions.ts +463 -0
- package/src/utils/serializers.ts +16 -0
- package/src/utils/string.ts +42 -0
- package/src/utils/urls/Url.ts +195 -0
- package/src/utils/urls/UrlMigration.ts +10 -0
- package/src/utils/urls/UrlUtils.ts +54 -0
- package/src/utils/urls/readme.md +90 -0
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OwidChartDimensionInterface,
|
|
3
|
+
OwidVariableRoundingMode,
|
|
4
|
+
} from "../OwidVariableDisplayConfigInterface.js"
|
|
5
|
+
import { ColumnSlugs, EntityName } from "../domainTypes/CoreTableTypes.js"
|
|
6
|
+
import { AxisAlign, Position } from "../domainTypes/Layout.js"
|
|
7
|
+
import { Integer, OwidVariableId } from "../domainTypes/Various.js"
|
|
8
|
+
import { DetailDictionary } from "../gdocTypes/Gdoc.js"
|
|
9
|
+
import {
|
|
10
|
+
GRAPHER_CHART_TYPES,
|
|
11
|
+
GRAPHER_MAP_TYPE,
|
|
12
|
+
GRAPHER_TAB_NAMES,
|
|
13
|
+
GRAPHER_TAB_CONFIG_OPTIONS,
|
|
14
|
+
GRAPHER_TAB_QUERY_PARAMS,
|
|
15
|
+
} from "./GrapherConstants.js"
|
|
16
|
+
import { OwidVariableDataMetadataDimensions } from "../OwidVariable.js"
|
|
17
|
+
import { ArchiveContext } from "../domainTypes/Archive.js"
|
|
18
|
+
import {
|
|
19
|
+
BinningStrategyIncludingManual,
|
|
20
|
+
MidpointMode,
|
|
21
|
+
} from "./BinningStrategyTypes.js"
|
|
22
|
+
|
|
23
|
+
// Utility type that marks all properties of T that may be undefined as optional.
|
|
24
|
+
export type UndefinedToOptional<T> = Partial<T> & {
|
|
25
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Box {
|
|
29
|
+
x: number
|
|
30
|
+
y: number
|
|
31
|
+
width: number
|
|
32
|
+
height: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// TODO: remove duplicate definition, also available in CoreTable
|
|
36
|
+
export enum SortOrder {
|
|
37
|
+
asc = "asc",
|
|
38
|
+
desc = "desc",
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export enum SortBy {
|
|
42
|
+
custom = "custom",
|
|
43
|
+
entityName = "entityName",
|
|
44
|
+
column = "column",
|
|
45
|
+
total = "total",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface SortConfig {
|
|
49
|
+
sortBy?: SortBy
|
|
50
|
+
sortOrder?: SortOrder
|
|
51
|
+
sortColumnSlug?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type Year = Integer
|
|
55
|
+
export type Color = string
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A concrete point in time (year or date). It's always supposed to be a finite number, but we
|
|
59
|
+
* cannot enforce this in TypeScript.
|
|
60
|
+
*/
|
|
61
|
+
export type Time = Integer
|
|
62
|
+
export type TimeRange = [Time, Time]
|
|
63
|
+
|
|
64
|
+
export type PrimitiveType = number | string | boolean
|
|
65
|
+
export type ValueRange = [number, number]
|
|
66
|
+
|
|
67
|
+
export enum ScaleType {
|
|
68
|
+
linear = "linear",
|
|
69
|
+
log = "log",
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export enum KeyChartLevel {
|
|
73
|
+
None = 0, // not a key chart, will not show in the all charts block of the related topic page
|
|
74
|
+
Bottom = 1, // chart will show at the bottom of the all charts block
|
|
75
|
+
Middle = 2, // chart will show in the middle of the all charts block
|
|
76
|
+
Top = 3, // chart will show at the top of the all charts block
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* How to mark a detail on demand:
|
|
81
|
+
* - superscript: add a superscript reference number
|
|
82
|
+
* - underline: underline the text
|
|
83
|
+
* - none: don't mark it
|
|
84
|
+
*/
|
|
85
|
+
export type DetailsMarker = "superscript" | "underline" | "none"
|
|
86
|
+
|
|
87
|
+
export interface BasicChartInformation {
|
|
88
|
+
title: string
|
|
89
|
+
slug: string
|
|
90
|
+
variantName?: string | null
|
|
91
|
+
}
|
|
92
|
+
export interface RelatedChart extends BasicChartInformation {
|
|
93
|
+
chartId: number
|
|
94
|
+
keyChartLevel?: KeyChartLevel
|
|
95
|
+
archiveContext?: ArchiveContext | undefined
|
|
96
|
+
}
|
|
97
|
+
export enum DimensionProperty {
|
|
98
|
+
y = "y",
|
|
99
|
+
x = "x",
|
|
100
|
+
size = "size",
|
|
101
|
+
color = "color",
|
|
102
|
+
table = "table",
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// see CoreTableConstants.ts
|
|
106
|
+
export type ColumnSlug = string // a url friendly name for a column in a table. cannot have spaces
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* An unbounded value (±Infinity) or a concrete point in time (year or date).
|
|
110
|
+
*/
|
|
111
|
+
export type TimeBound = number
|
|
112
|
+
|
|
113
|
+
export type TimeBounds = [TimeBound, TimeBound]
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The two special TimeBound values: unbounded left & unbounded right.
|
|
117
|
+
*/
|
|
118
|
+
export enum TimeBoundValue {
|
|
119
|
+
negativeInfinity = -Infinity,
|
|
120
|
+
positiveInfinity = Infinity,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export enum TimeBoundValueStr {
|
|
124
|
+
unboundedLeft = "earliest",
|
|
125
|
+
unboundedRight = "latest",
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Time tolerance strategy used for maps
|
|
130
|
+
*/
|
|
131
|
+
export enum ToleranceStrategy {
|
|
132
|
+
closest = "closest",
|
|
133
|
+
backwards = "backwards",
|
|
134
|
+
forwards = "forwards",
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface ToleranceOptions {
|
|
138
|
+
toleranceOverride?: number
|
|
139
|
+
toleranceStrategyOverride?: ToleranceStrategy
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export enum AxisMinMaxValueStr {
|
|
143
|
+
auto = "auto",
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// We currently have the notion of "modes", where you can either select 1 entity, or select multiple entities, or not change the selection at all.
|
|
147
|
+
// Todo: can we remove?
|
|
148
|
+
export enum EntitySelectionMode {
|
|
149
|
+
MultipleEntities = "add-country",
|
|
150
|
+
SingleEntity = "change-country",
|
|
151
|
+
Disabled = "disabled",
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export enum StackMode {
|
|
155
|
+
absolute = "absolute",
|
|
156
|
+
relative = "relative",
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export enum FacetStrategy {
|
|
160
|
+
none = "none", // No facets
|
|
161
|
+
entity = "entity", // One chart for each country/entity
|
|
162
|
+
metric = "metric", // One chart for each Y column
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export enum FacetAxisDomain {
|
|
166
|
+
independent = "independent", // all facets have their own y domain
|
|
167
|
+
// TODO: rename to "uniform", since "shared" has a different meaning when
|
|
168
|
+
// axes are being plotted (it means the axis is omitted).
|
|
169
|
+
// Need to migrate Grapher & Explorer configs.
|
|
170
|
+
shared = "shared", // all facets share the same y domain
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export enum SeriesStrategy {
|
|
174
|
+
column = "column", // One line per column
|
|
175
|
+
entity = "entity", // One line per entity
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface ChartErrorInfo {
|
|
179
|
+
reason: string // no chart error if set to the empty string
|
|
180
|
+
help?: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type SeriesName = string
|
|
184
|
+
|
|
185
|
+
export type SeriesColorMap = Map<SeriesName, Color>
|
|
186
|
+
|
|
187
|
+
export type GrapherMapType = typeof GRAPHER_MAP_TYPE
|
|
188
|
+
export type GrapherChartType = keyof typeof GRAPHER_CHART_TYPES
|
|
189
|
+
export type GrapherChartOrMapType = GrapherChartType | GrapherMapType
|
|
190
|
+
|
|
191
|
+
export type GrapherTabConfigOption = keyof typeof GRAPHER_TAB_CONFIG_OPTIONS
|
|
192
|
+
export type GrapherTabQueryParam = keyof typeof GRAPHER_TAB_QUERY_PARAMS
|
|
193
|
+
export type GrapherTabName = keyof typeof GRAPHER_TAB_NAMES
|
|
194
|
+
|
|
195
|
+
export interface RelatedQuestionsConfig {
|
|
196
|
+
text: string
|
|
197
|
+
url: string
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export enum MissingDataStrategy {
|
|
201
|
+
auto = "auto", // pick default strategy based on chart type
|
|
202
|
+
hide = "hide", // hide entities with missing data
|
|
203
|
+
show = "show", // show entities with missing data
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// When a user hovers over a connected series line in a ScatterPlot we show
|
|
207
|
+
// a label for each point. By default that value will be from the "year" column
|
|
208
|
+
// but by changing this option the column used for the x or y axis could be used instead.
|
|
209
|
+
export enum ScatterPointLabelStrategy {
|
|
210
|
+
year = "year",
|
|
211
|
+
x = "x",
|
|
212
|
+
y = "y",
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export enum GrapherTooltipAnchor {
|
|
216
|
+
// the tooltip is positioned relative to the mouse cursor
|
|
217
|
+
mouse = "mouse",
|
|
218
|
+
// the tooltip is pinned to the bottom of the screen
|
|
219
|
+
bottom = "bottom",
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface AnnotationFieldsInTitle {
|
|
223
|
+
entity?: boolean
|
|
224
|
+
time?: boolean
|
|
225
|
+
changeInPrefix?: boolean
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface Tickmark {
|
|
229
|
+
value: number
|
|
230
|
+
priority: number
|
|
231
|
+
faint?: boolean
|
|
232
|
+
gridLineOnly?: boolean
|
|
233
|
+
solid?: boolean // mostly for labelling domain start (e.g. 0)
|
|
234
|
+
}
|
|
235
|
+
export interface TickFormattingOptions {
|
|
236
|
+
roundingMode?: OwidVariableRoundingMode
|
|
237
|
+
numDecimalPlaces?: number
|
|
238
|
+
numSignificantFigures?: number
|
|
239
|
+
unit?: string
|
|
240
|
+
trailingZeroes?: boolean
|
|
241
|
+
spaceBeforeUnit?: boolean
|
|
242
|
+
useNoBreakSpace?: boolean
|
|
243
|
+
showPlus?: boolean
|
|
244
|
+
numberAbbreviation?: "short" | "long" | false
|
|
245
|
+
}
|
|
246
|
+
// Represents the actual entered configuration state in the editor
|
|
247
|
+
export interface AxisConfigInterface {
|
|
248
|
+
scaleType?: ScaleType
|
|
249
|
+
label?: string
|
|
250
|
+
min?: number | AxisMinMaxValueStr.auto
|
|
251
|
+
max?: number | AxisMinMaxValueStr.auto
|
|
252
|
+
canChangeScaleType?: boolean
|
|
253
|
+
removePointsOutsideDomain?: boolean
|
|
254
|
+
hideAxis?: boolean
|
|
255
|
+
hideTickLabels?: boolean
|
|
256
|
+
|
|
257
|
+
/** Hide the faint lines that are shown inside the plot (axis ticks may still be visible). */
|
|
258
|
+
hideGridlines?: boolean
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The *preferred* orientation of the axis.
|
|
262
|
+
* If the orientation is not supported by the axis, this parameter will be ignored.
|
|
263
|
+
*/
|
|
264
|
+
orient?: Position
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Whether the axis domain should be the same across faceted charts (if possible)
|
|
268
|
+
*/
|
|
269
|
+
facetDomain?: FacetAxisDomain
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Minimum pixels to take up.
|
|
273
|
+
* Dictates the minimum height for a HorizontalAxis, minimum width for a VerticalAxis.
|
|
274
|
+
*/
|
|
275
|
+
minSize?: number
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The padding between an axis label and an axis tick
|
|
279
|
+
*/
|
|
280
|
+
labelPadding?: number
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The padding between an axis tick and an axis gridline
|
|
284
|
+
*/
|
|
285
|
+
tickPadding?: number
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Extend scale to start & end on "nicer" round values.
|
|
289
|
+
* See: https://github.com/d3/d3-scale#continuous_nice
|
|
290
|
+
*/
|
|
291
|
+
nice?: boolean
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* The (rough) maximum number of ticks to show. Not a strict limit, more ticks may be shown.
|
|
295
|
+
* See: https://github.com/d3/d3-scale#continuous_ticks
|
|
296
|
+
*/
|
|
297
|
+
maxTicks?: number
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Custom ticks to use. Any automatic ticks are omitted.
|
|
301
|
+
* Note that the ticks will be omitted if they are outside the axis domain.
|
|
302
|
+
* To control the domain, use `min` and `max`.
|
|
303
|
+
*/
|
|
304
|
+
ticks?: Tickmark[]
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Tick formatting overrides. Allows things like omitting the unit and using
|
|
308
|
+
* short number abbreviations.
|
|
309
|
+
*/
|
|
310
|
+
tickFormattingOptions?: TickFormattingOptions
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* What to do when .place() is called on an axis that only contains a single
|
|
314
|
+
* domain value.
|
|
315
|
+
* Should the point be placed at the start, middle or end of the axis?
|
|
316
|
+
*/
|
|
317
|
+
singleValueAxisPointAlign?: AxisAlign
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* If given, think of the axis scale as a band scale, where each domain value
|
|
321
|
+
* occupies a fixed width. The axis is padded on both sides to reserve space
|
|
322
|
+
* for the outermost values.
|
|
323
|
+
*/
|
|
324
|
+
domainValues?: number[]
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface VerticalComparisonLineConfig {
|
|
328
|
+
xEquals: number // x-coordinate of the vertical line
|
|
329
|
+
label?: string
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface CustomComparisonLineConfig {
|
|
333
|
+
yEquals?: string // line equation like "2*x^2" or "sqrt(x)"; defaults to "x"
|
|
334
|
+
label?: string
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export type ComparisonLineConfig =
|
|
338
|
+
| VerticalComparisonLineConfig
|
|
339
|
+
| CustomComparisonLineConfig
|
|
340
|
+
|
|
341
|
+
export enum LogoOption {
|
|
342
|
+
owid = "owid",
|
|
343
|
+
"core+owid" = "core+owid",
|
|
344
|
+
"gv+owid" = "gv+owid",
|
|
345
|
+
buildcanada = "buildcanada",
|
|
346
|
+
"buildcanada-wide" = "buildcanada-wide",
|
|
347
|
+
canadaspends = "canadaspends",
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export interface ProjectionColumnInfo {
|
|
351
|
+
projectedSlug: ColumnSlug
|
|
352
|
+
historicalSlug: ColumnSlug
|
|
353
|
+
combinedSlug: ColumnSlug
|
|
354
|
+
slugForIsProjectionColumn: ColumnSlug
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface ColorScaleConfigInterface {
|
|
358
|
+
baseColorScheme?: ColorSchemeName
|
|
359
|
+
colorSchemeInvert?: boolean
|
|
360
|
+
binningStrategy: BinningStrategyIncludingManual
|
|
361
|
+
createBinForMidpoint?: boolean
|
|
362
|
+
minValue?: number
|
|
363
|
+
maxValue?: number
|
|
364
|
+
midpoint?: number
|
|
365
|
+
midpointMode?: MidpointMode
|
|
366
|
+
customNumericValues: number[]
|
|
367
|
+
customNumericLabels: (string | undefined | null)[]
|
|
368
|
+
customNumericColorsActive?: boolean
|
|
369
|
+
customNumericColors: (Color | undefined | null)[]
|
|
370
|
+
|
|
371
|
+
customCategoryColors: Record<string, string | undefined>
|
|
372
|
+
customCategoryLabels: Record<string, string | undefined>
|
|
373
|
+
customHiddenCategories: Record<string, true | undefined>
|
|
374
|
+
legendDescription?: string
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export const colorScaleConfigDefaults = {
|
|
378
|
+
binningStrategy: "auto",
|
|
379
|
+
customNumericValues: [],
|
|
380
|
+
customNumericLabels: [],
|
|
381
|
+
customNumericColors: [],
|
|
382
|
+
|
|
383
|
+
customCategoryColors: {},
|
|
384
|
+
customCategoryLabels: {},
|
|
385
|
+
customHiddenCategories: {},
|
|
386
|
+
} satisfies ColorScaleConfigInterface
|
|
387
|
+
|
|
388
|
+
export interface ColorSchemeInterface {
|
|
389
|
+
name: string
|
|
390
|
+
colorSets: Color[][] // Different color sets depending on how many distinct colors you want
|
|
391
|
+
singleColorScale?: boolean
|
|
392
|
+
isDistinct?: boolean
|
|
393
|
+
displayName?: string
|
|
394
|
+
colorMap?: Record<string, Color> // Optional mapping from categorical values to specific colors
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Note: TypeScript does not currently support extending or merging enums. Ideally we would have 2 enums here (one for custom and one for brewer) and then just merge them.
|
|
398
|
+
// https://github.com/microsoft/TypeScript/issues/17592
|
|
399
|
+
export enum ColorSchemeName {
|
|
400
|
+
// Brewer schemes:
|
|
401
|
+
YlGn = "YlGn",
|
|
402
|
+
YlGnBu = "YlGnBu",
|
|
403
|
+
GnBu = "GnBu",
|
|
404
|
+
BuGn = "BuGn",
|
|
405
|
+
PuBuGn = "PuBuGn",
|
|
406
|
+
BuPu = "BuPu",
|
|
407
|
+
RdPu = "RdPu",
|
|
408
|
+
PuRd = "PuRd",
|
|
409
|
+
OrRd = "OrRd",
|
|
410
|
+
YlOrRd = "YlOrRd",
|
|
411
|
+
YlOrBr = "YlOrBr",
|
|
412
|
+
Purples = "Purples",
|
|
413
|
+
Blues = "Blues",
|
|
414
|
+
Greens = "Greens",
|
|
415
|
+
Oranges = "Oranges",
|
|
416
|
+
Reds = "Reds",
|
|
417
|
+
Greys = "Greys",
|
|
418
|
+
PuOr = "PuOr",
|
|
419
|
+
BrBG = "BrBG",
|
|
420
|
+
PRGn = "PRGn",
|
|
421
|
+
PiYG = "PiYG",
|
|
422
|
+
RdBu = "RdBu",
|
|
423
|
+
RdGy = "RdGy",
|
|
424
|
+
RdYlBu = "RdYlBu",
|
|
425
|
+
Spectral = "Spectral",
|
|
426
|
+
RdYlGn = "RdYlGn",
|
|
427
|
+
Accent = "Accent",
|
|
428
|
+
Dark2 = "Dark2",
|
|
429
|
+
Paired = "Paired",
|
|
430
|
+
Pastel1 = "Pastel1",
|
|
431
|
+
Pastel2 = "Pastel2",
|
|
432
|
+
Set1 = "Set1",
|
|
433
|
+
Set2 = "Set2",
|
|
434
|
+
Set3 = "Set3",
|
|
435
|
+
PuBu = "PuBu",
|
|
436
|
+
|
|
437
|
+
// Custom schemes:
|
|
438
|
+
Magma = "Magma",
|
|
439
|
+
Inferno = "Inferno",
|
|
440
|
+
Plasma = "Plasma",
|
|
441
|
+
Viridis = "Viridis",
|
|
442
|
+
continents = "continents",
|
|
443
|
+
stackedAreaDefault = "stackedAreaDefault",
|
|
444
|
+
"owid-distinct" = "owid-distinct",
|
|
445
|
+
SingleColorDenim = "SingleColorDenim",
|
|
446
|
+
SingleColorTeal = "SingleColorTeal",
|
|
447
|
+
SingleColorPurple = "SingleColorPurple",
|
|
448
|
+
SingleColorDustyCoral = "SingleColorDustyCoral",
|
|
449
|
+
SingleColorDarkCopper = "SingleColorDarkCopper",
|
|
450
|
+
OwidCategoricalA = "OwidCategoricalA",
|
|
451
|
+
OwidCategoricalB = "OwidCategoricalB",
|
|
452
|
+
OwidCategoricalC = "OwidCategoricalC",
|
|
453
|
+
OwidCategoricalD = "OwidCategoricalD",
|
|
454
|
+
OwidCategoricalE = "OwidCategoricalE",
|
|
455
|
+
OwidEnergy = "OwidEnergy",
|
|
456
|
+
OwidEnergyLines = "OwidEnergyLines",
|
|
457
|
+
OwidDistinctLines = "OwidDistinctLines",
|
|
458
|
+
BinaryMapPaletteA = "BinaryMapPaletteA",
|
|
459
|
+
BinaryMapPaletteB = "BinaryMapPaletteB",
|
|
460
|
+
BinaryMapPaletteC = "BinaryMapPaletteC",
|
|
461
|
+
BinaryMapPaletteD = "BinaryMapPaletteD",
|
|
462
|
+
BinaryMapPaletteE = "BinaryMapPaletteE",
|
|
463
|
+
SingleColorGradientDenim = "SingleColorGradientDenim",
|
|
464
|
+
SingleColorGradientTeal = "SingleColorGradientTeal",
|
|
465
|
+
SingleColorGradientPurple = "SingleColorGradientPurple",
|
|
466
|
+
SingleColorGradientDustyCoral = "SingleColorGradientDustyCoral",
|
|
467
|
+
SingleColorGradientDarkCopper = "SingleColorGradientDarkCopper",
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export enum MapRegionName {
|
|
471
|
+
World = "World",
|
|
472
|
+
Africa = "Africa",
|
|
473
|
+
NorthAmerica = "NorthAmerica",
|
|
474
|
+
SouthAmerica = "SouthAmerica",
|
|
475
|
+
Asia = "Asia",
|
|
476
|
+
Europe = "Europe",
|
|
477
|
+
Oceania = "Oceania",
|
|
478
|
+
Canada = "Canada",
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// 'World' doesn't make sense as a region for the globe
|
|
482
|
+
export type GlobeRegionName = Exclude<MapRegionName, MapRegionName.World>
|
|
483
|
+
|
|
484
|
+
export interface GlobeConfig {
|
|
485
|
+
isActive: boolean
|
|
486
|
+
rotation: [number, number]
|
|
487
|
+
zoom: number
|
|
488
|
+
focusCountry?: EntityName
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export interface MapConfigInterface {
|
|
492
|
+
columnSlug?: ColumnSlug
|
|
493
|
+
time?: TimeBound | TimeBoundValueStr
|
|
494
|
+
startTime?: TimeBound | TimeBoundValueStr
|
|
495
|
+
timeTolerance?: number
|
|
496
|
+
toleranceStrategy?: ToleranceStrategy
|
|
497
|
+
hideTimeline?: boolean
|
|
498
|
+
region?: MapRegionName
|
|
499
|
+
globe?: GlobeConfig
|
|
500
|
+
colorScale?: Partial<ColorScaleConfigInterface>
|
|
501
|
+
tooltipUseCustomLabels?: boolean
|
|
502
|
+
selectedEntityNames?: EntityName[]
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// This configuration represents the entire persistent state of a grapher
|
|
506
|
+
// Ideally, this is also all of the interaction state: when a grapher is saved and loaded again
|
|
507
|
+
// under the same rendering conditions it ought to remain visually identical
|
|
508
|
+
export interface GrapherInterface extends SortConfig {
|
|
509
|
+
$schema?: string
|
|
510
|
+
chartTypes?: GrapherChartType[]
|
|
511
|
+
id?: number
|
|
512
|
+
version?: number
|
|
513
|
+
slug?: string
|
|
514
|
+
title?: string
|
|
515
|
+
subtitle?: string
|
|
516
|
+
sourceDesc?: string
|
|
517
|
+
note?: string
|
|
518
|
+
hideAnnotationFieldsInTitle?: AnnotationFieldsInTitle
|
|
519
|
+
minTime?: TimeBound | TimeBoundValueStr
|
|
520
|
+
maxTime?: TimeBound | TimeBoundValueStr
|
|
521
|
+
timelineMinTime?: Time | TimeBoundValueStr
|
|
522
|
+
timelineMaxTime?: Time | TimeBoundValueStr
|
|
523
|
+
dimensions?: OwidChartDimensionInterface[]
|
|
524
|
+
addCountryMode?: EntitySelectionMode
|
|
525
|
+
comparisonLines?: ComparisonLineConfig[]
|
|
526
|
+
stackMode?: StackMode
|
|
527
|
+
|
|
528
|
+
showNoDataArea?: boolean
|
|
529
|
+
hideLegend?: boolean
|
|
530
|
+
logo?: LogoOption
|
|
531
|
+
hideLogo?: boolean
|
|
532
|
+
hideRelativeToggle?: boolean
|
|
533
|
+
entityType?: string
|
|
534
|
+
entityTypePlural?: string
|
|
535
|
+
hideTimeline?: boolean
|
|
536
|
+
zoomToSelection?: boolean
|
|
537
|
+
showYearLabels?: boolean // Always show year in labels for bar charts
|
|
538
|
+
hasMapTab?: boolean
|
|
539
|
+
tab?: GrapherTabConfigOption
|
|
540
|
+
relatedQuestions?: RelatedQuestionsConfig[]
|
|
541
|
+
details?: DetailDictionary
|
|
542
|
+
internalNotes?: string
|
|
543
|
+
variantName?: string
|
|
544
|
+
originUrl?: string
|
|
545
|
+
isPublished?: boolean
|
|
546
|
+
baseColorScheme?: ColorSchemeName
|
|
547
|
+
invertColorScheme?: boolean
|
|
548
|
+
hideConnectedScatterLines?: boolean // Hides lines between points when timeline spans multiple years. Requested by core-econ for certain charts
|
|
549
|
+
hideScatterLabels?: boolean
|
|
550
|
+
scatterPointLabelStrategy?: ScatterPointLabelStrategy
|
|
551
|
+
compareEndPointsOnly?: boolean
|
|
552
|
+
matchingEntitiesOnly?: boolean
|
|
553
|
+
hideTotalValueLabel?: boolean
|
|
554
|
+
excludedEntityNames?: EntityName[]
|
|
555
|
+
includedEntityNames?: EntityName[]
|
|
556
|
+
selectedEntityNames?: EntityName[]
|
|
557
|
+
selectedEntityColors?: { [entityName: string]: string | undefined }
|
|
558
|
+
focusedSeriesNames?: SeriesName[]
|
|
559
|
+
missingDataStrategy?: MissingDataStrategy
|
|
560
|
+
hideFacetControl?: boolean
|
|
561
|
+
facettingLabelByYVariables?: string
|
|
562
|
+
selectedFacetStrategy?: FacetStrategy
|
|
563
|
+
|
|
564
|
+
xAxis?: Partial<AxisConfigInterface>
|
|
565
|
+
yAxis?: Partial<AxisConfigInterface>
|
|
566
|
+
colorScale?: Partial<ColorScaleConfigInterface>
|
|
567
|
+
map?: Partial<MapConfigInterface>
|
|
568
|
+
|
|
569
|
+
// When we move graphers to Git, and remove dimensions, we can clean this up.
|
|
570
|
+
ySlugs?: ColumnSlugs
|
|
571
|
+
xSlug?: ColumnSlug
|
|
572
|
+
sizeSlug?: ColumnSlug
|
|
573
|
+
colorSlug?: ColumnSlug
|
|
574
|
+
tableSlugs?: ColumnSlugs
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export interface LegacyGrapherInterface extends GrapherInterface {
|
|
578
|
+
data: any
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// This is intentionally a `type` and not an `interface`, because the TS semantics make it so that this here can be assigned to a `Record<string, string>`.
|
|
582
|
+
// See https://stackoverflow.com/q/64970414
|
|
583
|
+
export type GrapherQueryParams = {
|
|
584
|
+
country?: string
|
|
585
|
+
focus?: string
|
|
586
|
+
tab?: string
|
|
587
|
+
overlay?: string
|
|
588
|
+
stackMode?: string
|
|
589
|
+
zoomToSelection?: string
|
|
590
|
+
xScale?: string
|
|
591
|
+
yScale?: string
|
|
592
|
+
time?: string
|
|
593
|
+
region?: string
|
|
594
|
+
endpointsOnly?: string
|
|
595
|
+
facet?: string
|
|
596
|
+
uniformYAxis?: string
|
|
597
|
+
showSelectionOnlyInTable?: string
|
|
598
|
+
showNoDataArea?: string
|
|
599
|
+
globe?: string
|
|
600
|
+
globeRotation?: string
|
|
601
|
+
globeZoom?: string
|
|
602
|
+
mapSelect?: string
|
|
603
|
+
tableFilter?: string
|
|
604
|
+
tableSearch?: string
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
export type LegacyGrapherQueryParams = GrapherQueryParams & {
|
|
608
|
+
year?: string
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// We don't use this anywhere, but this is a way to ensure that we have an object with all keys present
|
|
612
|
+
// ... so GRAPHER_QUERY_PARAM_KEYS below is guaranteed to have all keys of LegacyGrapherQueryParams
|
|
613
|
+
const GRAPHER_ALL_QUERY_PARAMS: Required<LegacyGrapherQueryParams> = {
|
|
614
|
+
country: "",
|
|
615
|
+
focus: "",
|
|
616
|
+
tab: "",
|
|
617
|
+
overlay: "",
|
|
618
|
+
stackMode: "",
|
|
619
|
+
zoomToSelection: "",
|
|
620
|
+
xScale: "",
|
|
621
|
+
yScale: "",
|
|
622
|
+
time: "",
|
|
623
|
+
region: "",
|
|
624
|
+
endpointsOnly: "",
|
|
625
|
+
facet: "",
|
|
626
|
+
uniformYAxis: "",
|
|
627
|
+
showSelectionOnlyInTable: "",
|
|
628
|
+
showNoDataArea: "",
|
|
629
|
+
year: "",
|
|
630
|
+
globe: "",
|
|
631
|
+
globeRotation: "",
|
|
632
|
+
globeZoom: "",
|
|
633
|
+
mapSelect: "",
|
|
634
|
+
tableFilter: "",
|
|
635
|
+
tableSearch: "",
|
|
636
|
+
}
|
|
637
|
+
export const GRAPHER_QUERY_PARAM_KEYS = Object.keys(
|
|
638
|
+
GRAPHER_ALL_QUERY_PARAMS
|
|
639
|
+
) as (keyof LegacyGrapherQueryParams)[]
|
|
640
|
+
|
|
641
|
+
// Another approach we may want to try is this: https://github.com/mobxjs/serializr
|
|
642
|
+
export const grapherKeysToSerialize = [
|
|
643
|
+
"$schema",
|
|
644
|
+
"chartTypes",
|
|
645
|
+
"id",
|
|
646
|
+
"version",
|
|
647
|
+
"slug",
|
|
648
|
+
"title",
|
|
649
|
+
"subtitle",
|
|
650
|
+
"sourceDesc",
|
|
651
|
+
"note",
|
|
652
|
+
"hideAnnotationFieldsInTitle",
|
|
653
|
+
"minTime",
|
|
654
|
+
"maxTime",
|
|
655
|
+
"timelineMinTime",
|
|
656
|
+
"timelineMaxTime",
|
|
657
|
+
"addCountryMode",
|
|
658
|
+
"stackMode",
|
|
659
|
+
"showNoDataArea",
|
|
660
|
+
"hideLegend",
|
|
661
|
+
"logo",
|
|
662
|
+
"hideLogo",
|
|
663
|
+
"hideRelativeToggle",
|
|
664
|
+
"entityType",
|
|
665
|
+
"entityTypePlural",
|
|
666
|
+
"facettingLabelByYVariables",
|
|
667
|
+
"hideTimeline",
|
|
668
|
+
"zoomToSelection",
|
|
669
|
+
"showYearLabels",
|
|
670
|
+
"hasMapTab",
|
|
671
|
+
"tab",
|
|
672
|
+
"internalNotes",
|
|
673
|
+
"variantName",
|
|
674
|
+
"originUrl",
|
|
675
|
+
"isPublished",
|
|
676
|
+
"baseColorScheme",
|
|
677
|
+
"invertColorScheme",
|
|
678
|
+
"hideConnectedScatterLines",
|
|
679
|
+
"hideScatterLabels",
|
|
680
|
+
"scatterPointLabelStrategy",
|
|
681
|
+
"compareEndPointsOnly",
|
|
682
|
+
"matchingEntitiesOnly",
|
|
683
|
+
"hideTotalValueLabel",
|
|
684
|
+
"xAxis",
|
|
685
|
+
"yAxis",
|
|
686
|
+
"colorScale",
|
|
687
|
+
"map",
|
|
688
|
+
"dimensions",
|
|
689
|
+
"selectedEntityNames",
|
|
690
|
+
"selectedEntityColors",
|
|
691
|
+
"focusedSeriesNames",
|
|
692
|
+
"sortBy",
|
|
693
|
+
"sortOrder",
|
|
694
|
+
"sortColumnSlug",
|
|
695
|
+
"excludedEntityNames",
|
|
696
|
+
"includedEntityNames",
|
|
697
|
+
"selectedFacetStrategy",
|
|
698
|
+
"hideFacetControl",
|
|
699
|
+
"comparisonLines",
|
|
700
|
+
"relatedQuestions",
|
|
701
|
+
"missingDataStrategy",
|
|
702
|
+
|
|
703
|
+
// internals
|
|
704
|
+
"adminBaseUrl",
|
|
705
|
+
"bakedGrapherURL",
|
|
706
|
+
]
|
|
707
|
+
|
|
708
|
+
export enum GrapherVariant {
|
|
709
|
+
/**
|
|
710
|
+
* Default rendering, with header and footer
|
|
711
|
+
*/
|
|
712
|
+
Default = "default",
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Default rendering, chart area only
|
|
716
|
+
*/
|
|
717
|
+
Uncaptioned = "uncaptioned",
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Simplified rendering, suitable for thumbnails.
|
|
721
|
+
* Less noisy visualization, but should be understandable on its own
|
|
722
|
+
*/
|
|
723
|
+
Thumbnail = "thumbnail",
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export interface ChartRedirect {
|
|
727
|
+
id: number
|
|
728
|
+
slug: string
|
|
729
|
+
chartId: number
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
export enum GrapherWindowType {
|
|
733
|
+
panel = "panel",
|
|
734
|
+
modal = "modal",
|
|
735
|
+
drawer = "drawer",
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export type AdditionalGrapherDataFetchFn = (
|
|
739
|
+
varId: OwidVariableId,
|
|
740
|
+
loadMetadataOnly?: boolean
|
|
741
|
+
) => Promise<OwidVariableDataMetadataDimensions>
|
|
742
|
+
|
|
743
|
+
export type GrapherTrendArrowDirection = "up" | "right" | "down"
|