@buildcanada/charts 0.1.0 → 0.2.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.
Files changed (127) hide show
  1. package/package.json +9 -24
  2. package/src/components/Button/Button.scss +17 -17
  3. package/src/components/Button/Button.tsx +4 -4
  4. package/src/components/MarkdownTextWrap/MarkdownTextWrap.tsx +1 -1
  5. package/src/components/index.ts +1 -1
  6. package/src/components/stubs/DataCitation.tsx +1 -1
  7. package/src/components/stubs/IndicatorKeyData.tsx +1 -1
  8. package/src/components/stubs/IndicatorProcessing.tsx +1 -1
  9. package/src/components/stubs/IndicatorSources.tsx +1 -1
  10. package/src/components/styles/colors.scss +1 -1
  11. package/src/components/styles/mixins.scss +5 -5
  12. package/src/core-table/{OwidTable.ts → ChartsTable.ts} +31 -31
  13. package/src/core-table/CoreTable.ts +12 -12
  14. package/src/core-table/CoreTableColumns.ts +24 -24
  15. package/src/core-table/CoreTableUtils.ts +7 -7
  16. package/src/core-table/{OwidTableSynthesizers.ts → TableSynthesizers.ts} +24 -24
  17. package/src/core-table/{OwidTableUtil.ts → TableUtil.ts} +5 -5
  18. package/src/core-table/index.ts +3 -3
  19. package/src/explorer/ColumnGrammar.ts +1 -1
  20. package/src/explorer/Explorer.sample.ts +7 -7
  21. package/src/explorer/Explorer.scss +1 -1
  22. package/src/explorer/Explorer.tsx +23 -23
  23. package/src/explorer/ExplorerConstants.ts +2 -2
  24. package/src/explorer/ExplorerGrammar.ts +3 -3
  25. package/src/explorer/ExplorerProgram.ts +21 -18
  26. package/src/explorer/ExplorerUtils.ts +1 -1
  27. package/src/explorer/gridLang/readme.md +1 -1
  28. package/src/grapher/axis/Axis.ts +3 -3
  29. package/src/grapher/barCharts/DiscreteBarChart.tsx +2 -2
  30. package/src/grapher/barCharts/DiscreteBarChartState.ts +8 -8
  31. package/src/grapher/captionedChart/Logos.tsx +11 -13
  32. package/src/grapher/captionedChart/LogosSVG.tsx +2 -2
  33. package/src/grapher/chart/ChartAreaContent.tsx +1 -1
  34. package/src/grapher/chart/ChartDimension.ts +15 -15
  35. package/src/grapher/chart/ChartInterface.ts +6 -6
  36. package/src/grapher/chart/ChartManager.ts +3 -3
  37. package/src/grapher/chart/ChartUtils.tsx +3 -3
  38. package/src/grapher/color/ColorConstants.ts +2 -2
  39. package/src/grapher/color/ColorScale.ts +4 -4
  40. package/src/grapher/color/ColorSchemes.ts +26 -26
  41. package/src/grapher/color/CustomSchemes.ts +227 -227
  42. package/src/grapher/controls/ContentSwitchers.tsx +1 -1
  43. package/src/grapher/controls/DataTableFilterDropdown.tsx +2 -2
  44. package/src/grapher/controls/MapZoomDropdown.tsx +3 -3
  45. package/src/grapher/controls/ShareMenu.tsx +1 -1
  46. package/src/grapher/controls/entityPicker/EntityPicker.tsx +8 -8
  47. package/src/grapher/controls/entityPicker/EntityPickerConstants.ts +3 -3
  48. package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.tsx +1 -1
  49. package/src/grapher/core/EntitiesByRegionType.ts +4 -4
  50. package/src/grapher/core/EntityUrlBuilder.ts +2 -2
  51. package/src/grapher/core/FetchingGrapher.tsx +4 -4
  52. package/src/grapher/core/Grapher.tsx +10 -10
  53. package/src/grapher/core/GrapherState.tsx +47 -50
  54. package/src/grapher/core/GrapherUseHelpers.tsx +4 -4
  55. package/src/grapher/core/{LegacyToOwidTable.ts → LegacyToChartsTable.ts} +100 -100
  56. package/src/grapher/core/loadGrapherTableHelpers.ts +13 -13
  57. package/src/grapher/core/loadVariable.ts +5 -5
  58. package/src/grapher/dataTable/DataTable.sample.ts +12 -12
  59. package/src/grapher/dataTable/DataTable.tsx +22 -22
  60. package/src/grapher/dataTable/DataTableConstants.ts +9 -9
  61. package/src/grapher/entitySelector/EntitySelector.tsx +13 -13
  62. package/src/grapher/facet/FacetChart.tsx +4 -4
  63. package/src/grapher/facet/FacetMap.tsx +6 -6
  64. package/src/grapher/footer/Footer.tsx +4 -4
  65. package/src/grapher/footer/FooterManager.ts +2 -2
  66. package/src/grapher/header/Header.tsx +5 -5
  67. package/src/grapher/header/HeaderManager.ts +1 -1
  68. package/src/grapher/index.ts +8 -8
  69. package/src/grapher/lineCharts/LineChartHelpers.ts +4 -4
  70. package/src/grapher/lineCharts/LineChartState.ts +9 -9
  71. package/src/grapher/mapCharts/ChoroplethGlobe.tsx +1 -1
  72. package/src/grapher/mapCharts/GlobeController.ts +9 -9
  73. package/src/grapher/mapCharts/MapChartState.ts +16 -16
  74. package/src/grapher/mapCharts/MapSparkline.tsx +5 -5
  75. package/src/grapher/mapCharts/MapTooltip.tsx +13 -13
  76. package/src/grapher/modal/DownloadModal.scss +3 -3
  77. package/src/grapher/modal/DownloadModal.tsx +24 -29
  78. package/src/grapher/modal/SourcesDescriptions.scss +1 -1
  79. package/src/grapher/modal/SourcesKeyDataTable.tsx +2 -2
  80. package/src/grapher/modal/SourcesModal.tsx +15 -15
  81. package/src/grapher/scatterCharts/ScatterPlotChart.tsx +2 -2
  82. package/src/grapher/scatterCharts/ScatterPlotChartConstants.ts +2 -2
  83. package/src/grapher/scatterCharts/ScatterPlotChartState.ts +8 -8
  84. package/src/grapher/scatterCharts/ScatterSizeLegend.tsx +2 -2
  85. package/src/grapher/scatterCharts/ScatterUtils.ts +2 -2
  86. package/src/grapher/schema/grapher-schema.009.yaml +18 -18
  87. package/src/grapher/schema/migrations/migrations.ts +4 -4
  88. package/src/grapher/selection/MapSelectionArray.ts +1 -1
  89. package/src/grapher/selection/readme.md +1 -1
  90. package/src/grapher/slopeCharts/SlopeChartConstants.ts +3 -3
  91. package/src/grapher/slopeCharts/SlopeChartHelpers.ts +1 -1
  92. package/src/grapher/slopeCharts/SlopeChartState.ts +10 -10
  93. package/src/grapher/stackedCharts/AbstractStackedChartState.ts +8 -8
  94. package/src/grapher/stackedCharts/MarimekkoChart.tsx +5 -5
  95. package/src/grapher/stackedCharts/MarimekkoChartConstants.ts +2 -2
  96. package/src/grapher/stackedCharts/MarimekkoChartState.ts +12 -12
  97. package/src/grapher/stackedCharts/StackedBarChartState.ts +1 -1
  98. package/src/grapher/stackedCharts/StackedConstants.ts +2 -2
  99. package/src/grapher/stackedCharts/StackedDiscreteBarChartState.ts +12 -12
  100. package/src/grapher/stackedCharts/StackedDiscreteBars.tsx +2 -2
  101. package/src/grapher/tabs/Tabs.tsx +1 -1
  102. package/src/grapher/testData/{OwidTestData.sample.ts → TestData.sample.ts} +7 -7
  103. package/src/grapher/testData/{OwidTestData.ts → TestData.ts} +5 -5
  104. package/src/index.ts +7 -7
  105. package/src/types/{OwidOrigin.ts → Origin.ts} +3 -3
  106. package/src/types/{OwidSource.ts → Source.ts} +1 -1
  107. package/src/types/Variable.ts +133 -0
  108. package/src/types/{OwidVariableDisplayConfigInterface.ts → VariableDisplayConfigInterface.ts} +11 -11
  109. package/src/types/domainTypes/ContentGraph.ts +3 -3
  110. package/src/types/domainTypes/CoreTableTypes.ts +29 -29
  111. package/src/types/domainTypes/Posts.ts +2 -2
  112. package/src/types/domainTypes/Search.ts +6 -6
  113. package/src/types/domainTypes/Various.ts +1 -1
  114. package/src/types/gdocTypes/Gdoc.ts +42 -42
  115. package/src/types/grapherTypes/GrapherTypes.ts +21 -21
  116. package/src/types/index.ts +51 -51
  117. package/src/utils/MultiDimDataPageConfig.ts +1 -1
  118. package/src/utils/Util.ts +61 -55
  119. package/src/utils/{OwidVariable.ts → Variable.ts} +15 -15
  120. package/src/utils/formatValue.ts +12 -12
  121. package/src/utils/image.ts +12 -12
  122. package/src/utils/index.ts +5 -5
  123. package/src/utils/metadataHelpers.ts +19 -19
  124. package/src/utils/regions.ts +9 -9
  125. package/LICENSE.md +0 -8
  126. package/README.md +0 -113
  127. package/src/types/OwidVariable.ts +0 -133
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@buildcanada/charts",
3
- "version": "0.1.0",
4
- "description": "A configurable data visualization library for creating interactive charts. Extracted from Our World in Data's Grapher.",
3
+ "version": "0.2.0",
4
+ "description": "A configurable data visualization library for creating interactive charts.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "types": "src/index.ts",
@@ -32,16 +32,10 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "engines": {
36
- "node": ">=22.0"
37
- },
38
35
  "scripts": {
39
- "build": "storybook build -o storybook-static",
40
36
  "typecheck": "tsc --noEmit",
41
37
  "test": "vitest run",
42
- "test:watch": "vitest",
43
- "storybook": "storybook dev -p 6006",
44
- "serve-storybook": "serve storybook-static -p 6006"
38
+ "test:watch": "vitest"
45
39
  },
46
40
  "keywords": [
47
41
  "charts",
@@ -70,6 +64,7 @@
70
64
  "classnames": "^2.5.1",
71
65
  "colorbrewer": "^1.3.0",
72
66
  "d3": "^7.9.0",
67
+ "d3-transition": "^3.0.1",
73
68
  "dayjs": "^1.11.11",
74
69
  "fparser": "^3.1.0",
75
70
  "fuzzysort": "^3.1.0",
@@ -99,9 +94,7 @@
99
94
  "versor": "^0.2.0"
100
95
  },
101
96
  "devDependencies": {
102
- "@storybook/addon-docs": "^10.1.11",
103
- "@storybook/react": "^10.1.11",
104
- "@storybook/react-vite": "^10.1.11",
97
+ "@storybook/react-dom-shim": "^10.1.11",
105
98
  "@testing-library/dom": "^10.4.1",
106
99
  "@testing-library/jest-dom": "^6.9.1",
107
100
  "@testing-library/react": "^16.3.0",
@@ -113,25 +106,17 @@
113
106
  "@types/lodash-es": "^4",
114
107
  "@types/mousetrap": "^1.6.9",
115
108
  "@types/papaparse": "^5.3.16",
116
- "@types/react": "^19.2.2",
117
- "@types/react-dom": "^19.2.2",
118
109
  "@types/string-pixel-width": "^1.7.2",
119
110
  "@types/topojson-client": "^3.1.1",
120
111
  "@types/url-parse": "^1.4.8",
121
- "@vitejs/plugin-react": "^5.1.1",
112
+ "debug": "^4.4.3",
122
113
  "eslint": "^9.37.0",
123
114
  "eslint-plugin-react-hooks": "^5.2.0",
124
115
  "happy-dom": "^20.1.0",
125
116
  "jsdom": "^27.4.0",
126
- "mobx": "^6.13.7",
127
- "mobx-react": "^7.6.0",
128
- "react": "^19.2.0",
129
- "react-dom": "^19.2.0",
130
- "sass": "^1.77.0",
131
- "serve": "^14.2.5",
132
- "storybook": "^10.1.11",
133
- "typescript": "~5.9.2",
134
- "vite": "^6.0.0",
117
+ "object-assign": "^4.1.1",
118
+ "side-channel": "^1.1.0",
119
+ "timezone-mock": "^1.3.6",
135
120
  "vitest": "^4.0.15"
136
121
  }
137
122
  }
@@ -1,4 +1,4 @@
1
- .owid-btn {
1
+ .charts-btn {
2
2
  @include body-3-medium;
3
3
  padding: 8.5px 24px;
4
4
  border: 1px solid transparent;
@@ -7,23 +7,23 @@
7
7
  display: block;
8
8
  cursor: pointer;
9
9
 
10
- &.owid-btn--icon-only {
10
+ &.charts-btn--icon-only {
11
11
  padding: 4.5px 9px;
12
12
  }
13
13
 
14
14
  &:disabled {
15
15
  cursor: default;
16
16
 
17
- &.owid-btn--solid-blue,
18
- &.owid-btn--solid-dark-blue,
19
- &.owid-btn--solid-light-blue,
20
- &.owid-btn--solid-vermillion {
17
+ &.charts-btn--solid-blue,
18
+ &.charts-btn--solid-dark-blue,
19
+ &.charts-btn--solid-light-blue,
20
+ &.charts-btn--solid-vermillion {
21
21
  color: $blue-50;
22
22
  background-color: $blue-10;
23
23
  }
24
24
 
25
- &.owid-btn--outline-vermillion,
26
- &.owid-btn--outline-white {
25
+ &.charts-btn--outline-vermillion,
26
+ &.charts-btn--outline-white {
27
27
  color: $blue-40;
28
28
  border-color: $blue-40;
29
29
  }
@@ -34,15 +34,15 @@
34
34
  }
35
35
  }
36
36
 
37
- .owid-btn--icon-right {
37
+ .charts-btn--icon-right {
38
38
  margin-left: 0.5rem;
39
39
  }
40
40
 
41
- .owid-btn--icon-left {
41
+ .charts-btn--icon-left {
42
42
  margin-right: 0.5rem;
43
43
  }
44
44
 
45
- .owid-btn--solid-vermillion {
45
+ .charts-btn--solid-vermillion {
46
46
  background-color: $vermillion;
47
47
  color: #fff;
48
48
 
@@ -51,7 +51,7 @@
51
51
  }
52
52
  }
53
53
 
54
- .owid-btn--outline-vermillion {
54
+ .charts-btn--outline-vermillion {
55
55
  border-color: $vermillion;
56
56
  color: $vermillion;
57
57
 
@@ -61,7 +61,7 @@
61
61
  }
62
62
  }
63
63
 
64
- .owid-btn--solid-blue {
64
+ .charts-btn--solid-blue {
65
65
  background-color: $blue-60;
66
66
  color: #fff;
67
67
 
@@ -70,7 +70,7 @@
70
70
  }
71
71
  }
72
72
 
73
- .owid-btn--solid-dark-blue {
73
+ .charts-btn--solid-dark-blue {
74
74
  background-color: $blue-95;
75
75
  color: #fff;
76
76
 
@@ -79,7 +79,7 @@
79
79
  }
80
80
  }
81
81
 
82
- .owid-btn--solid-light-blue {
82
+ .charts-btn--solid-light-blue {
83
83
  background-color: $blue-20;
84
84
  color: $blue-90;
85
85
 
@@ -88,7 +88,7 @@
88
88
  }
89
89
  }
90
90
 
91
- .owid-btn--outline-white {
91
+ .charts-btn--outline-white {
92
92
  background-color: transparent;
93
93
  border-color: $white;
94
94
  color: $white;
@@ -99,7 +99,7 @@
99
99
  }
100
100
  }
101
101
 
102
- .owid-btn--outline-light-blue {
102
+ .charts-btn--outline-light-blue {
103
103
  border-color: $blue-20;
104
104
  color: $blue-90;
105
105
 
@@ -52,21 +52,21 @@ export const Button = ({
52
52
  dataTrackNote,
53
53
  disabled,
54
54
  }: ButtonProps) => {
55
- const classes = cx("owid-btn", `owid-btn--${theme}`, className, {
56
- "owid-btn--icon-only": icon && !text,
55
+ const classes = cx("charts-btn", `charts-btn--${theme}`, className, {
56
+ "charts-btn--icon-only": icon && !text,
57
57
  })
58
58
  const content = (
59
59
  <>
60
60
  {iconPosition === "left" && icon && (
61
61
  <FontAwesomeIcon
62
- className={cx({ "owid-btn--icon-left": text })}
62
+ className={cx({ "charts-btn--icon-left": text })}
63
63
  icon={icon}
64
64
  />
65
65
  )}
66
66
  {text && <span>{text}</span>}
67
67
  {iconPosition !== "left" && icon && (
68
68
  <FontAwesomeIcon
69
- className={cx({ "owid-btn--icon-right": text })}
69
+ className={cx({ "charts-btn--icon-right": text })}
70
70
  icon={icon}
71
71
  />
72
72
  )}
@@ -427,7 +427,7 @@ export const isTextToken = (token: IRToken): token is IRText | IRWhitespace =>
427
427
  * translated.
428
428
  * This is to be run _just before_ rendering to HTML, because it loses some
429
429
  * information and is not easily reversible.
430
- * See also https://github.com/owid/owid-grapher/issues/1785
430
+ * See also # legacy issue 1785
431
431
  */
432
432
  export const recursiveMergeTextTokens = (
433
433
  tokens: IRToken[],
@@ -47,7 +47,7 @@ export { reactRenderToStringClientOnly } from "./reactUtil.js"
47
47
  export { GrapherTabIcon } from "./GrapherTabIcon.js"
48
48
  export { GrapherTrendArrow } from "./GrapherTrendArrow.js"
49
49
 
50
- // Stub components for OWID data page features
50
+ // Stub components for data page features
51
51
  export { CodeSnippet } from "./stubs/CodeSnippet.js"
52
52
  export {
53
53
  makeSource,
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stub component for DataCitation.
3
- * This is a placeholder for OWID data page functionality.
3
+ * This is a placeholder for data page functionality.
4
4
  */
5
5
  import React from "react"
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stub functions for IndicatorKeyData.
3
- * These are placeholders for OWID data page functionality.
3
+ * These are placeholders for data page functionality.
4
4
  */
5
5
  import React from "react"
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stub component for IndicatorProcessing.
3
- * This is a placeholder for OWID data page functionality.
3
+ * This is a placeholder for data page functionality.
4
4
  */
5
5
  import React from "react"
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stub component for IndicatorSources.
3
- * This is a placeholder for OWID data page functionality.
3
+ * This is a placeholder for data page functionality.
4
4
  */
5
5
  import React from "react"
6
6
 
@@ -105,7 +105,7 @@ $sdgColors: (
105
105
  );
106
106
 
107
107
  :root {
108
- // See also owidTypes.ts > OwidGdocPostContent > cover-color
108
+ // See also gdocTypes/Gdoc.ts > GdocPostContent > cover-color
109
109
  --amber: #{$amber};
110
110
  @each $i, $sdgColor in $sdgColors {
111
111
  --sdg-color-#{$i}: #{$sdgColor};
@@ -1,6 +1,6 @@
1
1
  @use "sass:math";
2
2
 
3
- @mixin owid-link-90 {
3
+ @mixin link-90 {
4
4
  color: $blue-90;
5
5
  text-decoration: underline;
6
6
  text-underline-offset: 4px;
@@ -13,7 +13,7 @@
13
13
  }
14
14
  }
15
15
 
16
- @mixin owid-link-60 {
16
+ @mixin link-60 {
17
17
  color: $blue-60;
18
18
  text-decoration: underline;
19
19
  text-underline-offset: 4px;
@@ -26,7 +26,7 @@
26
26
  }
27
27
  }
28
28
 
29
- @mixin owid-link-40 {
29
+ @mixin link-40 {
30
30
  color: $blue-40;
31
31
  text-decoration: underline;
32
32
  text-underline-offset: 4px;
@@ -70,7 +70,7 @@
70
70
  }
71
71
 
72
72
  a {
73
- @include owid-link-90;
73
+ @include link-90;
74
74
  }
75
75
  }
76
76
  }
@@ -517,7 +517,7 @@
517
517
  }
518
518
  }
519
519
 
520
- @mixin owid-checkbox {
520
+ @mixin charts-checkbox {
521
521
  background: #fff;
522
522
  appearance: none;
523
523
  width: 16px;
@@ -24,9 +24,9 @@ import {
24
24
  CoreValueType,
25
25
  ColumnTypeNames,
26
26
  EntityName,
27
- OwidColumnDef,
28
- OwidRow,
29
- OwidTableSlugs,
27
+ ColumnDef,
28
+ Row,
29
+ ChartsTableSlugs,
30
30
  ErrorValue,
31
31
  ToleranceOptions,
32
32
  } from "../types/index.js"
@@ -39,7 +39,7 @@ import {
39
39
  makeOriginalStartTimeSlugFromColumnSlug,
40
40
  timeColumnSlugFromColumnDef,
41
41
  toPercentageColumnDef,
42
- } from "./OwidTableUtil.js"
42
+ } from "./TableUtil.js"
43
43
  import {
44
44
  linearInterpolation,
45
45
  toleranceInterpolation,
@@ -49,10 +49,10 @@ import {
49
49
  } from "./CoreTableUtils.js"
50
50
  import { CoreColumn, ColumnTypeMap } from "./CoreTableColumns.js"
51
51
 
52
- // An OwidTable is a subset of Table. An OwidTable always has EntityName, EntityCode, EntityId, and Time columns,
52
+ // An ChartsTable is a subset of Table. An ChartsTable always has EntityName, EntityCode, EntityId, and Time columns,
53
53
  // and value column(s). Whether or not we need in the long run is uncertain and it may just be a stepping stone
54
54
  // to go from our Variables paradigm to the Table paradigm.
55
- export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
55
+ export class ChartsTable extends CoreTable<Row, ColumnDef> {
56
56
  @imemo get availableEntityNames(): any[] {
57
57
  return Array.from(this.availableEntityNameSet)
58
58
  }
@@ -64,7 +64,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
64
64
  @imemo override get entityNameColumn(): CoreColumn {
65
65
  return (
66
66
  this.getFirstColumnWithType(ColumnTypeNames.EntityName) ??
67
- this.get(OwidTableSlugs.entityName)
67
+ this.get(ChartsTableSlugs.entityName)
68
68
  )
69
69
  }
70
70
 
@@ -84,7 +84,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
84
84
  return this.rowIndex([this.entityNameSlug])
85
85
  }
86
86
 
87
- getAnnotationColumnSlug(columnDef: OwidColumnDef): string | undefined {
87
+ getAnnotationColumnSlug(columnDef: ColumnDef): string | undefined {
88
88
  return _.isEmpty(columnDef?.annotationsColumnSlug)
89
89
  ? makeAnnotationsSlug(columnDef.slug)
90
90
  : columnDef.annotationsColumnSlug
@@ -92,7 +92,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
92
92
 
93
93
  // todo: instead of this we should probably make annotations another property on charts—something like "annotationsColumnSlugs"
94
94
  getAnnotationColumnForColumn(columnSlug: ColumnSlug): CoreColumn {
95
- const def = this.get(columnSlug).def as OwidColumnDef
95
+ const def = this.get(columnSlug).def as ColumnDef
96
96
  const slug = this.getAnnotationColumnSlug(def)
97
97
  return this.get(slug)
98
98
  }
@@ -179,7 +179,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
179
179
  const adjustedStart = start === Infinity ? this.maxTime! : start
180
180
  const adjustedEnd = end === -Infinity ? this.minTime! : end
181
181
  // todo: we should set a time column onload so we don't have to worry about it again.
182
- const timeColumnSlug = this.timeColumn?.slug || OwidTableSlugs.time
182
+ const timeColumnSlug = this.timeColumn?.slug || ChartsTableSlugs.time
183
183
 
184
184
  const description = `Keep only rows with Time between ${adjustedStart} - ${adjustedEnd}`
185
185
 
@@ -543,7 +543,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
543
543
  columnSlugs.forEach((valueSlug) => {
544
544
  let comparisonValue: number
545
545
  rowsForSingleEntity = rowsForSingleEntity.map(
546
- (row: Readonly<OwidRow>) => {
546
+ (row: Readonly<Row>) => {
547
547
  const newRow = {
548
548
  ...row,
549
549
  }
@@ -658,11 +658,11 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
658
658
  this.getAverageAnnualChangeIndicesByEntity(columnSlugs)
659
659
 
660
660
  // Overwrite table rows
661
- const rows: OwidRow[] = []
661
+ const rows: Row[] = []
662
662
  entityNameToIndices.forEach((indices) => {
663
663
  const [startRow, endRow] = this.rowsAt(indices)
664
664
 
665
- const newRow: OwidRow = { ...endRow }
665
+ const newRow: Row = { ...endRow }
666
666
  columns.forEach((col) => {
667
667
  const timeSlug = col.originalTimeColumnSlug
668
668
 
@@ -712,7 +712,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
712
712
  )
713
713
  }
714
714
 
715
- // Give our users a clean CSV of each Grapher. Assumes an Owid Table with entityName.
715
+ // Give our users a clean CSV of each Grapher. Assumes a ChartsTable with entityName.
716
716
  toPrettyCsv(
717
717
  useShortNames: boolean = false,
718
718
  activeColumnSlugs: string[] | undefined = undefined
@@ -720,8 +720,8 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
720
720
  let table
721
721
  if (activeColumnSlugs?.length) {
722
722
  const timeColumnToInclude = [
723
- OwidTableSlugs.year,
724
- OwidTableSlugs.day,
723
+ ChartsTableSlugs.year,
724
+ ChartsTableSlugs.day,
725
725
  this.timeColumn.slug, // needed for explorers, where the time column may be called anything
726
726
  ].find((colSlug) => this.has(colSlug))
727
727
 
@@ -737,9 +737,9 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
737
737
  ])
738
738
  } else {
739
739
  table = this.dropColumns([
740
- OwidTableSlugs.entityId,
741
- OwidTableSlugs.time,
742
- OwidTableSlugs.entityColor,
740
+ ChartsTableSlugs.entityId,
741
+ ChartsTableSlugs.time,
742
+ ChartsTableSlugs.entityColor,
743
743
  ])
744
744
  }
745
745
  return table
@@ -750,7 +750,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
750
750
  @imemo get entityNameColorIndex(): Map<EntityName, Color> {
751
751
  return this.valueIndex(
752
752
  this.entityNameSlug,
753
- OwidTableSlugs.entityColor
753
+ ChartsTableSlugs.entityColor
754
754
  ) as Map<EntityName, Color>
755
755
  }
756
756
 
@@ -836,7 +836,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
836
836
  if (!this.has(columnSlug)) return this
837
837
 
838
838
  const column = this.get(columnSlug)
839
- const columnDef = column.def as OwidColumnDef
839
+ const columnDef = column.def as ColumnDef
840
840
  const tolerance = toleranceOverride ?? column.tolerance ?? 0
841
841
  const toleranceStrategy =
842
842
  toleranceStrategyOverride ??
@@ -846,7 +846,7 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
846
846
  const timeColumnOfTable = !this.timeColumn.isMissing
847
847
  ? this.timeColumn
848
848
  : // CovidTable does not have a day or year column so we need to use time.
849
- (this.get(OwidTableSlugs.time) as CoreColumn)
849
+ (this.get(ChartsTableSlugs.time) as CoreColumn)
850
850
 
851
851
  const maybeTimeColumnOfValue =
852
852
  getOriginalTimeColumnSlug(this, columnSlug) ??
@@ -923,14 +923,14 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
923
923
  if (!this.has(columnSlug)) return this
924
924
 
925
925
  const column = this.get(columnSlug)
926
- const columnDef = column?.def as OwidColumnDef
926
+ const columnDef = column?.def as ColumnDef
927
927
 
928
928
  const maybeTimeColumnSlug =
929
929
  getOriginalTimeColumnSlug(this, columnSlug) ??
930
930
  timeColumnSlugFromColumnDef(columnDef)
931
931
  const timeColumn =
932
932
  this.get(maybeTimeColumnSlug) ??
933
- (this.get(OwidTableSlugs.time) as CoreColumn) // CovidTable does not have a day or year column so we need to use time.
933
+ (this.get(ChartsTableSlugs.time) as CoreColumn) // CovidTable does not have a day or year column so we need to use time.
934
934
 
935
935
  const originalColumnSlug =
936
936
  makeOriginalValueSlugFromColumnSlug(columnSlug)
@@ -1157,16 +1157,16 @@ export class OwidTable extends CoreTable<OwidRow, OwidColumnDef> {
1157
1157
 
1158
1158
  const BLANK_TABLE_MESSAGE = `Table is empty.`
1159
1159
 
1160
- // This just assures that even an emtpty OwidTable will have an entityName column. Probably a cleaner way to do this pattern (add a defaultColumns prop??)
1161
- export const BlankOwidTable = (
1162
- tableSlug = `blankOwidTable`,
1160
+ // This just assures that even an emtpty ChartsTable will have an entityName column. Probably a cleaner way to do this pattern (add a defaultColumns prop??)
1161
+ export const BlankChartsTable = (
1162
+ tableSlug = `blankChartsTable`,
1163
1163
  extraTableDescription = ""
1164
- ): OwidTable =>
1165
- new OwidTable(
1164
+ ): ChartsTable =>
1165
+ new ChartsTable(
1166
1166
  undefined,
1167
1167
  [
1168
- { slug: OwidTableSlugs.entityName },
1169
- { slug: OwidTableSlugs.year, type: ColumnTypeNames.Year },
1168
+ { slug: ChartsTableSlugs.entityName },
1169
+ { slug: ChartsTableSlugs.year, type: ColumnTypeNames.Year },
1170
1170
  ],
1171
1171
  {
1172
1172
  tableDescription: BLANK_TABLE_MESSAGE + extraTableDescription,
@@ -28,8 +28,8 @@ import {
28
28
  ColumnTypeNames,
29
29
  CoreColumnDef,
30
30
  JsTypes,
31
- OwidTableSlugs,
32
- OwidColumnDef,
31
+ ChartsTableSlugs,
32
+ ColumnDef,
33
33
  } from "../types/index.js"
34
34
  import {
35
35
  makeAutoTypeFn,
@@ -65,7 +65,7 @@ interface AdvancedOptions {
65
65
  }
66
66
 
67
67
  // The complex generic with default here just enables you to optionally specify a more
68
- // narrow interface for the input rows. This is helpful for OwidTable.
68
+ // narrow interface for the input rows. This is helpful for ChartsTable.
69
69
  export class CoreTable<
70
70
  ROW_TYPE extends CoreRow = CoreRow,
71
71
  COL_DEF_TYPE extends CoreColumnDef = CoreColumnDef,
@@ -232,7 +232,7 @@ export class CoreTable<
232
232
  // If we ever pass Mobx observable arrays, we need to convert them to regular arrays.
233
233
  // Otherwise, operations like `.concat()` will break in unexpected ways.
234
234
  // See https://github.com/mobxjs/mobx/blob/mobx4and5/docs/best/pitfalls.md
235
- // Also, see https://github.com/owid/owid-grapher/issues/2948 for an issue caused by this problem.
235
+ // Also, see # legacy issue 2948 for an issue caused by this problem.
236
236
  type CoreValueArrayThatMayBeMobxProxy = CoreValueType[] & {
237
237
  toJS?: () => CoreValueType[]
238
238
  }
@@ -468,14 +468,14 @@ export class CoreTable<
468
468
  )
469
469
  }
470
470
 
471
- // todo: move this. time methods should not be in CoreTable, in OwidTable instead (which is really TimeSeriesTable).
471
+ // todo: move this. time methods should not be in CoreTable, in ChartsTable instead (which is really TimeSeriesTable).
472
472
  // TODO: remove this. Currently we use this to get the right day/year time formatting. For now a chart is either a "day chart" or a "year chart".
473
473
  // But we can have charts with multiple time columns. Ideally each place that needs access to the timeColumn, would get the specific column
474
474
  // and not the first time column from the table.
475
475
  @imemo get timeColumn(): TimeColumn | MissingColumn {
476
476
  // "time" is the canonical time column slug.
477
- // See LegacyToOwidTable where this column is injected for all Graphers.
478
- const maybeTimeColumn = this.get(OwidTableSlugs.time)
477
+ // See LegacyToChartsTable where this column is injected for all Graphers.
478
+ const maybeTimeColumn = this.get(ChartsTableSlugs.time)
479
479
  if (maybeTimeColumn instanceof ColumnTypeMap.Time)
480
480
  return maybeTimeColumn
481
481
  // If a valid "time" column doesn't exist, find _some_ time column to use.
@@ -496,15 +496,15 @@ export class CoreTable<
496
496
  maybeTimeColumn) as TimeColumn | MissingColumn
497
497
  }
498
498
 
499
- // todo: should be on owidtable
499
+ // todo: should be on ChartsTable
500
500
  @imemo get entityNameColumn(): CoreColumn {
501
501
  return (
502
502
  this.getFirstColumnWithType(ColumnTypeNames.EntityName) ??
503
- this.get(OwidTableSlugs.entityName)
503
+ this.get(ChartsTableSlugs.entityName)
504
504
  )
505
505
  }
506
506
 
507
- // todo: should be on owidtable
507
+ // todo: should be on ChartsTable
508
508
  @imemo get entityNameSlug(): string {
509
509
  return this.entityNameColumn.slug
510
510
  }
@@ -854,8 +854,8 @@ export class CoreTable<
854
854
  this.columnsAsArray
855
855
  .map((col) =>
856
856
  csvEscape(
857
- useShortNames && (col.def as OwidColumnDef).shortName
858
- ? (col.def as OwidColumnDef).shortName
857
+ useShortNames && (col.def as ColumnDef).shortName
858
+ ? (col.def as ColumnDef).shortName
859
859
  : col.name
860
860
  )
861
861
  )