@buildcanada/charts 0.1.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- 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/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 +46 -46
- 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 +12 -12
- 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 +3 -3
- 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/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/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 +2 -2
- 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 +50 -50
- 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/src/types/OwidVariable.ts +0 -133
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
CoreColumn,
|
|
5
5
|
defaultIfErrorValue,
|
|
6
6
|
isNotErrorValue,
|
|
7
|
-
|
|
7
|
+
ChartsTable,
|
|
8
8
|
} from "../../core-table/index.js"
|
|
9
9
|
import { ChartState } from "../chart/ChartInterface"
|
|
10
10
|
import { ColorScale, ColorScaleManager } from "../color/ColorScale"
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
lowerCaseFirstLetterUnlessAbbreviation,
|
|
37
37
|
} from "../../utils/index.js"
|
|
38
38
|
import { ColorScaleConfig } from "../color/ColorScaleConfig"
|
|
39
|
-
import {
|
|
39
|
+
import { NO_DATA_GRAY } from "../color/ColorConstants"
|
|
40
40
|
import { AxisConfig } from "../axis/AxisConfig"
|
|
41
41
|
import { BASE_FONT_SIZE } from "../core/GrapherConstants"
|
|
42
42
|
import { SelectionArray } from "../selection/SelectionArray"
|
|
@@ -49,7 +49,7 @@ export class ScatterPlotChartState implements ChartState, ColorScaleManager {
|
|
|
49
49
|
|
|
50
50
|
colorScale: ColorScale
|
|
51
51
|
defaultBaseColorScheme = ColorSchemeName.continents
|
|
52
|
-
defaultNoDataColor =
|
|
52
|
+
defaultNoDataColor = NO_DATA_GRAY
|
|
53
53
|
|
|
54
54
|
constructor({ manager }: { manager: ScatterPlotManager }) {
|
|
55
55
|
this.manager = manager
|
|
@@ -57,11 +57,11 @@ export class ScatterPlotChartState implements ChartState, ColorScaleManager {
|
|
|
57
57
|
makeObservable(this)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
@computed get inputTable():
|
|
60
|
+
@computed get inputTable(): ChartsTable {
|
|
61
61
|
return this.manager.table
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
@computed get transformedTableFromGrapher():
|
|
64
|
+
@computed get transformedTableFromGrapher(): ChartsTable {
|
|
65
65
|
return (
|
|
66
66
|
this.manager.transformedTable ??
|
|
67
67
|
this.transformTable(this.inputTable)
|
|
@@ -69,7 +69,7 @@ export class ScatterPlotChartState implements ChartState, ColorScaleManager {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// TODO chunk this up into multiple computeds for better performance?
|
|
72
|
-
@computed get transformedTable():
|
|
72
|
+
@computed get transformedTable(): ChartsTable {
|
|
73
73
|
let table = this.transformedTableFromGrapher
|
|
74
74
|
// We don't want to apply this transform when relative mode is also enabled, it has a
|
|
75
75
|
// slightly different endpoints logic that drops initial zeroes to avoid DivideByZero error.
|
|
@@ -85,7 +85,7 @@ export class ScatterPlotChartState implements ChartState, ColorScaleManager {
|
|
|
85
85
|
return table
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
transformTable(table:
|
|
88
|
+
transformTable(table: ChartsTable): ChartsTable {
|
|
89
89
|
// Drop all entities that have no data in either the X or Y column.
|
|
90
90
|
// For some charts, this can drop more than 50% of rows, so we do it first.
|
|
91
91
|
// If there's no data at all for an entity, then tolerance can also not "recover" any data, so this is safe to do.
|
|
@@ -153,7 +153,7 @@ export class ScatterPlotChartState implements ChartState, ColorScaleManager {
|
|
|
153
153
|
return table
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
transformTableForDisplay(table:
|
|
156
|
+
transformTableForDisplay(table: ChartsTable): ChartsTable {
|
|
157
157
|
// Drop any rows which have non-number values for X or Y.
|
|
158
158
|
table = table
|
|
159
159
|
.columnFilter(
|
|
@@ -6,7 +6,7 @@ import { TextWrap, Halo } from "../../components/index.js"
|
|
|
6
6
|
import {
|
|
7
7
|
Color,
|
|
8
8
|
makeIdForHumanConsumption,
|
|
9
|
-
|
|
9
|
+
VariableRoundingMode,
|
|
10
10
|
} from "../../utils/index.js"
|
|
11
11
|
import {
|
|
12
12
|
BASE_FONT_SIZE,
|
|
@@ -184,7 +184,7 @@ export class ScatterSizeLegend {
|
|
|
184
184
|
value,
|
|
185
185
|
{
|
|
186
186
|
roundingMode:
|
|
187
|
-
|
|
187
|
+
VariableRoundingMode.decimalPlaces,
|
|
188
188
|
}
|
|
189
189
|
)}
|
|
190
190
|
cx={cx}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./ScatterPlotChartConstants"
|
|
19
19
|
import { BASE_FONT_SIZE } from "../core/GrapherConstants.js"
|
|
20
20
|
import { ScatterPlotChartState } from "./ScatterPlotChartState"
|
|
21
|
-
import {
|
|
21
|
+
import { ChartsTable } from "../../core-table/index.js"
|
|
22
22
|
|
|
23
23
|
export const labelPriority = (label: ScatterLabel): number => {
|
|
24
24
|
let priority = label.fontSize
|
|
@@ -257,7 +257,7 @@ export function toSizeRange(
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
export function computeSizeDomain(
|
|
260
|
-
table:
|
|
260
|
+
table: ChartsTable,
|
|
261
261
|
slug: ColumnSlug
|
|
262
262
|
): ValueRange {
|
|
263
263
|
const sizeValues = table.get(slug).values.filter(_.isNumber)
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
$schema: "http://json-schema.org/draft-07/schema#"
|
|
2
2
|
# if you update the required keys, make sure that the mergeGrapherConfigs and
|
|
3
3
|
# diffGrapherConfigs functions both reflect this change
|
|
4
|
-
$id: "https://
|
|
4
|
+
$id: "https://buildcanada.github.io/schemas/grapher-schema.009.json"
|
|
5
5
|
required:
|
|
6
6
|
- $schema
|
|
7
7
|
- dimensions
|
|
8
8
|
type: object
|
|
9
9
|
description: |
|
|
10
|
-
|
|
10
|
+
Grapher configuration. Most of the fields can be left empty and will be
|
|
11
11
|
filled with reasonable default values.
|
|
12
12
|
properties:
|
|
13
13
|
$schema:
|
|
14
14
|
type: string
|
|
15
15
|
description: Url of the concrete schema version to use to validate this document
|
|
16
16
|
format: uri
|
|
17
|
-
default: "https://
|
|
17
|
+
default: "https://buildcanada.github.io/schemas/grapher-schema.009.json"
|
|
18
18
|
# We restrict the $schema field to a single value since we expect all
|
|
19
19
|
# configs in our database to be valid against the latest schema.
|
|
20
20
|
# If we ever need to validate configs against multiple schema versions,
|
|
21
21
|
# we can remove this constraint.
|
|
22
|
-
const: "https://
|
|
22
|
+
const: "https://buildcanada.github.io/schemas/grapher-schema.009.json"
|
|
23
23
|
id:
|
|
24
24
|
type: integer
|
|
25
|
-
description: Internal DB id. Useful internally
|
|
25
|
+
description: Internal DB id. Useful internally but not required if just using grapher directly.
|
|
26
26
|
minimum: 0
|
|
27
27
|
map:
|
|
28
28
|
type: object
|
|
@@ -260,11 +260,11 @@ properties:
|
|
|
260
260
|
logo:
|
|
261
261
|
type: string
|
|
262
262
|
description: Which logo to show on the upper right side
|
|
263
|
-
default:
|
|
263
|
+
default: legacy
|
|
264
264
|
enum:
|
|
265
|
-
-
|
|
266
|
-
- core+
|
|
267
|
-
- gv+
|
|
265
|
+
- legacy
|
|
266
|
+
- core+legacy
|
|
267
|
+
- gv+legacy
|
|
268
268
|
entityType:
|
|
269
269
|
type: string
|
|
270
270
|
default: country or region
|
|
@@ -658,20 +658,20 @@ $defs:
|
|
|
658
658
|
- Viridis
|
|
659
659
|
- continents
|
|
660
660
|
- stackedAreaDefault
|
|
661
|
-
-
|
|
661
|
+
- distinct
|
|
662
662
|
- SingleColorDenim
|
|
663
663
|
- SingleColorTeal
|
|
664
664
|
- SingleColorPurple
|
|
665
665
|
- SingleColorDustyCoral
|
|
666
666
|
- SingleColorDarkCopper
|
|
667
|
-
-
|
|
668
|
-
-
|
|
669
|
-
-
|
|
670
|
-
-
|
|
671
|
-
-
|
|
672
|
-
-
|
|
673
|
-
-
|
|
674
|
-
-
|
|
667
|
+
- CategoricalA
|
|
668
|
+
- CategoricalB
|
|
669
|
+
- CategoricalC
|
|
670
|
+
- CategoricalD
|
|
671
|
+
- CategoricalE
|
|
672
|
+
- Energy
|
|
673
|
+
- EnergyLines
|
|
674
|
+
- DistinctLines
|
|
675
675
|
- BinaryMapPaletteA
|
|
676
676
|
- BinaryMapPaletteB
|
|
677
677
|
- BinaryMapPaletteC
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "./helpers"
|
|
18
18
|
import { GRAPHER_CHART_TYPES } from "../../../types/index.js"
|
|
19
19
|
|
|
20
|
-
// see
|
|
20
|
+
// see # legacy commit 26f2a0d1790c71bdda7e12f284ca552945d2f6ef
|
|
21
21
|
const migrateFrom001To002 = (
|
|
22
22
|
config: AnyConfigWithValidSchema
|
|
23
23
|
): AnyConfigWithValidSchema => {
|
|
@@ -26,7 +26,7 @@ const migrateFrom001To002 = (
|
|
|
26
26
|
return config
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// see
|
|
29
|
+
// see # legacy commit 4525ad81fb7064709ffab83677a8b0354b324dfb
|
|
30
30
|
const migrateFrom002To003 = (
|
|
31
31
|
config: AnyConfigWithValidSchema
|
|
32
32
|
): AnyConfigWithValidSchema => {
|
|
@@ -43,7 +43,7 @@ const migrateFrom002To003 = (
|
|
|
43
43
|
return config
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
// see
|
|
46
|
+
// see # legacy commit 1776721253cf61d7f1e24ebadeaf7a7ca2f43ced
|
|
47
47
|
const migrateFrom003To004 = (
|
|
48
48
|
config: AnyConfigWithValidSchema
|
|
49
49
|
): AnyConfigWithValidSchema => {
|
|
@@ -52,7 +52,7 @@ const migrateFrom003To004 = (
|
|
|
52
52
|
return config
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// see
|
|
55
|
+
// see # legacy commit 1d67de3174764a413bc5055fbdf34efb2b49e079
|
|
56
56
|
const migrateFrom004To005 = (
|
|
57
57
|
config: AnyConfigWithValidSchema
|
|
58
58
|
): AnyConfigWithValidSchema => {
|
|
@@ -73,7 +73,7 @@ export class MapSelectionArray extends SelectionArray {
|
|
|
73
73
|
@computed get selectedRegions(): (Continent | Aggregate | IncomeGroup)[] {
|
|
74
74
|
return this.selectedEntitiesWithRegionInfo.filter(
|
|
75
75
|
(region): region is Continent | Aggregate | IncomeGroup =>
|
|
76
|
-
checkHasMembers(region) && region.code !== "
|
|
76
|
+
checkHasMembers(region) && region.code !== "WRL"
|
|
77
77
|
)
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -13,4 +13,4 @@ If something happens so the user has new choices, you can expand #2.
|
|
|
13
13
|
|
|
14
14
|
Except for Scatters, only selected entities will appear in charts. In Scatters "selected entities" really are "highlighted entities". It may be nice to separate those concepts.
|
|
15
15
|
|
|
16
|
-
SeriesSelection. It may be better to rename
|
|
16
|
+
SeriesSelection. It may be better to rename ChartsTable to TimeSeriesTable, and remove the concept of `entityName` and replace with `seriesName`. Then we could have a nice simple concept "SeriesSelection". Similarly, we could ditch "EntityCode" and maybe have "SeriesNickname", which would be a shorter URL friendly way to specify seriesSelection. It would then be nice to rename the `country=` url param to something like `series=`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PartialBy, PointVector } from "../../utils/index.js"
|
|
2
|
-
import { EntityName,
|
|
2
|
+
import { EntityName, VariableRow } from "../../types/index.js"
|
|
3
3
|
import { ChartSeries } from "../chart/ChartInterface"
|
|
4
4
|
import { CoreColumn } from "../../core-table/index.js"
|
|
5
5
|
import { ChartManager } from "../chart/ChartManager"
|
|
@@ -15,8 +15,8 @@ export interface SlopeChartSeries extends ChartSeries {
|
|
|
15
15
|
column: CoreColumn
|
|
16
16
|
entityName: EntityName
|
|
17
17
|
displayName: string
|
|
18
|
-
start: Pick<
|
|
19
|
-
end: Pick<
|
|
18
|
+
start: Pick<VariableRow<number>, "value" | "originalTime">
|
|
19
|
+
end: Pick<VariableRow<number>, "value" | "originalTime">
|
|
20
20
|
annotation?: string
|
|
21
21
|
focus: InteractionState
|
|
22
22
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
RawSlopeChartSeries,
|
|
6
6
|
SlopeChartSeries,
|
|
7
7
|
} from "./SlopeChartConstants"
|
|
8
|
-
import {
|
|
8
|
+
import { ChartsTable, CoreColumn } from "../../core-table/index.js"
|
|
9
9
|
import { SelectionArray } from "../selection/SelectionArray"
|
|
10
10
|
import { FocusArray } from "../focus/FocusArray"
|
|
11
11
|
import {
|
|
@@ -44,25 +44,25 @@ import { VerticalAxis } from "../axis/Axis"
|
|
|
44
44
|
export class SlopeChartState implements ChartState {
|
|
45
45
|
manager: SlopeChartManager
|
|
46
46
|
|
|
47
|
-
defaultBaseColorScheme = ColorSchemeName.
|
|
47
|
+
defaultBaseColorScheme = ColorSchemeName.DistinctLines
|
|
48
48
|
|
|
49
49
|
constructor({ manager }: { manager: SlopeChartManager }) {
|
|
50
50
|
this.manager = manager
|
|
51
51
|
makeObservable(this)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
@computed get inputTable():
|
|
54
|
+
@computed get inputTable(): ChartsTable {
|
|
55
55
|
return this.manager.table
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
@computed get transformedTableFromGrapher():
|
|
58
|
+
@computed get transformedTableFromGrapher(): ChartsTable {
|
|
59
59
|
return (
|
|
60
60
|
this.manager.transformedTable ??
|
|
61
61
|
this.transformTable(this.inputTable)
|
|
62
62
|
)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
@computed get transformedTable():
|
|
65
|
+
@computed get transformedTable(): ChartsTable {
|
|
66
66
|
let table = this.transformedTableFromGrapher
|
|
67
67
|
// The % growth transform cannot be applied in transformTable() because it will filter out
|
|
68
68
|
// any rows before startTime and change the timeline bounds.
|
|
@@ -76,7 +76,7 @@ export class SlopeChartState implements ChartState {
|
|
|
76
76
|
return table
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
transformTable(table:
|
|
79
|
+
transformTable(table: ChartsTable) {
|
|
80
80
|
table = table.filterByEntityNames(
|
|
81
81
|
this.selectionArray.selectedEntityNames
|
|
82
82
|
)
|
|
@@ -94,7 +94,7 @@ export class SlopeChartState implements ChartState {
|
|
|
94
94
|
return table
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
transformTableForSelection(table:
|
|
97
|
+
transformTableForSelection(table: ChartsTable): ChartsTable {
|
|
98
98
|
table = table.replaceNonNumericCellsWithErrorValues(this.yColumnSlugs)
|
|
99
99
|
|
|
100
100
|
this.yColumnSlugs.forEach((slug) => {
|
|
@@ -234,9 +234,9 @@ export class SlopeChartState implements ChartState {
|
|
|
234
234
|
hasMultipleEntitiesSelected,
|
|
235
235
|
})
|
|
236
236
|
|
|
237
|
-
const
|
|
238
|
-
const start =
|
|
239
|
-
const end =
|
|
237
|
+
const dataRowByTime = column.dataRowByEntityNameAndTime.get(entityName)
|
|
238
|
+
const start = dataRowByTime?.get(startTime)
|
|
239
|
+
const end = dataRowByTime?.get(endTime)
|
|
240
240
|
|
|
241
241
|
const colorKey = getColorKey({
|
|
242
242
|
entityName,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
StackedSeries,
|
|
18
18
|
} from "./StackedConstants.js"
|
|
19
19
|
import {
|
|
20
|
-
|
|
20
|
+
ChartsTable,
|
|
21
21
|
CoreColumn,
|
|
22
22
|
isNotErrorValueOrEmptyCell,
|
|
23
23
|
} from "../../core-table/index.js"
|
|
@@ -57,18 +57,18 @@ export abstract class AbstractStackedChartState implements ChartState {
|
|
|
57
57
|
makeObservable(this)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
@computed get inputTable():
|
|
60
|
+
@computed get inputTable(): ChartsTable {
|
|
61
61
|
return this.manager.table
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
@computed get transformedTable():
|
|
64
|
+
@computed get transformedTable(): ChartsTable {
|
|
65
65
|
return (
|
|
66
66
|
this.manager.transformedTable ??
|
|
67
67
|
this.transformTable(this.inputTable)
|
|
68
68
|
)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
transformTable(table:
|
|
71
|
+
transformTable(table: ChartsTable): ChartsTable {
|
|
72
72
|
table = table.filterByEntityNames(
|
|
73
73
|
this.selectionArray.selectedEntityNames
|
|
74
74
|
)
|
|
@@ -103,7 +103,7 @@ export abstract class AbstractStackedChartState implements ChartState {
|
|
|
103
103
|
return table
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
transformTableForSelection(table:
|
|
106
|
+
transformTableForSelection(table: ChartsTable): ChartsTable {
|
|
107
107
|
// if entities with partial data are not plotted,
|
|
108
108
|
// make sure they don't show up in the entity selector
|
|
109
109
|
if (this.missingDataStrategy !== MissingDataStrategy.show) {
|
|
@@ -151,7 +151,7 @@ export abstract class AbstractStackedChartState implements ChartState {
|
|
|
151
151
|
return {
|
|
152
152
|
isProjection: column.isProjection,
|
|
153
153
|
seriesName: column.displayName,
|
|
154
|
-
rows: column.
|
|
154
|
+
rows: column.dataRows,
|
|
155
155
|
focus: this.focusArray.state(column.displayName),
|
|
156
156
|
}
|
|
157
157
|
})
|
|
@@ -162,14 +162,14 @@ export abstract class AbstractStackedChartState implements ChartState {
|
|
|
162
162
|
get entitiesAsSeries(): readonly StackedRawSeries<number>[] {
|
|
163
163
|
if (!this.yColumns.length) return []
|
|
164
164
|
|
|
165
|
-
const { isProjection,
|
|
165
|
+
const { isProjection, dataRowsByEntityName } = this.yColumns[0]
|
|
166
166
|
return this.selectionArray.selectedEntityNames
|
|
167
167
|
.map((entityName) => {
|
|
168
168
|
return {
|
|
169
169
|
isProjection,
|
|
170
170
|
seriesName: entityName,
|
|
171
171
|
shortEntityName: getShortNameForEntity(entityName),
|
|
172
|
-
rows:
|
|
172
|
+
rows: dataRowsByEntityName.get(entityName) || [],
|
|
173
173
|
focus: this.focusArray.state(entityName),
|
|
174
174
|
}
|
|
175
175
|
})
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
VerticalAlign,
|
|
31
31
|
ColorScaleConfigInterface,
|
|
32
32
|
} from "../../types/index.js"
|
|
33
|
-
import {
|
|
33
|
+
import { ChartsTable, CoreColumn } from "../../core-table/index.js"
|
|
34
34
|
import { getShortNameForEntity } from "../chart/ChartUtils"
|
|
35
35
|
import {
|
|
36
36
|
LEGEND_STYLE_FOR_STACKED_CHARTS,
|
|
@@ -111,7 +111,7 @@ export class MarimekkoChart
|
|
|
111
111
|
return this.chartState.manager
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
@computed private get inputTable():
|
|
114
|
+
@computed private get inputTable(): ChartsTable {
|
|
115
115
|
return this.chartState.inputTable
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -144,7 +144,7 @@ export class MarimekkoChart
|
|
|
144
144
|
return times ? R.last(times) : undefined
|
|
145
145
|
}
|
|
146
146
|
@computed private get tableAtLatestTimelineTimepoint():
|
|
147
|
-
|
|
|
147
|
+
| ChartsTable
|
|
148
148
|
| undefined {
|
|
149
149
|
if (this.latestTime)
|
|
150
150
|
return this.manager.tableAfterAuthorTimelineAndActiveChartTransform?.filterByTargetTimes(
|
|
@@ -714,7 +714,7 @@ export class MarimekkoChart
|
|
|
714
714
|
// we want this for the last year to pick all labels there - sortedItems
|
|
715
715
|
// changes with the time point the user selects
|
|
716
716
|
const ySizeMap: Map<string, number> = new Map(
|
|
717
|
-
yColumnsAtLastTimePoint[0].
|
|
717
|
+
yColumnsAtLastTimePoint[0].dataRows.map((row) => [
|
|
718
718
|
row.entityName,
|
|
719
719
|
row.value,
|
|
720
720
|
])
|
|
@@ -728,7 +728,7 @@ export class MarimekkoChart
|
|
|
728
728
|
: yColumnsAtLastTimePoint[0]
|
|
729
729
|
|
|
730
730
|
let labelCandidates: LabelCandidate[] =
|
|
731
|
-
labelCandidateSource.
|
|
731
|
+
labelCandidateSource.dataRows.map((row) =>
|
|
732
732
|
MarimekkoChart.labelCandidateFromItem(
|
|
733
733
|
{
|
|
734
734
|
entityName: row.entityName,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
EntityName,
|
|
9
9
|
ColumnSlug,
|
|
10
10
|
} from "../../utils/index.js"
|
|
11
|
-
import {
|
|
11
|
+
import { ChartsTable } from "../../core-table/index.js"
|
|
12
12
|
import { StackedPoint } from "./StackedConstants"
|
|
13
13
|
import { DualAxis } from "../axis/Axis"
|
|
14
14
|
import { InteractionState } from "../interaction/InteractionState.js"
|
|
@@ -17,7 +17,7 @@ export interface MarimekkoChartManager extends ChartManager {
|
|
|
17
17
|
endTime?: Time
|
|
18
18
|
matchingEntitiesOnly?: boolean
|
|
19
19
|
xOverrideTime?: number
|
|
20
|
-
tableAfterAuthorTimelineAndActiveChartTransform?:
|
|
20
|
+
tableAfterAuthorTimelineAndActiveChartTransform?: ChartsTable
|
|
21
21
|
sortConfig?: SortConfig
|
|
22
22
|
hideNoDataArea?: boolean
|
|
23
23
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
SimpleChartSeries,
|
|
13
13
|
SimplePoint,
|
|
14
14
|
} from "./MarimekkoChartConstants"
|
|
15
|
-
import { CoreColumn,
|
|
15
|
+
import { CoreColumn, ChartsTable } from "../../core-table/index.js"
|
|
16
16
|
import {
|
|
17
17
|
autoDetectYColumnSlugs,
|
|
18
18
|
getShortNameForEntity,
|
|
@@ -24,13 +24,13 @@ import {
|
|
|
24
24
|
ColorSchemeName,
|
|
25
25
|
EntityName,
|
|
26
26
|
ColorScaleConfigInterface,
|
|
27
|
-
|
|
27
|
+
VariableRow,
|
|
28
28
|
SortConfig,
|
|
29
29
|
SortBy,
|
|
30
30
|
SortOrder,
|
|
31
31
|
ScaleType,
|
|
32
32
|
} from "../../types/index.js"
|
|
33
|
-
import {
|
|
33
|
+
import { NO_DATA_GRAY } from "../color/ColorConstants"
|
|
34
34
|
import { StackedPoint, StackedSeries } from "./StackedConstants"
|
|
35
35
|
import { ColorScheme } from "../color/ColorScheme"
|
|
36
36
|
import { ColorSchemes } from "../color/ColorSchemes"
|
|
@@ -45,7 +45,7 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
45
45
|
|
|
46
46
|
colorScale: ColorScale
|
|
47
47
|
defaultBaseColorScheme = ColorSchemeName.continents
|
|
48
|
-
defaultNoDataColor =
|
|
48
|
+
defaultNoDataColor = NO_DATA_GRAY
|
|
49
49
|
|
|
50
50
|
constructor({ manager }: { manager: MarimekkoChartManager }) {
|
|
51
51
|
this.manager = manager
|
|
@@ -53,16 +53,16 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
53
53
|
makeObservable(this)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
@computed get inputTable():
|
|
56
|
+
@computed get inputTable(): ChartsTable {
|
|
57
57
|
return this.manager.table
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
@computed get transformedTable():
|
|
60
|
+
@computed get transformedTable(): ChartsTable {
|
|
61
61
|
const { inputTable } = this
|
|
62
62
|
return this.manager.transformedTable ?? this.transformTable(inputTable)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
transformTable(table:
|
|
65
|
+
transformTable(table: ChartsTable): ChartsTable {
|
|
66
66
|
const { yColumnSlugs, manager, colorColumnSlug, xColumnSlug } = this
|
|
67
67
|
if (!this.yColumnSlugs.length) return table
|
|
68
68
|
|
|
@@ -179,7 +179,7 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
179
179
|
(this.manager.baseColorScheme
|
|
180
180
|
? ColorSchemes.get(this.manager.baseColorScheme)
|
|
181
181
|
: undefined) ??
|
|
182
|
-
ColorSchemes.get(ColorSchemeName["
|
|
182
|
+
ColorSchemes.get(ColorSchemeName["distinct"])
|
|
183
183
|
)
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -198,7 +198,7 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
198
198
|
color:
|
|
199
199
|
col.def.color ??
|
|
200
200
|
colorScheme.getColors(yColumns.length)[i],
|
|
201
|
-
points: col.
|
|
201
|
+
points: col.dataRows.map((row) => ({
|
|
202
202
|
time: row.originalTime,
|
|
203
203
|
position: row.entityName,
|
|
204
204
|
value: row.value,
|
|
@@ -238,7 +238,7 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
238
238
|
|
|
239
239
|
@computed get xSeries(): SimpleChartSeries | undefined {
|
|
240
240
|
const createStackedXPoints = (
|
|
241
|
-
rows:
|
|
241
|
+
rows: VariableRow<any>[]
|
|
242
242
|
): SimplePoint[] => {
|
|
243
243
|
const points: SimplePoint[] = []
|
|
244
244
|
for (const row of rows) {
|
|
@@ -254,7 +254,7 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
254
254
|
const column = this.xColumn
|
|
255
255
|
return {
|
|
256
256
|
seriesName: column.displayName,
|
|
257
|
-
points: createStackedXPoints(column.
|
|
257
|
+
points: createStackedXPoints(column.dataRows),
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
|
|
@@ -262,7 +262,7 @@ export class MarimekkoChartState implements ChartState, ColorScaleManager {
|
|
|
262
262
|
const { colorColumn, colorScale, uniqueEntityNames } = this
|
|
263
263
|
const hasColorColumn = !colorColumn.isMissing
|
|
264
264
|
const colorRowsByEntity = hasColorColumn
|
|
265
|
-
? colorColumn.
|
|
265
|
+
? colorColumn.dataRowsByEntityName
|
|
266
266
|
: undefined
|
|
267
267
|
const domainColorMap = new Map<string, EntityColorData>()
|
|
268
268
|
if (uniqueEntityNames !== undefined) {
|
|
@@ -30,7 +30,7 @@ export class StackedBarChartState
|
|
|
30
30
|
|
|
31
31
|
@computed
|
|
32
32
|
get unstackedSeriesWithMissingValuesAsZeroes(): StackedSeries<number>[] {
|
|
33
|
-
// TODO: remove once monthly data is supported (
|
|
33
|
+
// TODO: remove once monthly data is supported (# legacy issue 2007)
|
|
34
34
|
const enforceUniformSpacing = !(
|
|
35
35
|
this.transformedTable.timeColumn instanceof ColumnTypeMap.Day
|
|
36
36
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Color,
|
|
3
3
|
EntityName,
|
|
4
|
-
|
|
4
|
+
VariableRow,
|
|
5
5
|
SeriesName,
|
|
6
6
|
} from "../../types/index.js"
|
|
7
7
|
import { ChartSeries } from "../chart/ChartInterface"
|
|
@@ -80,7 +80,7 @@ export interface StackedRawSeries<
|
|
|
80
80
|
> {
|
|
81
81
|
seriesName: SeriesName
|
|
82
82
|
isProjection?: boolean
|
|
83
|
-
rows:
|
|
83
|
+
rows: VariableRow<PositionType>[]
|
|
84
84
|
focus: InteractionState
|
|
85
85
|
shortEntityName?: string
|
|
86
86
|
}
|