@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.
- package/package.json +9 -24
- package/src/components/Button/Button.scss +17 -17
- package/src/components/Button/Button.tsx +4 -4
- package/src/components/MarkdownTextWrap/MarkdownTextWrap.tsx +1 -1
- package/src/components/index.ts +1 -1
- package/src/components/stubs/DataCitation.tsx +1 -1
- package/src/components/stubs/IndicatorKeyData.tsx +1 -1
- package/src/components/stubs/IndicatorProcessing.tsx +1 -1
- package/src/components/stubs/IndicatorSources.tsx +1 -1
- package/src/components/styles/colors.scss +1 -1
- package/src/components/styles/mixins.scss +5 -5
- package/src/core-table/{OwidTable.ts → ChartsTable.ts} +31 -31
- package/src/core-table/CoreTable.ts +12 -12
- package/src/core-table/CoreTableColumns.ts +24 -24
- package/src/core-table/CoreTableUtils.ts +7 -7
- package/src/core-table/{OwidTableSynthesizers.ts → TableSynthesizers.ts} +24 -24
- package/src/core-table/{OwidTableUtil.ts → TableUtil.ts} +5 -5
- package/src/core-table/index.ts +3 -3
- package/src/explorer/ColumnGrammar.ts +1 -1
- package/src/explorer/Explorer.sample.ts +7 -7
- package/src/explorer/Explorer.scss +1 -1
- package/src/explorer/Explorer.tsx +23 -23
- package/src/explorer/ExplorerConstants.ts +2 -2
- package/src/explorer/ExplorerGrammar.ts +3 -3
- package/src/explorer/ExplorerProgram.ts +21 -18
- package/src/explorer/ExplorerUtils.ts +1 -1
- package/src/explorer/gridLang/readme.md +1 -1
- package/src/grapher/axis/Axis.ts +3 -3
- package/src/grapher/barCharts/DiscreteBarChart.tsx +2 -2
- package/src/grapher/barCharts/DiscreteBarChartState.ts +8 -8
- package/src/grapher/captionedChart/Logos.tsx +11 -13
- package/src/grapher/captionedChart/LogosSVG.tsx +2 -2
- package/src/grapher/chart/ChartAreaContent.tsx +1 -1
- package/src/grapher/chart/ChartDimension.ts +15 -15
- package/src/grapher/chart/ChartInterface.ts +6 -6
- package/src/grapher/chart/ChartManager.ts +3 -3
- package/src/grapher/chart/ChartUtils.tsx +3 -3
- package/src/grapher/color/ColorConstants.ts +2 -2
- package/src/grapher/color/ColorScale.ts +4 -4
- package/src/grapher/color/ColorSchemes.ts +26 -26
- package/src/grapher/color/CustomSchemes.ts +227 -227
- package/src/grapher/controls/ContentSwitchers.tsx +1 -1
- package/src/grapher/controls/DataTableFilterDropdown.tsx +2 -2
- package/src/grapher/controls/MapZoomDropdown.tsx +3 -3
- package/src/grapher/controls/ShareMenu.tsx +1 -1
- package/src/grapher/controls/entityPicker/EntityPicker.tsx +8 -8
- package/src/grapher/controls/entityPicker/EntityPickerConstants.ts +3 -3
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.tsx +1 -1
- package/src/grapher/core/EntitiesByRegionType.ts +4 -4
- package/src/grapher/core/EntityUrlBuilder.ts +2 -2
- package/src/grapher/core/FetchingGrapher.tsx +4 -4
- package/src/grapher/core/Grapher.tsx +10 -10
- package/src/grapher/core/GrapherState.tsx +47 -50
- package/src/grapher/core/GrapherUseHelpers.tsx +4 -4
- package/src/grapher/core/{LegacyToOwidTable.ts → LegacyToChartsTable.ts} +100 -100
- package/src/grapher/core/loadGrapherTableHelpers.ts +13 -13
- package/src/grapher/core/loadVariable.ts +5 -5
- package/src/grapher/dataTable/DataTable.sample.ts +12 -12
- package/src/grapher/dataTable/DataTable.tsx +22 -22
- package/src/grapher/dataTable/DataTableConstants.ts +9 -9
- package/src/grapher/entitySelector/EntitySelector.tsx +13 -13
- package/src/grapher/facet/FacetChart.tsx +4 -4
- package/src/grapher/facet/FacetMap.tsx +6 -6
- package/src/grapher/footer/Footer.tsx +4 -4
- package/src/grapher/footer/FooterManager.ts +2 -2
- package/src/grapher/header/Header.tsx +5 -5
- package/src/grapher/header/HeaderManager.ts +1 -1
- package/src/grapher/index.ts +8 -8
- package/src/grapher/lineCharts/LineChartHelpers.ts +4 -4
- package/src/grapher/lineCharts/LineChartState.ts +9 -9
- package/src/grapher/mapCharts/ChoroplethGlobe.tsx +1 -1
- package/src/grapher/mapCharts/GlobeController.ts +9 -9
- package/src/grapher/mapCharts/MapChartState.ts +16 -16
- package/src/grapher/mapCharts/MapSparkline.tsx +5 -5
- package/src/grapher/mapCharts/MapTooltip.tsx +13 -13
- package/src/grapher/modal/DownloadModal.scss +3 -3
- package/src/grapher/modal/DownloadModal.tsx +24 -29
- package/src/grapher/modal/SourcesDescriptions.scss +1 -1
- package/src/grapher/modal/SourcesKeyDataTable.tsx +2 -2
- package/src/grapher/modal/SourcesModal.tsx +15 -15
- package/src/grapher/scatterCharts/ScatterPlotChart.tsx +2 -2
- package/src/grapher/scatterCharts/ScatterPlotChartConstants.ts +2 -2
- package/src/grapher/scatterCharts/ScatterPlotChartState.ts +8 -8
- package/src/grapher/scatterCharts/ScatterSizeLegend.tsx +2 -2
- package/src/grapher/scatterCharts/ScatterUtils.ts +2 -2
- package/src/grapher/schema/grapher-schema.009.yaml +18 -18
- package/src/grapher/schema/migrations/migrations.ts +4 -4
- package/src/grapher/selection/MapSelectionArray.ts +1 -1
- package/src/grapher/selection/readme.md +1 -1
- package/src/grapher/slopeCharts/SlopeChartConstants.ts +3 -3
- package/src/grapher/slopeCharts/SlopeChartHelpers.ts +1 -1
- package/src/grapher/slopeCharts/SlopeChartState.ts +10 -10
- package/src/grapher/stackedCharts/AbstractStackedChartState.ts +8 -8
- package/src/grapher/stackedCharts/MarimekkoChart.tsx +5 -5
- package/src/grapher/stackedCharts/MarimekkoChartConstants.ts +2 -2
- package/src/grapher/stackedCharts/MarimekkoChartState.ts +12 -12
- package/src/grapher/stackedCharts/StackedBarChartState.ts +1 -1
- package/src/grapher/stackedCharts/StackedConstants.ts +2 -2
- package/src/grapher/stackedCharts/StackedDiscreteBarChartState.ts +12 -12
- package/src/grapher/stackedCharts/StackedDiscreteBars.tsx +2 -2
- package/src/grapher/tabs/Tabs.tsx +1 -1
- package/src/grapher/testData/{OwidTestData.sample.ts → TestData.sample.ts} +7 -7
- package/src/grapher/testData/{OwidTestData.ts → TestData.ts} +5 -5
- package/src/index.ts +7 -7
- package/src/types/{OwidOrigin.ts → Origin.ts} +3 -3
- package/src/types/{OwidSource.ts → Source.ts} +1 -1
- package/src/types/Variable.ts +133 -0
- package/src/types/{OwidVariableDisplayConfigInterface.ts → VariableDisplayConfigInterface.ts} +11 -11
- package/src/types/domainTypes/ContentGraph.ts +3 -3
- package/src/types/domainTypes/CoreTableTypes.ts +29 -29
- package/src/types/domainTypes/Posts.ts +2 -2
- package/src/types/domainTypes/Search.ts +6 -6
- package/src/types/domainTypes/Various.ts +1 -1
- package/src/types/gdocTypes/Gdoc.ts +42 -42
- package/src/types/grapherTypes/GrapherTypes.ts +21 -21
- package/src/types/index.ts +51 -51
- package/src/utils/MultiDimDataPageConfig.ts +1 -1
- package/src/utils/Util.ts +61 -55
- package/src/utils/{OwidVariable.ts → Variable.ts} +15 -15
- package/src/utils/formatValue.ts +12 -12
- package/src/utils/image.ts +12 -12
- package/src/utils/index.ts +5 -5
- package/src/utils/metadataHelpers.ts +19 -19
- package/src/utils/regions.ts +9 -9
- package/LICENSE.md +0 -8
- package/README.md +0 -113
- package/src/types/OwidVariable.ts +0 -133
|
@@ -2,7 +2,7 @@ import * as _ from "lodash-es"
|
|
|
2
2
|
import { computed, makeObservable } from "mobx"
|
|
3
3
|
import { ChartState } from "../chart/ChartInterface"
|
|
4
4
|
import { StackedDiscreteBarChartManager } from "./StackedDiscreteBarChart"
|
|
5
|
-
import { CoreColumn,
|
|
5
|
+
import { CoreColumn, ChartsTable } from "../../core-table/index.js"
|
|
6
6
|
import {
|
|
7
7
|
ChartErrorInfo,
|
|
8
8
|
ColorSchemeName,
|
|
@@ -39,18 +39,18 @@ export class StackedDiscreteBarChartState implements ChartState {
|
|
|
39
39
|
makeObservable(this)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
@computed get inputTable():
|
|
42
|
+
@computed get inputTable(): ChartsTable {
|
|
43
43
|
return this.manager.table
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
@computed get transformedTable():
|
|
46
|
+
@computed get transformedTable(): ChartsTable {
|
|
47
47
|
return (
|
|
48
48
|
this.manager.transformedTable ??
|
|
49
49
|
this.transformTable(this.inputTable)
|
|
50
50
|
)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
transformTable(table:
|
|
53
|
+
transformTable(table: ChartsTable): ChartsTable {
|
|
54
54
|
if (!this.yColumnSlugs.length) return table
|
|
55
55
|
|
|
56
56
|
table = table.filterByEntityNames(
|
|
@@ -82,7 +82,7 @@ export class StackedDiscreteBarChartState implements ChartState {
|
|
|
82
82
|
return table
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
transformTableForSelection(table:
|
|
85
|
+
transformTableForSelection(table: ChartsTable): ChartsTable {
|
|
86
86
|
table = table
|
|
87
87
|
.replaceNonNumericCellsWithErrorValues(this.yColumnSlugs)
|
|
88
88
|
.replaceNegativeCellsWithErrorValues(this.yColumnSlugs)
|
|
@@ -93,14 +93,14 @@ export class StackedDiscreteBarChartState implements ChartState {
|
|
|
93
93
|
return table
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
private applyMissingDataStrategy(table:
|
|
96
|
+
private applyMissingDataStrategy(table: ChartsTable): ChartsTable {
|
|
97
97
|
// We want to remove all rows with missing data for at least one column if:
|
|
98
98
|
// - MissingDataStrategy is explicitly set to hide, or
|
|
99
99
|
// - We are in relative mode and MissingDataStrategy is not explicitly set to show:
|
|
100
100
|
// If we are showing relative mode, we want to drop all rows that are missing data for
|
|
101
101
|
// any column, because otherwise the displayed data will be misleading in that it may
|
|
102
102
|
// suggest patterns that are not actually present.
|
|
103
|
-
// see
|
|
103
|
+
// see # legacy issue 2860
|
|
104
104
|
|
|
105
105
|
const shouldRemoveRows =
|
|
106
106
|
this.missingDataStrategy === MissingDataStrategy.hide ||
|
|
@@ -162,7 +162,7 @@ export class StackedDiscreteBarChartState implements ChartState {
|
|
|
162
162
|
return (
|
|
163
163
|
(this.manager.baseColorScheme
|
|
164
164
|
? ColorSchemes.get(this.manager.baseColorScheme)
|
|
165
|
-
: null) ?? ColorSchemes.get(ColorSchemeName["
|
|
165
|
+
: null) ?? ColorSchemes.get(ColorSchemeName["distinct"])
|
|
166
166
|
)
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -187,7 +187,7 @@ export class StackedDiscreteBarChartState implements ChartState {
|
|
|
187
187
|
color: this.categoricalColorAssigner.assign(
|
|
188
188
|
col.displayName
|
|
189
189
|
),
|
|
190
|
-
points: col.
|
|
190
|
+
points: col.dataRows.map((row) => ({
|
|
191
191
|
time: row.originalTime,
|
|
192
192
|
position: row.entityName,
|
|
193
193
|
value: row.value,
|
|
@@ -250,10 +250,10 @@ export class StackedDiscreteBarChartState implements ChartState {
|
|
|
250
250
|
sortByFunc = (item: Item): string => item.entityName
|
|
251
251
|
break
|
|
252
252
|
case SortBy.column: {
|
|
253
|
-
const
|
|
254
|
-
this.sortColumn?.
|
|
253
|
+
const dataRowsByEntityName =
|
|
254
|
+
this.sortColumn?.dataRowsByEntityName
|
|
255
255
|
sortByFunc = (item: Item): number => {
|
|
256
|
-
const rows =
|
|
256
|
+
const rows = dataRowsByEntityName?.get(item.entityName)
|
|
257
257
|
return rows?.[0]?.value ?? 0
|
|
258
258
|
}
|
|
259
259
|
break
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "../axis/AxisViews"
|
|
29
29
|
import { AxisConfig } from "../axis/AxisConfig"
|
|
30
30
|
import { ChartInterface } from "../chart/ChartInterface"
|
|
31
|
-
import {
|
|
31
|
+
import { ChartsTable, CoreColumn } from "../../core-table/index.js"
|
|
32
32
|
import { ChartManager } from "../chart/ChartManager"
|
|
33
33
|
import { TooltipFooterIcon } from "../tooltip/TooltipProps.js"
|
|
34
34
|
import {
|
|
@@ -311,7 +311,7 @@ export class StackedDiscreteBars
|
|
|
311
311
|
: this.renderInteractive()
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
@computed private get inputTable():
|
|
314
|
+
@computed private get inputTable(): ChartsTable {
|
|
315
315
|
return this.chartState.inputTable
|
|
316
316
|
}
|
|
317
317
|
|
|
@@ -4,10 +4,10 @@ import { GrapherState } from "../core/GrapherState"
|
|
|
4
4
|
import {
|
|
5
5
|
TestData,
|
|
6
6
|
TestMetadata,
|
|
7
|
-
|
|
7
|
+
createTestDataset,
|
|
8
8
|
fakeEntities,
|
|
9
|
-
} from "../testData/
|
|
10
|
-
import {
|
|
9
|
+
} from "../testData/TestData"
|
|
10
|
+
import { legacyToChartsTableAndDimensionsWithMandatorySlug } from "../core/LegacyToChartsTable.js"
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Comprehensive life expectancy test data covering:
|
|
@@ -170,8 +170,8 @@ export const LifeExpectancyGrapher = (
|
|
|
170
170
|
...props,
|
|
171
171
|
dimensions,
|
|
172
172
|
})
|
|
173
|
-
const inputTable =
|
|
174
|
-
|
|
173
|
+
const inputTable = legacyToChartsTableAndDimensionsWithMandatorySlug(
|
|
174
|
+
createTestDataset([
|
|
175
175
|
{ data: lifeExpectancyData, metadata: lifeExpectancyMetadata },
|
|
176
176
|
]),
|
|
177
177
|
dimensions,
|
|
@@ -261,8 +261,8 @@ export const CanadaProvinceGrapher = (
|
|
|
261
261
|
...props,
|
|
262
262
|
dimensions,
|
|
263
263
|
})
|
|
264
|
-
const inputTable =
|
|
265
|
-
|
|
264
|
+
const inputTable = legacyToChartsTableAndDimensionsWithMandatorySlug(
|
|
265
|
+
createTestDataset([
|
|
266
266
|
{ data: provinceData, metadata: populationMetadata },
|
|
267
267
|
]),
|
|
268
268
|
dimensions,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _ from "lodash-es"
|
|
2
2
|
import { Region, regions } from "../../utils/index.js"
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
MultipleVariableDataDimensionsMap,
|
|
5
|
+
VariableWithSource,
|
|
6
6
|
EntityCode,
|
|
7
7
|
EntityId,
|
|
8
8
|
EntityName,
|
|
@@ -12,7 +12,7 @@ type Entity = { id: EntityId; code?: EntityCode; name?: EntityName }
|
|
|
12
12
|
type TestDatum = { year: number; entity: Entity; value: string | number }
|
|
13
13
|
|
|
14
14
|
export type TestData = TestDatum[]
|
|
15
|
-
export type TestMetadata =
|
|
15
|
+
export type TestMetadata = VariableWithSource
|
|
16
16
|
|
|
17
17
|
const fakeRegions = regions.map((region: Region, index: number) => ({
|
|
18
18
|
...region,
|
|
@@ -26,12 +26,12 @@ export const fakeEntities = Object.fromEntries(
|
|
|
26
26
|
])
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
export function
|
|
29
|
+
export function createTestDataset(
|
|
30
30
|
indicators: {
|
|
31
31
|
data: TestData
|
|
32
32
|
metadata: TestMetadata
|
|
33
33
|
}[]
|
|
34
|
-
):
|
|
34
|
+
): MultipleVariableDataDimensionsMap {
|
|
35
35
|
return new Map(
|
|
36
36
|
indicators.map(({ data, metadata }) => [
|
|
37
37
|
metadata.id,
|
package/src/index.ts
CHANGED
|
@@ -194,20 +194,20 @@ export {
|
|
|
194
194
|
|
|
195
195
|
// Legacy conversion
|
|
196
196
|
export {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
} from "./grapher/core/
|
|
197
|
+
legacyToChartsTableAndDimensions,
|
|
198
|
+
legacyToChartsTableAndDimensionsWithMandatorySlug,
|
|
199
|
+
} from "./grapher/core/LegacyToChartsTable.js"
|
|
200
200
|
|
|
201
201
|
export { legacyToCurrentGrapherUrl } from "./grapher/core/GrapherUrlMigrations.js"
|
|
202
202
|
|
|
203
203
|
// Test data helpers (useful for demos and testing)
|
|
204
204
|
export {
|
|
205
205
|
fakeEntities,
|
|
206
|
-
|
|
206
|
+
createTestDataset,
|
|
207
207
|
type TestData,
|
|
208
208
|
type TestMetadata,
|
|
209
|
-
} from "./grapher/testData/
|
|
210
|
-
export { LifeExpectancyGrapher } from "./grapher/testData/
|
|
209
|
+
} from "./grapher/testData/TestData.js"
|
|
210
|
+
export { LifeExpectancyGrapher } from "./grapher/testData/TestData.sample.js"
|
|
211
211
|
|
|
212
212
|
// Types commonly needed for data loading
|
|
213
213
|
export {
|
|
@@ -223,4 +223,4 @@ export {
|
|
|
223
223
|
|
|
224
224
|
// Utilities for data loading
|
|
225
225
|
export { Bounds } from "./utils/index.js"
|
|
226
|
-
export { parseDelimited,
|
|
226
|
+
export { parseDelimited, ChartsTable, BlankChartsTable } from "./core-table/index.js"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
1
|
+
import { License } from "./Variable.js"
|
|
2
|
+
export interface Origin {
|
|
3
3
|
id?: number
|
|
4
4
|
title?: string
|
|
5
5
|
titleSnapshot?: string
|
|
6
6
|
attribution?: string
|
|
7
7
|
attributionShort?: string
|
|
8
8
|
versionProducer?: string
|
|
9
|
-
license?:
|
|
9
|
+
license?: License
|
|
10
10
|
descriptionSnapshot?: string
|
|
11
11
|
description?: string
|
|
12
12
|
producer?: string
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Origin } from "./Origin.js"
|
|
2
|
+
import { Source } from "./Source.js"
|
|
3
|
+
import { VariableDisplayConfigInterface } from "./VariableDisplayConfigInterface.js"
|
|
4
|
+
|
|
5
|
+
export interface VariableWithSource {
|
|
6
|
+
id: number
|
|
7
|
+
name?: string
|
|
8
|
+
description?: string
|
|
9
|
+
descriptionShort?: string
|
|
10
|
+
descriptionFromProducer?: string
|
|
11
|
+
descriptionKey?: string[]
|
|
12
|
+
descriptionProcessing?: string
|
|
13
|
+
unit?: string
|
|
14
|
+
display?: VariableDisplayConfigInterface
|
|
15
|
+
shortUnit?: string
|
|
16
|
+
datasetName?: string
|
|
17
|
+
datasetId?: number
|
|
18
|
+
coverage?: string
|
|
19
|
+
nonRedistributable?: boolean
|
|
20
|
+
source?: Source
|
|
21
|
+
origins?: Origin[]
|
|
22
|
+
schemaVersion?: number
|
|
23
|
+
processingLevel?: ProcessingLevel
|
|
24
|
+
presentation?: VariablePresentation
|
|
25
|
+
shortName?: string
|
|
26
|
+
timespan?: string
|
|
27
|
+
catalogPath?: string
|
|
28
|
+
license?: License
|
|
29
|
+
updatePeriodDays?: number
|
|
30
|
+
datasetVersion?: string
|
|
31
|
+
licenses?: License[]
|
|
32
|
+
type?: VariableType
|
|
33
|
+
|
|
34
|
+
// omitted:
|
|
35
|
+
// code
|
|
36
|
+
// coverage
|
|
37
|
+
// dataPath
|
|
38
|
+
// metadataPath
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IndicatorTitleWithFragments {
|
|
42
|
+
title: string
|
|
43
|
+
attributionShort?: string
|
|
44
|
+
titleVariant?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function joinTitleFragments(
|
|
48
|
+
attributionShort: string | undefined,
|
|
49
|
+
titleVariant: string | undefined
|
|
50
|
+
): string | undefined {
|
|
51
|
+
if (attributionShort && titleVariant && attributionShort !== titleVariant) {
|
|
52
|
+
return `${titleVariant} – ${attributionShort}`
|
|
53
|
+
}
|
|
54
|
+
if (attributionShort) {
|
|
55
|
+
return attributionShort
|
|
56
|
+
}
|
|
57
|
+
if (titleVariant) {
|
|
58
|
+
return titleVariant
|
|
59
|
+
}
|
|
60
|
+
return undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface License {
|
|
64
|
+
name: string
|
|
65
|
+
url: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface VariablePresentation {
|
|
69
|
+
titlePublic?: string
|
|
70
|
+
titleVariant?: string
|
|
71
|
+
attributionShort?: string
|
|
72
|
+
attribution?: string
|
|
73
|
+
topicTagsLinks?: string[]
|
|
74
|
+
faqs?: FaqLink[]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type ProcessingLevel = "minor" | "major"
|
|
78
|
+
|
|
79
|
+
export interface FaqLink {
|
|
80
|
+
gdocId: string
|
|
81
|
+
fragmentId: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type VariableWithSourceAndDimension = VariableWithSource & {
|
|
85
|
+
dimensions: VariableDimensions
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type VariableWithSourceAndDimensionWithoutId = Omit<
|
|
89
|
+
VariableWithSourceAndDimension,
|
|
90
|
+
"id"
|
|
91
|
+
>
|
|
92
|
+
|
|
93
|
+
export interface VariableMixedData {
|
|
94
|
+
years: number[]
|
|
95
|
+
entities: number[]
|
|
96
|
+
values: (string | number)[]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type VariableWithDataAndSource = VariableWithSource &
|
|
100
|
+
VariableMixedData
|
|
101
|
+
|
|
102
|
+
export interface VariableDimension {
|
|
103
|
+
values: VariableDimensionValuePartial[]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface VariableDimensions {
|
|
107
|
+
years: VariableDimension
|
|
108
|
+
entities: VariableDimension
|
|
109
|
+
values?: VariableDimension
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type VariableDataMetadataDimensions = {
|
|
113
|
+
data: VariableMixedData
|
|
114
|
+
metadata: VariableWithSourceAndDimension
|
|
115
|
+
}
|
|
116
|
+
export type MultipleVariableDataDimensionsMap = Map<
|
|
117
|
+
number,
|
|
118
|
+
VariableDataMetadataDimensions
|
|
119
|
+
>
|
|
120
|
+
|
|
121
|
+
export interface VariableDimensionValuePartial {
|
|
122
|
+
id: number
|
|
123
|
+
name?: string
|
|
124
|
+
code?: string
|
|
125
|
+
}
|
|
126
|
+
export type VariableDimensionValueFull =
|
|
127
|
+
Required<VariableDimensionValuePartial>
|
|
128
|
+
|
|
129
|
+
export interface EntityKey {
|
|
130
|
+
[id: string]: VariableDimensionValuePartial
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type VariableType = "string" | "float" | "int" | "mixed" | "ordinal"
|
package/src/types/{OwidVariableDisplayConfigInterface.ts → VariableDisplayConfigInterface.ts}
RENAMED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VariableId } from "./domainTypes/Various.js"
|
|
2
2
|
import {
|
|
3
3
|
ColumnSlug,
|
|
4
4
|
DimensionProperty,
|
|
5
5
|
Time,
|
|
6
6
|
} from "./grapherTypes/GrapherTypes.js"
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface VariableDisplayConfigInterface {
|
|
9
9
|
name?: string
|
|
10
10
|
unit?: string
|
|
11
11
|
shortUnit?: string
|
|
12
12
|
isProjection?: boolean
|
|
13
13
|
conversionFactor?: number
|
|
14
|
-
roundingMode?:
|
|
14
|
+
roundingMode?: VariableRoundingMode
|
|
15
15
|
numDecimalPlaces?: number
|
|
16
16
|
numSignificantFigures?: number
|
|
17
17
|
tolerance?: number
|
|
@@ -19,31 +19,31 @@ export interface OwidVariableDisplayConfigInterface {
|
|
|
19
19
|
zeroDay?: string
|
|
20
20
|
entityAnnotationsMap?: string
|
|
21
21
|
includeInTable?: boolean
|
|
22
|
-
tableDisplay?:
|
|
22
|
+
tableDisplay?: VariableDataTableConfigInterface
|
|
23
23
|
color?: string
|
|
24
24
|
plotMarkersOnlyInLineChart?: boolean
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// todo: flatten onto the above
|
|
28
|
-
export interface
|
|
28
|
+
export interface VariableDataTableConfigInterface {
|
|
29
29
|
hideAbsoluteChange?: boolean
|
|
30
30
|
hideRelativeChange?: boolean
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export enum
|
|
33
|
+
export enum VariableRoundingMode {
|
|
34
34
|
decimalPlaces = "decimalPlaces",
|
|
35
35
|
significantFigures = "significantFigures",
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface
|
|
38
|
+
export interface ChartDimensionInterface {
|
|
39
39
|
property: DimensionProperty
|
|
40
40
|
targetYear?: Time
|
|
41
|
-
display?:
|
|
42
|
-
variableId:
|
|
41
|
+
display?: VariableDisplayConfigInterface
|
|
42
|
+
variableId: VariableId
|
|
43
43
|
slug?: ColumnSlug
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export interface
|
|
47
|
-
extends
|
|
46
|
+
export interface ChartDimensionInterfaceWithMandatorySlug
|
|
47
|
+
extends ChartDimensionInterface {
|
|
48
48
|
slug: ColumnSlug
|
|
49
49
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DbPlainTag } from "../dbTypes/Tags.js"
|
|
2
|
-
import {
|
|
2
|
+
import { GdocType } from "../gdocTypes/Gdoc.js"
|
|
3
3
|
|
|
4
4
|
export interface EntryMeta {
|
|
5
5
|
slug: string
|
|
@@ -46,7 +46,7 @@ export interface TagGraphNode {
|
|
|
46
46
|
weight: number
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export
|
|
49
|
+
export interface TagGraphRoot {
|
|
50
50
|
children: TagGraphNode[]
|
|
51
51
|
id: number
|
|
52
52
|
isTopic: false
|
|
@@ -61,7 +61,7 @@ export interface PostReference {
|
|
|
61
61
|
title: string
|
|
62
62
|
slug: string
|
|
63
63
|
url: string
|
|
64
|
-
type:
|
|
64
|
+
type: GdocType
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export enum ContentGraphLinkType {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Origin } from "../Origin.js"
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "../
|
|
6
|
-
import {
|
|
3
|
+
ProcessingLevel,
|
|
4
|
+
VariablePresentation,
|
|
5
|
+
} from "../Variable.js"
|
|
6
|
+
import { VariableDisplayConfigInterface } from "../VariableDisplayConfigInterface.js"
|
|
7
7
|
import {
|
|
8
8
|
Color,
|
|
9
9
|
ColumnSlug,
|
|
@@ -119,7 +119,7 @@ type CoreVector = any[]
|
|
|
119
119
|
*/
|
|
120
120
|
export type CoreMatrix = CoreVector[]
|
|
121
121
|
|
|
122
|
-
export enum
|
|
122
|
+
export enum ChartsTableSlugs {
|
|
123
123
|
entityName = "entityName",
|
|
124
124
|
entityColor = "entityColor",
|
|
125
125
|
entityId = "entityId",
|
|
@@ -130,7 +130,7 @@ export enum OwidTableSlugs {
|
|
|
130
130
|
date = "date",
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
enum
|
|
133
|
+
enum ChartsTableNames {
|
|
134
134
|
Entity = "Entity",
|
|
135
135
|
Code = "Code",
|
|
136
136
|
}
|
|
@@ -224,8 +224,8 @@ export interface CoreColumnDef extends ColumnColorScale {
|
|
|
224
224
|
timespan?: string
|
|
225
225
|
|
|
226
226
|
// Metadata v2
|
|
227
|
-
origins?:
|
|
228
|
-
presentation?:
|
|
227
|
+
origins?: Origin[]
|
|
228
|
+
presentation?: VariablePresentation
|
|
229
229
|
updatePeriodDays?: number
|
|
230
230
|
|
|
231
231
|
// Dataset information
|
|
@@ -243,12 +243,12 @@ export interface CoreColumnDef extends ColumnColorScale {
|
|
|
243
243
|
// DEPRECATED
|
|
244
244
|
unit?: string // DEPRECATED: use an existing column type or create a new one instead.
|
|
245
245
|
shortUnit?: string // DEPRECATED: use an existing column type or create a new one instead.
|
|
246
|
-
display?:
|
|
246
|
+
display?: VariableDisplayConfigInterface // DEPRECATED: use an existing column type or create a new one instead, or migrate any properties you need onto this interface.
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// Todo: coverage, datasetId, and datasetName can just be on source, right? or should we flatten source onto this?
|
|
250
|
-
export interface
|
|
251
|
-
|
|
250
|
+
export interface ColumnDef extends CoreColumnDef {
|
|
251
|
+
variableId?: number
|
|
252
252
|
coverage?: string
|
|
253
253
|
datasetId?: number
|
|
254
254
|
datasetName?: string
|
|
@@ -257,36 +257,36 @@ export interface OwidColumnDef extends CoreColumnDef {
|
|
|
257
257
|
nonRedistributable?: boolean
|
|
258
258
|
skipParsing?: boolean
|
|
259
259
|
catalogPath?: string
|
|
260
|
-
|
|
261
|
-
|
|
260
|
+
processingLevel?: ProcessingLevel
|
|
261
|
+
schemaVersion?: number
|
|
262
262
|
shortName?: string
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
export const
|
|
266
|
-
name:
|
|
267
|
-
slug:
|
|
265
|
+
export const EntityNameColumnDef = {
|
|
266
|
+
name: ChartsTableNames.Entity,
|
|
267
|
+
slug: ChartsTableSlugs.entityName,
|
|
268
268
|
type: ColumnTypeNames.EntityName,
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
export const
|
|
272
|
-
slug:
|
|
271
|
+
export const EntityIdColumnDef = {
|
|
272
|
+
slug: ChartsTableSlugs.entityId,
|
|
273
273
|
type: ColumnTypeNames.EntityId,
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
export const
|
|
277
|
-
name:
|
|
278
|
-
slug:
|
|
276
|
+
export const EntityCodeColumnDef = {
|
|
277
|
+
name: ChartsTableNames.Code,
|
|
278
|
+
slug: ChartsTableSlugs.entityCode,
|
|
279
279
|
type: ColumnTypeNames.EntityCode,
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
export const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
export const StandardColumnDefs: ColumnDef[] = [
|
|
283
|
+
EntityNameColumnDef,
|
|
284
|
+
EntityIdColumnDef,
|
|
285
|
+
EntityCodeColumnDef,
|
|
286
286
|
]
|
|
287
287
|
|
|
288
|
-
// This is a row with the additional columns specific to our
|
|
289
|
-
export interface
|
|
288
|
+
// This is a row with the additional columns specific to our data model
|
|
289
|
+
export interface Row extends CoreRow {
|
|
290
290
|
entityName: EntityName
|
|
291
291
|
time: Time
|
|
292
292
|
entityCode?: EntityCode
|
|
@@ -296,7 +296,7 @@ export interface OwidRow extends CoreRow {
|
|
|
296
296
|
date?: string
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
export interface
|
|
299
|
+
export interface VariableRow<ValueType extends PrimitiveType> {
|
|
300
300
|
entityName: EntityName
|
|
301
301
|
time: Time
|
|
302
302
|
value: ValueType
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GdocType } from "../gdocTypes/Gdoc.js"
|
|
2
2
|
import { WP_PostType } from "../wordpressTypes/WordpressTypes.js"
|
|
3
3
|
import { RelatedChart } from "../grapherTypes/GrapherTypes.js"
|
|
4
4
|
import { TocHeading } from "./Toc.js"
|
|
@@ -15,7 +15,7 @@ export interface FormattedPost extends FullPost {
|
|
|
15
15
|
export interface IndexPost {
|
|
16
16
|
title: string
|
|
17
17
|
slug: string
|
|
18
|
-
type?: WP_PostType |
|
|
18
|
+
type?: WP_PostType | GdocType
|
|
19
19
|
date: Date
|
|
20
20
|
modifiedDate: Date
|
|
21
21
|
authors: string[]
|
|
@@ -4,14 +4,14 @@ import type {
|
|
|
4
4
|
Hit,
|
|
5
5
|
HitHighlightResult,
|
|
6
6
|
} from "instantsearch.js"
|
|
7
|
-
import {
|
|
7
|
+
import { GdocType } from "../gdocTypes/Gdoc.js"
|
|
8
8
|
import { GrapherTabName } from "../grapherTypes/GrapherTypes.js"
|
|
9
9
|
import * as z from "zod/mini"
|
|
10
10
|
|
|
11
11
|
export const PagesIndexRecordSchema = z.object({
|
|
12
12
|
objectID: z.string(),
|
|
13
13
|
importance: z.number(),
|
|
14
|
-
type: z.enum(
|
|
14
|
+
type: z.enum(GdocType),
|
|
15
15
|
slug: z.string(),
|
|
16
16
|
title: z.string(),
|
|
17
17
|
content: z.string(),
|
|
@@ -176,7 +176,7 @@ export type DataInsightHit = {
|
|
|
176
176
|
thumbnailUrl: string
|
|
177
177
|
date: string
|
|
178
178
|
slug: string
|
|
179
|
-
type:
|
|
179
|
+
type: GdocType.DataInsight
|
|
180
180
|
objectID: string
|
|
181
181
|
__position: number
|
|
182
182
|
}
|
|
@@ -188,7 +188,7 @@ export type FlatArticleHit = {
|
|
|
188
188
|
thumbnailUrl: string
|
|
189
189
|
date: string
|
|
190
190
|
slug: string
|
|
191
|
-
type:
|
|
191
|
+
type: GdocType.Article | GdocType.AboutPage
|
|
192
192
|
content: string
|
|
193
193
|
authors: string[]
|
|
194
194
|
objectID: string
|
|
@@ -199,7 +199,7 @@ export type StackedArticleHit = {
|
|
|
199
199
|
title: string
|
|
200
200
|
thumbnailUrl: string
|
|
201
201
|
slug: string
|
|
202
|
-
type:
|
|
202
|
+
type: GdocType.Article | GdocType.AboutPage
|
|
203
203
|
content: string
|
|
204
204
|
objectID: string
|
|
205
205
|
__position: number
|
|
@@ -210,7 +210,7 @@ export type SearchFlatArticleResponse = SearchResponse<FlatArticleHit>
|
|
|
210
210
|
|
|
211
211
|
export type TopicPageHit = {
|
|
212
212
|
title: string
|
|
213
|
-
type:
|
|
213
|
+
type: GdocType.TopicPage | GdocType.LinearTopicPage
|
|
214
214
|
slug: string
|
|
215
215
|
excerpt: string
|
|
216
216
|
excerptLong?: string[]
|