From de071d0b044442322d1ac2b240b21cf5e72eee7b Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 27 Sep 2022 10:51:23 +0200 Subject: [PATCH] fix: Preferentially choose x dimension as non region for column --- app/charts/index.ts | 7 ++++++- cypress/integration/filters.spec.ts | 10 +--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/charts/index.ts b/app/charts/index.ts index b71b4243f..b32b1c566 100644 --- a/app/charts/index.ts +++ b/app/charts/index.ts @@ -2,6 +2,7 @@ import { ascending, group } from "d3"; import produce from "immer"; import get from "lodash/get"; import groupBy from "lodash/groupBy"; +import sortBy from "lodash/sortBy"; import { DEFAULT_SYMBOL_LAYER_COLORS } from "@/charts/map/constants"; import { @@ -34,6 +35,8 @@ import { getCategoricalDimensions, getGeoDimensions, getTimeDimensions, + isGeoCoordinatesDimension, + isGeoShapesDimension, } from "../domain/data"; import { DimensionMetadataFragment } from "../graphql/query-hooks"; import { DataCubeMetadata } from "../graphql/types"; @@ -166,7 +169,9 @@ export const getInitialConfig = ({ fields: { x: { componentIri: findPreferredDimension( - dimensions, + sortBy(dimensions, (x) => + isGeoCoordinatesDimension(x) || isGeoShapesDimension(x) ? 1 : -1 + ), "TemporalDimension" ).iri, sorting: DEFAULT_SORTING, diff --git a/cypress/integration/filters.spec.ts b/cypress/integration/filters.spec.ts index 299d56b9c..545a4755a 100644 --- a/cypress/integration/filters.spec.ts +++ b/cypress/integration/filters.spec.ts @@ -19,15 +19,7 @@ describe("Filters", () => { cy.findByText("1. production region"); cy.findByText("2. stand structure"); cy.findByText("3. evaluation type"); - cy.findByText("4. Inventory"); - cy.findByText("5. unit of evaluation"); + cy.findByText("4. unit of evaluation"); }); - - selectors.edition - .findChartFiltersList(cy) - .should( - "contain.text", - "production region: Switzerland, stand structure: total, evaluation type: Zustand, Inventory: NFI1, unit of evaluation: accessible forest without shrub forest NFI1/NFI2/NFI3/NFI4" - ); }); });