diff --git a/adminSiteClient/ChartList.tsx b/adminSiteClient/ChartList.tsx index f93cc6ee216..2bf5889ba9f 100644 --- a/adminSiteClient/ChartList.tsx +++ b/adminSiteClient/ChartList.tsx @@ -3,7 +3,11 @@ import { observer } from "mobx-react" import { runInAction, observable } from "mobx" import { bind } from "decko" import { AdminAppContext, AdminAppContextType } from "./AdminAppContext.js" -import { ChartTypeName, GrapherInterface } from "@ourworldindata/types" +import { + ChartTypeName, + GrapherInterface, + GrapherTabOption, +} from "@ourworldindata/types" import { startCase, DbChartTagJoin } from "@ourworldindata/utils" import { References, getFullReferencesCount } from "./ChartEditor.js" import { ChartRow } from "./ChartRow.js" @@ -14,13 +18,14 @@ export interface ChartListItem { id: GrapherInterface["id"] title: GrapherInterface["title"] slug: GrapherInterface["slug"] - type: GrapherInterface["type"] internalNotes: GrapherInterface["internalNotes"] variantName: GrapherInterface["variantName"] isPublished: GrapherInterface["isPublished"] tab: GrapherInterface["tab"] - hasChartTab: GrapherInterface["hasChartTab"] - hasMapTab: GrapherInterface["hasMapTab"] + + type: ChartTypeName + hasChartTab: boolean + hasMapTab: boolean lastEditedAt: string lastEditedBy: string @@ -148,7 +153,7 @@ export function showChartType(chart: ChartListItem): string { ? startCase(ChartTypeName[chartType]) : "Unknown" - if (chart.tab === "map") { + if (chart.tab === GrapherTabOption.WorldMap) { if (chart.hasChartTab) return `Map + ${displayType}` else return "Map" } else { diff --git a/adminSiteClient/EditorBasicTab.tsx b/adminSiteClient/EditorBasicTab.tsx index d8dc2e3f9ac..cb09fea7be1 100644 --- a/adminSiteClient/EditorBasicTab.tsx +++ b/adminSiteClient/EditorBasicTab.tsx @@ -11,6 +11,7 @@ import { observer } from "mobx-react" import { ChartTypeName, EntitySelectionMode, + GrapherTabOption, StackMode, } from "@ourworldindata/types" import { @@ -18,6 +19,8 @@ import { WorldEntityName, CONTINENTS_INDICATOR_ID, POPULATION_INDICATOR_ID_USED_IN_ADMIN, + allChartTypes, + allChartTypesDisabled, } from "@ourworldindata/grapher" import { DimensionProperty, @@ -147,7 +150,10 @@ class DimensionSlotView< () => this.grapher.isReady, () => { this.disposers.push( - reaction(() => this.grapher.type, this.updateDefaults), + reaction( + () => this.grapher.availableTabs, + this.updateDefaults + ), reaction( () => this.grapher.yColumnsFromDimensions.length, this.updateDefaults @@ -355,16 +361,20 @@ export class EditorBasicTab< @action.bound onChartTypeChange(value: string) { const { grapher } = this.props.editor - // if availableTabs is a list, remove all but map - // if a record, set all but map to false - if (value === ChartTypeName.LineChart) { - // remove all charts from list - // add line – if slope toggle, add slope - } else { - // remove all charts from list - // add the one given + + const newChartType = value as ChartTypeName + grapher.availableTabs = { + ...grapher.availableTabs, + ...allChartTypesDisabled, + [newChartType]: true, + } + + if ( + grapher.tab !== GrapherTabOption.Table && + grapher.tab !== GrapherTabOption.WorldMap + ) { + grapher.tab = newChartType as unknown as GrapherTabOption } - grapher.type = value as ChartTypeName if (grapher.isMarimekko) { grapher.hideRelativeToggle = false @@ -404,9 +414,6 @@ export class EditorBasicTab< render() { const { editor } = this.props const { grapher } = editor - const chartTypes = Object.keys(ChartTypeName).filter( - (chartType) => chartType !== ChartTypeName.WorldMap - ) const isIndicatorChart = isIndicatorChartEditorInstance(editor) @@ -416,9 +423,9 @@ export class EditorBasicTab<
({ + options={allChartTypes.map((key) => ({ value: key, label: startCase(key), }))} @@ -427,12 +434,30 @@ export class EditorBasicTab< (grapher.hasChartTab = value)} + onValue={(value) => { + // TODO: remove false? + if (value) { + grapher.availableTabs = + grapher.availableTabs ?? {} + grapher.availableTabs[ + ChartTypeName.LineChart + ] = true + } else { + grapher.availableTabs = { + ...grapher.availableTabs, + ...allChartTypesDisabled, + } + } + }} /> (grapher.hasMapTab = value)} + onValue={(value) => { + grapher.availableTabs = + grapher.availableTabs ?? {} + grapher.availableTabs.WorldMap = value + }} />
diff --git a/adminSiteClient/EditorCustomizeTab.tsx b/adminSiteClient/EditorCustomizeTab.tsx index ae3cdf5bedc..6a01665b595 100644 --- a/adminSiteClient/EditorCustomizeTab.tsx +++ b/adminSiteClient/EditorCustomizeTab.tsx @@ -158,7 +158,7 @@ export class ColorSchemeSelector extends React.Component<{ value={grapher.baseColorScheme} onChange={this.onChange} onBlur={this.onBlur} - chartType={this.props.grapher.type} + chartType={this.props.grapher.chartType} invertedColorScheme={!!grapher.invertColorScheme} additionalOptions={[ { @@ -751,7 +751,7 @@ export class EditorCustomizeTab< {grapher.chartInstanceExceptMap.colorScale && ( /** * Migrate the legacy `selectedData` and get rid of it. diff --git a/db/model/Chart.ts b/db/model/Chart.ts index 1f44e590f12..59270da853c 100644 --- a/db/model/Chart.ts +++ b/db/model/Chart.ts @@ -526,12 +526,12 @@ export const oldChartFieldList = ` charts.id, chart_configs.full->>"$.title" AS title, chart_configs.full->>"$.slug" AS slug, - chart_configs.full->>"$.type" AS type, + chart_configs.chartType AS type, chart_configs.full->>"$.internalNotes" AS internalNotes, chart_configs.full->>"$.variantName" AS variantName, chart_configs.full->>"$.tab" AS tab, - JSON_EXTRACT(chart_configs.full, "$.hasChartTab") = true AS hasChartTab, - JSON_EXTRACT(chart_configs.full, "$.hasMapTab") = true AS hasMapTab, + chart_configs.chartType IS NOT NULL AS hasChartTab, + JSON_EXTRACT(chart_configs.full, "$.availableTabs.WorldMap") = true AS hasMapTab, JSON_EXTRACT(chart_configs.full, "$.isPublished") = true AS isPublished, charts.lastEditedAt, charts.lastEditedByUserId, diff --git a/db/model/Gdoc/GdocBase.ts b/db/model/Gdoc/GdocBase.ts index 4dfacfe69f0..9c7933d6090 100644 --- a/db/model/Gdoc/GdocBase.ts +++ b/db/model/Gdoc/GdocBase.ts @@ -934,7 +934,7 @@ export async function makeGrapherLinkedChart( const resolvedSlug = config.slug ?? "" const resolvedTitle = config.title ?? "" const resolvedUrl = `${BAKED_GRAPHER_URL}/${resolvedSlug}` - const tab = config.tab ?? GrapherTabOption.chart + const tab = config.tab const datapageIndicator = await getVariableOfDatapageIfApplicable(config) return { configType: ChartConfigType.Grapher, diff --git a/devTools/svgTester/utils.ts b/devTools/svgTester/utils.ts index a094edb2765..906bd9b2cfe 100644 --- a/devTools/svgTester/utils.ts +++ b/devTools/svgTester/utils.ts @@ -426,7 +426,7 @@ export async function renderSvg( const svgRecord = { chartId: configAndData.config.id!, slug: configAndData.config.slug!, - chartType: grapher.tab === "chart" ? grapher.type : grapher.tab, + chartType: grapher.currentTab, queryStr, md5: processSvgAndCalculateHash(svg), svgFilename: outFilename, diff --git a/packages/@ourworldindata/explorer/src/Explorer.jsdom.test.tsx b/packages/@ourworldindata/explorer/src/Explorer.jsdom.test.tsx index 1b6a6410138..12dc74f5766 100755 --- a/packages/@ourworldindata/explorer/src/Explorer.jsdom.test.tsx +++ b/packages/@ourworldindata/explorer/src/Explorer.jsdom.test.tsx @@ -49,7 +49,7 @@ describe(Explorer, () => { explorer.onChangeChoice("Gas")("All GHGs (CO₂eq)") - expect(explorer.grapher.tab).toEqual("chart") + expect(explorer.grapher.tab).toEqual(GrapherTabOption.LineChart) expect(explorer.queryParams.tab).toEqual(undefined) }) diff --git a/packages/@ourworldindata/explorer/src/Explorer.tsx b/packages/@ourworldindata/explorer/src/Explorer.tsx index 94885434ec6..60863e1417d 100644 --- a/packages/@ourworldindata/explorer/src/Explorer.tsx +++ b/packages/@ourworldindata/explorer/src/Explorer.tsx @@ -593,6 +593,7 @@ export class Explorer const partialGrapherConfig = this.partialGrapherConfigsByVariableId.get(yVariableIdsList[0]) ?? {} + console.log(partialGrapherConfig) const config: GrapherProgrammaticInterface = { ...mergeGrapherConfigs( diff --git a/packages/@ourworldindata/explorer/src/ExplorerProgram.ts b/packages/@ourworldindata/explorer/src/ExplorerProgram.ts index e8f289462b1..400519a3c9a 100644 --- a/packages/@ourworldindata/explorer/src/ExplorerProgram.ts +++ b/packages/@ourworldindata/explorer/src/ExplorerProgram.ts @@ -8,6 +8,7 @@ import { FacetAxisDomain, GrapherInterface, AxisMinMaxValueStr, + ChartTypeName, } from "@ourworldindata/types" import { CoreTable, @@ -64,6 +65,10 @@ interface ExplorerGrapherInterface extends GrapherInterface { relatedQuestionText?: string relatedQuestionUrl?: string mapTargetTime?: number + + type?: ChartTypeName + hasChartTab?: boolean + hasMapTab?: boolean } const ExplorerRootDef: CellDef = { @@ -379,6 +384,9 @@ export class ExplorerProgram extends GridProgram { if (!GrapherGrammar[key]) delete config[key] }) + // assume a line chart if no type is specified + if (!config.type) config.type = ChartTypeName.LineChart + return config } diff --git a/packages/@ourworldindata/explorer/src/GrapherGrammar.ts b/packages/@ourworldindata/explorer/src/GrapherGrammar.ts index 5e235502b53..10aebe48313 100644 --- a/packages/@ourworldindata/explorer/src/GrapherGrammar.ts +++ b/packages/@ourworldindata/explorer/src/GrapherGrammar.ts @@ -24,6 +24,7 @@ import { IndicatorIdOrEtlPathCellDef, GrapherCellDef, } from "./gridLang/GridLangConstants.js" +import { allChartTypesDisabled } from "@ourworldindata/grapher" const toTerminalOptions = (keywords: string[]): CellDef[] => { return keywords.map((keyword) => ({ @@ -65,7 +66,7 @@ export const GrapherGrammar: Grammar = { keyword: "type", description: `The type of chart to show such as LineChart or ScatterPlot.`, terminalOptions: toTerminalOptions(Object.values(ChartTypeName)), - toGrapherObject: (value) => ({ type: value }), + toGrapherObject: (value) => ({ availableTabs: { [value]: true } }), }, grapherId: { ...IntegerCellDef, @@ -84,7 +85,9 @@ export const GrapherGrammar: Grammar = { ...BooleanCellDef, keyword: "hasMapTab", description: "Show the map tab?", - toGrapherObject: (value) => ({ hasMapTab: value }), + toGrapherObject: (value) => ({ + availableTabs: { [ChartTypeName.WorldMap]: value }, + }), }, tab: { ...EnumCellDef, @@ -97,7 +100,8 @@ export const GrapherGrammar: Grammar = { ...BooleanCellDef, keyword: "hasChartTab", description: "Show the chart tab?", - toGrapherObject: (value) => ({ hasChartTab: value }), + // overwrites the given chart type if provided + toGrapherObject: (value) => ({ availableTabs: allChartTypesDisabled }), }, xSlug: { ...SlugDeclarationCellDef, diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.jsdom.test.ts b/packages/@ourworldindata/grapher/src/core/Grapher.jsdom.test.ts index d13069e5b3e..6e0a3e7850a 100755 --- a/packages/@ourworldindata/grapher/src/core/Grapher.jsdom.test.ts +++ b/packages/@ourworldindata/grapher/src/core/Grapher.jsdom.test.ts @@ -10,6 +10,7 @@ import { GrapherQueryParams, LegacyGrapherInterface, LegacyGrapherQueryParams, + ChartTypeNameRecord, } from "@ourworldindata/types" import { TimeBoundValue, @@ -44,6 +45,7 @@ const TestGrapherConfig = (): { property: DimensionProperty variableId: any }[] + availableTabs: ChartTypeNameRecord } => { const table = SynthesizeGDPTable({ entityCount: 10 }) return { @@ -56,6 +58,7 @@ const TestGrapherConfig = (): { variableId: SampleColumnSlugs.GDP as any, }, ], + availableTabs: { [ChartTypeName.LineChart]: true }, } } @@ -71,7 +74,7 @@ it("can get dimension slots", () => { const grapher = new Grapher() expect(grapher.dimensionSlots.length).toBe(2) - grapher.type = ChartTypeName.ScatterPlot + grapher.availableTabs[ChartTypeName.ScatterPlot] = true expect(grapher.dimensionSlots.length).toBe(4) }) @@ -86,7 +89,7 @@ it("an empty Grapher serializes to an object that includes only the schema", () it("a bad chart type does not crash grapher", () => { const input = { - type: "fff" as any, + availableTabs: { fff: true } as any, } expect(new Grapher(input).toObject()).toEqual({ ...input, @@ -214,25 +217,25 @@ it("can generate a url with country selection even if there is no entity code", describe("hasTimeline", () => { it("charts with timeline", () => { const grapher = new Grapher(legacyConfig) - grapher.availableTabs = [GrapherTabOption.LineChart] + grapher.availableTabs = { [GrapherTabOption.LineChart]: true } expect(grapher.hasTimeline).toBeTruthy() - grapher.availableTabs = [GrapherTabOption.SlopeChart] + grapher.availableTabs = { [GrapherTabOption.SlopeChart]: true } expect(grapher.hasTimeline).toBeTruthy() - grapher.availableTabs = [GrapherTabOption.StackedArea] + grapher.availableTabs = { [GrapherTabOption.StackedArea]: true } expect(grapher.hasTimeline).toBeTruthy() - grapher.availableTabs = [GrapherTabOption.StackedBar] + grapher.availableTabs = { [GrapherTabOption.StackedBar]: true } expect(grapher.hasTimeline).toBeTruthy() - grapher.availableTabs = [GrapherTabOption.DiscreteBar] + grapher.availableTabs = { [GrapherTabOption.DiscreteBar]: true } expect(grapher.hasTimeline).toBeTruthy() }) it("map tab has timeline even if chart doesn't", () => { const grapher = new Grapher(legacyConfig) grapher.hideTimeline = true - grapher.availableTabs = [ - GrapherTabOption.WorldMap, - GrapherTabOption.LineChart, - ] + grapher.availableTabs = { + [GrapherTabOption.WorldMap]: true, + [GrapherTabOption.LineChart]: true, + } expect(grapher.hasTimeline).toBeFalsy() grapher.tab = GrapherTabOption.WorldMap expect(grapher.hasTimeline).toBeTruthy() @@ -385,7 +388,7 @@ describe("authors can use maxTime", () => { const table = SynthesizeGDPTable({ timeRange: [2000, 2010] }) const grapher = new Grapher({ table, - type: ChartTypeName.DiscreteBar, + availableTabs: { [ChartTypeName.DiscreteBar]: true }, selectedEntityNames: table.availableEntityNames, maxTime: 2005, ySlugs: "GDP", @@ -924,7 +927,7 @@ it("correctly identifies activeColumnSlugs", () => { `) const grapher = new Grapher({ table, - type: ChartTypeName.ScatterPlot, + availableTabs: { [ChartTypeName.ScatterPlot]: true }, xSlug: "gdp", ySlugs: "child_mortality", colorSlug: "continent", @@ -961,7 +964,9 @@ it("considers map tolerance before using column tolerance", () => { const grapher = new Grapher({ table, - availableTabs: [GrapherTabOption.Table, GrapherTabOption.WorldMap], + availableTabs: { + [GrapherTabOption.WorldMap]: true, + }, ySlugs: "gdp", tab: GrapherTabOption.WorldMap, map: new MapConfig({ timeTolerance: 1, columnSlug: "gdp", time: 2002 }), @@ -1022,7 +1027,7 @@ describe("tableForSelection", () => { const grapher = new Grapher({ table, - type: ChartTypeName.ScatterPlot, + availableTabs: { [ChartTypeName.ScatterPlot]: true }, excludedEntities: [3], xSlug: "x", ySlugs: "y", @@ -1058,7 +1063,7 @@ it("handles tolerance when there are gaps in ScatterPlot data", () => { const grapher = new Grapher({ table, - type: ChartTypeName.ScatterPlot, + availableTabs: { [ChartTypeName.ScatterPlot]: true }, xSlug: "x", ySlugs: "y", minTime: 1999, diff --git a/packages/@ourworldindata/grapher/src/core/Grapher.tsx b/packages/@ourworldindata/grapher/src/core/Grapher.tsx index d76b3938343..7e3bea5f546 100644 --- a/packages/@ourworldindata/grapher/src/core/Grapher.tsx +++ b/packages/@ourworldindata/grapher/src/core/Grapher.tsx @@ -364,7 +364,7 @@ export class Grapher @observable.ref internalNotes?: string = undefined @observable.ref originUrl?: string = undefined - @observable availableTabs?: ChartTypeNameRecord + @observable availableTabs: ChartTypeNameRecord = {} @observable.ref tab?: GrapherTabOption @observable hideAnnotationFieldsInTitle?: AnnotationFieldsInTitle = @@ -757,6 +757,10 @@ export class Grapher return this.chartTypes[0] } + @computed get chartType(): ChartTypeName { + return this.firstChartType ?? ChartTypeName.LineChart + } + @computed get currentChartType(): ChartTypeName | undefined { if (!this.isOnChartTab) return undefined return this.currentTab as unknown as ChartTypeName @@ -3163,7 +3167,7 @@ export class Grapher @action.bound clearQueryParams(): void { const { authorsVersion } = this - this.tab = authorsVersion.tab // TODO + this.tab = authorsVersion.tab this.xAxis.scaleType = authorsVersion.xAxis.scaleType this.yAxis.scaleType = authorsVersion.yAxis.scaleType this.stackMode = authorsVersion.stackMode diff --git a/packages/@ourworldindata/grapher/src/core/GrapherConstants.ts b/packages/@ourworldindata/grapher/src/core/GrapherConstants.ts index 4d20a0d213b..b8d4cedae7c 100644 --- a/packages/@ourworldindata/grapher/src/core/GrapherConstants.ts +++ b/packages/@ourworldindata/grapher/src/core/GrapherConstants.ts @@ -97,3 +97,7 @@ export const grapherInterfaceWithHiddenControlsOnly: GrapherProgrammaticInterfac export const allChartTypes = Object.values(ChartTypeName).filter( (type) => type !== ChartTypeName.WorldMap ) + +export const allChartTypesDisabled = Object.fromEntries( + allChartTypes.map((chartType) => [chartType, false]) +) diff --git a/packages/@ourworldindata/grapher/src/core/GrapherWithChartTypes.jsdom.test.tsx b/packages/@ourworldindata/grapher/src/core/GrapherWithChartTypes.jsdom.test.tsx index b82ca6f925e..b1624d98adc 100755 --- a/packages/@ourworldindata/grapher/src/core/GrapherWithChartTypes.jsdom.test.tsx +++ b/packages/@ourworldindata/grapher/src/core/GrapherWithChartTypes.jsdom.test.tsx @@ -50,7 +50,7 @@ const basicGrapherConfig: GrapherProgrammaticInterface = { describe("grapher and discrete bar charts", () => { const grapher = new Grapher({ - type: ChartTypeName.DiscreteBar, + availableTabs: { [ChartTypeName.DiscreteBar]: true }, ...basicGrapherConfig, }) expect(grapher.chartInstance.series.length).toBeGreaterThan(0) diff --git a/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.test.ts b/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.test.ts index 29c8fcf6302..438844935aa 100755 --- a/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.test.ts +++ b/packages/@ourworldindata/grapher/src/core/LegacyToOwidTable.test.ts @@ -466,7 +466,7 @@ describe(legacyToOwidTableAndDimensions, () => { it("joins targetTime", () => { const scatterLegacyGrapherConfig = { ...legacyGrapherConfig, - type: ChartTypeName.ScatterPlot, + availableTabs: { [ChartTypeName.ScatterPlot]: true }, } const { table } = legacyToOwidTableAndDimensions( diff --git a/packages/@ourworldindata/grapher/src/dataTable/DataTable.jsdom.test.tsx b/packages/@ourworldindata/grapher/src/dataTable/DataTable.jsdom.test.tsx index 94383bce657..44a5b6d1ccd 100755 --- a/packages/@ourworldindata/grapher/src/dataTable/DataTable.jsdom.test.tsx +++ b/packages/@ourworldindata/grapher/src/dataTable/DataTable.jsdom.test.tsx @@ -70,7 +70,7 @@ describe("when you select a range of years", () => { let view: ReactWrapper beforeAll(() => { const grapher = childMortalityGrapher({ - availableTabs: [GrapherTabOption.Table, GrapherTabOption.LineChart], + availableTabs: { [GrapherTabOption.LineChart]: true }, tab: GrapherTabOption.Table, }) grapher.timelineHandleTimeBounds = [1950, 2019] @@ -158,7 +158,7 @@ describe("when the table has no filter toggle", () => { const grapher = LifeExpectancyGrapher({ selectedEntityNames: ["World"], hideEntityControls: true, // no filter toggle - hasMapTab: true, + availableTabs: { [ChartTypeName.WorldMap]: true }, }) const view = Enzyme.mount() const rows = view.find("tbody tr:not(.title)") @@ -169,7 +169,6 @@ describe("when the table has no filter toggle", () => { const grapher = LifeExpectancyGrapher({ selectedEntityNames: [], hideEntityControls: true, // no filter toggle - hasMapTab: false, }) const view = Enzyme.mount() const rows = view.find("tbody tr:not(.title)") diff --git a/packages/@ourworldindata/grapher/src/dataTable/DataTable.sample.ts b/packages/@ourworldindata/grapher/src/dataTable/DataTable.sample.ts index eae6d20e645..30fda027687 100644 --- a/packages/@ourworldindata/grapher/src/dataTable/DataTable.sample.ts +++ b/packages/@ourworldindata/grapher/src/dataTable/DataTable.sample.ts @@ -37,7 +37,6 @@ export const childMortalityGrapher = ( }, ] return new Grapher({ - hasMapTab: true, tab: GrapherTabOption.WorldMap, dimensions, ...props, diff --git a/packages/@ourworldindata/grapher/src/index.ts b/packages/@ourworldindata/grapher/src/index.ts index aac3525f4e7..78ae041ace4 100644 --- a/packages/@ourworldindata/grapher/src/index.ts +++ b/packages/@ourworldindata/grapher/src/index.ts @@ -25,6 +25,8 @@ export { grapherInterfaceWithHiddenControlsOnly, CONTINENTS_INDICATOR_ID, POPULATION_INDICATOR_ID_USED_IN_ADMIN, + allChartTypes, + allChartTypesDisabled, } from "./core/GrapherConstants" export { getVariableDataRoute, diff --git a/packages/@ourworldindata/grapher/src/mapCharts/MapChart.sample.ts b/packages/@ourworldindata/grapher/src/mapCharts/MapChart.sample.ts index 946d5d3e83c..ddb64819867 100644 --- a/packages/@ourworldindata/grapher/src/mapCharts/MapChart.sample.ts +++ b/packages/@ourworldindata/grapher/src/mapCharts/MapChart.sample.ts @@ -1,10 +1,10 @@ import { DimensionProperty } from "@ourworldindata/utils" import { GrapherProgrammaticInterface } from "../core/Grapher" -import { GrapherTabOption } from "@ourworldindata/types" +import { ChartTypeName, GrapherTabOption } from "@ourworldindata/types" // TODO: rewrite export const legacyMapGrapher: GrapherProgrammaticInterface = { - hasMapTab: true, + availableTabs: { [ChartTypeName.WorldMap]: true }, tab: GrapherTabOption.WorldMap, map: { timeTolerance: 5, diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.jsdom.test.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.jsdom.test.tsx index c4650faccd6..e41ae68f44c 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.jsdom.test.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/MarimekkoChart.jsdom.test.tsx @@ -3,8 +3,8 @@ import { Bounds, ColumnTypeNames } from "@ourworldindata/utils" import { OwidTable } from "@ourworldindata/core-table" import { DefaultColorScheme } from "../color/CustomSchemes" -import { Grapher } from "../core/Grapher" -import { ChartTypeName } from "@ourworldindata/types" +import { Grapher, GrapherProgrammaticInterface } from "../core/Grapher" +import { ChartTypeName, GrapherInterface } from "@ourworldindata/types" import { MarimekkoChart } from "./MarimekkoChart" import { BarShape, PlacedItem } from "./MarimekkoChartConstants" it("can filter years correctly", () => { @@ -23,7 +23,7 @@ it("can filter years correctly", () => { // TODO: why is it ySlugs and xSlug here instead of yColumnSlugs and xColumnSlug? Unify when we have config migrations? const manager = { - type: ChartTypeName.Marimekko, + availableTabs: { [ChartTypeName.Marimekko]: true }, table, selection: table.availableEntityNames, ySlugs: "percentBelow2USD", @@ -133,7 +133,7 @@ it("shows no data points at the end", () => { // TODO: why is it ySlugs and xSlug here instead of yColumnSlugs and xColumnSlug? Unify when we have config migrations? const manager = { - type: ChartTypeName.Marimekko, + availableTabs: { [ChartTypeName.Marimekko]: true }, table, selection: table.availableEntityNames, ySlugs: "percentBelow2USD", @@ -233,7 +233,7 @@ test("interpolation works as expected", () => { // TODO: why is it ySlugs and xSlug here instead of yColumnSlugs and xColumnSlug? Unify when we have config migrations? const manager = { - type: ChartTypeName.Marimekko, + availableTabs: { [ChartTypeName.Marimekko]: true }, table, selection: table.availableEntityNames, ySlugs: "percentBelow2USD", @@ -344,7 +344,7 @@ it("can deal with y columns with missing values", () => { // TODO: why is it ySlugs and xSlug here instead of yColumnSlugs and xColumnSlug? Unify when we have config migrations? const manager = { - type: ChartTypeName.Marimekko, + availableTabs: { [ChartTypeName.Marimekko]: true }, table, selection: table.availableEntityNames, ySlugs: "percentBelow2USD percentBelow10USD",