diff --git a/app/charts/index.ts b/app/charts/index.ts index b9370de60..96f0c177a 100644 --- a/app/charts/index.ts +++ b/app/charts/index.ts @@ -278,9 +278,10 @@ export const getInitialConfig = ({ componentIri: geoShapes[0]?.iri || "", measureIri: measures[0].iri, hierarchyLevel: 1, + colorScaleType: "continuous", + colorScaleInterpolationType: "linear", palette: "oranges", nbClass: 5, - paletteType: "continuous", }, symbolLayer: { show: geoShapes.length === 0, diff --git a/app/charts/map/map-legend.tsx b/app/charts/map/map-legend.tsx index 7544e71c2..279011762 100644 --- a/app/charts/map/map-legend.tsx +++ b/app/charts/map/map-legend.tsx @@ -1,6 +1,5 @@ import { axisBottom, - interpolateOranges, NumberValue, range, ScaleLinear, @@ -14,6 +13,7 @@ import { import * as React from "react"; import { useEffect, useMemo, useRef } from "react"; import { Box, Flex, Text } from "theme-ui"; +import { ColorRamp } from "../../configurator/components/chart-controls/color-ramp"; import { getColorInterpolator, useFormatInteger, @@ -92,10 +92,18 @@ export const MapLegend = () => { {areaLayer.measureLabel} )} - {areaLayer.paletteType === "continuous" && } - {areaLayer.paletteType === "discrete" && } - {areaLayer.paletteType === "quantile" && } - {areaLayer.paletteType === "jenks" && } + {areaLayer.colorScaleInterpolationType === "linear" && ( + + )} + {areaLayer.colorScaleInterpolationType === "quantize" && ( + + )} + {areaLayer.colorScaleInterpolationType === "quantile" && ( + + )} + {areaLayer.colorScaleInterpolationType === "jenks" && ( + + )} )} @@ -509,7 +517,7 @@ const ContinuousColorLegend = () => { width={width - MARGIN.left - MARGIN.right} height={COLOR_RAMP_HEIGHT} colorInterpolator={getColorInterpolator(palette)} - nbClass={width} + nbClass={width - MARGIN.left - MARGIN.right} /> ); }; - -const ColorRamp = ({ - colorInterpolator = interpolateOranges, - nbClass, - width, - height, -}: { - colorInterpolator: (t: number) => string; - nbClass: number; - width: number; - height: number; -}) => { - const canvasRef = useRef(null); - - useEffect(() => { - const canvas = canvasRef.current; - const context = canvas && canvas.getContext("2d"); - - if (canvas && context) { - context.clearRect(0, 0, width, height); - canvas.style.imageRendering = "-moz-crisp-edges"; - canvas.style.imageRendering = "pixelated"; - - for (let i = 0; i < nbClass; ++i) { - context.fillStyle = colorInterpolator(i / (nbClass - 1)); - context.fillRect(i, 0, 1, height); - } - } - }); - - return ; -}; diff --git a/app/charts/map/map-state.tsx b/app/charts/map/map-state.tsx index 257398a64..f8daf6281 100644 --- a/app/charts/map/map-state.tsx +++ b/app/charts/map/map-state.tsx @@ -22,8 +22,10 @@ import { } from "../../configurator/components/ui-helpers"; import { BaseLayer, + ColorScaleInterpolationType, + DivergingPaletteType, MapFields, - PaletteType, + SequentialPaletteType, } from "../../configurator/config-types"; import { GeoData, @@ -61,8 +63,8 @@ export interface MapState { | ScaleQuantile | ScaleLinear | ScaleThreshold; - paletteType: PaletteType; - palette: string; + colorScaleInterpolationType: ColorScaleInterpolationType; + palette: DivergingPaletteType | SequentialPaletteType; nbClass: number; dataDomain: [number, number]; }; @@ -80,36 +82,38 @@ export interface MapState { } const getColorScale = ({ - paletteType, + scaleInterpolationType, palette, getValue, data, dataDomain, nbClass, }: { - paletteType: PaletteType; - palette: string; + scaleInterpolationType: ColorScaleInterpolationType; + palette: DivergingPaletteType | SequentialPaletteType; getValue: (x: Observation) => number | null; data: Observation[]; dataDomain: [number, number]; nbClass: number; }) => { - const paletteDomain = getSingleHueSequentialPalette({ - palette, - nbClass: 9, - }); + const interpolator = getColorInterpolator(palette); + const getDiscreteRange = () => { + return Array.from({ length: nbClass }, (_, i) => + interpolator(i / (nbClass - 1)) + ); + }; - switch (paletteType) { - case "continuous": - return scaleSequential(getColorInterpolator(palette)).domain(dataDomain); - case "discrete": + switch (scaleInterpolationType) { + case "linear": + return scaleSequential(interpolator).domain(dataDomain); + case "quantize": return scaleQuantize() .domain(dataDomain) - .range(getSingleHueSequentialPalette({ palette, nbClass })); + .range(getDiscreteRange()); case "quantile": return scaleQuantile() .domain(data.map((d) => getValue(d))) - .range(getSingleHueSequentialPalette({ palette, nbClass })); + .range(getDiscreteRange()); case "jenks": const ckMeansThresholds = ckmeans( data.map((d) => getValue(d) ?? NaN), @@ -118,8 +122,13 @@ const getColorScale = ({ return scaleThreshold() .domain(ckMeansThresholds) - .range(getSingleHueSequentialPalette({ palette, nbClass })); + .range(getDiscreteRange()); default: + const paletteDomain = getSingleHueSequentialPalette({ + palette, + nbClass: 9, + }); + return scaleLinear() .domain(dataDomain) .range([paletteDomain[0], paletteDomain[paletteDomain.length - 1]]); @@ -140,7 +149,6 @@ const useMapState = ({ }): MapState => { const width = useWidth(); const { areaLayer, symbolLayer } = fields; - const { palette, nbClass, paletteType } = areaLayer; const getAreaLabel = useStringVariable(areaLayer.componentIri); const getSymbolLabel = useStringVariable(symbolLayer.componentIri); @@ -227,12 +235,12 @@ const useMapState = ({ ]) as [number, number]; const areaColorScale = getColorScale({ - paletteType, - palette, + scaleInterpolationType: areaLayer.colorScaleInterpolationType, + palette: areaLayer.palette, getValue: getAreaValue, data: areaData, dataDomain: areaDataDomain, - nbClass, + nbClass: areaLayer.nbClass, }); const getAreaColor = (v: number | null) => { @@ -279,9 +287,9 @@ const useMapState = ({ getValue: getAreaValue, getColor: getAreaColor, colorScale: areaColorScale, - paletteType, - palette, - nbClass: nbClass, + colorScaleInterpolationType: areaLayer.colorScaleInterpolationType, + palette: areaLayer.palette, + nbClass: areaLayer.nbClass, dataDomain: areaDataDomain, }, symbolLayer: { diff --git a/app/configurator/components/chart-controls/color-palette.tsx b/app/configurator/components/chart-controls/color-palette.tsx index bf9b8dae8..1854c067f 100644 --- a/app/configurator/components/chart-controls/color-palette.tsx +++ b/app/configurator/components/chart-controls/color-palette.tsx @@ -1,18 +1,18 @@ import { Trans } from "@lingui/macro"; -import { Box, Button, Flex, Text } from "theme-ui"; import { useSelect } from "downshift"; import get from "lodash/get"; import { useCallback } from "react"; +import { Box, Button, Flex, Text } from "theme-ui"; import { ConfiguratorStateConfiguringChart, useConfiguratorState } from "../.."; import { Label } from "../../../components/form"; +import { DimensionMetaDataFragment } from "../../../graphql/query-hooks"; +import { Icon } from "../../../icons"; import { categoricalPalettes, + divergingSteppedPalettes, getPalette, mapColorsToComponentValuesIris, - sequentialPalettes, } from "../ui-helpers"; -import { DimensionMetaDataFragment } from "../../../graphql/query-hooks"; -import { Icon } from "../../../icons"; type Props = { field: string; @@ -31,7 +31,7 @@ export const ColorPalette = ({ const palettes = component?.__typename === "Measure" - ? sequentialPalettes + ? divergingSteppedPalettes : categoricalPalettes; const currentPaletteName = get( @@ -73,34 +73,14 @@ export const ColorPalette = ({ }); return ( - + + + {isOpen && ( + <> + + Diverging + + {divergingPalettes.map((d, i) => ( + + ))} + + + Sequential + + {sequentialPalettes.map((d, i) => ( + + ))} + + )} + + + ); +}; + +const PaletteRamp = (props: { + palette: { + label: string; + value: DivergingPaletteType | SequentialPaletteType; + interpolator: (t: number) => string; + }; + itemProps: any; + highlighted?: boolean; + nbClass?: number; +}) => { + const { palette, itemProps, highlighted, nbClass } = props; + const backgroundColor = highlighted ? "monochrome200" : "monochrome100"; + + return ( + + + + + + ); }; diff --git a/app/configurator/components/ui-helpers.ts b/app/configurator/components/ui-helpers.ts index b92d0559d..757502d72 100644 --- a/app/configurator/components/ui-helpers.ts +++ b/app/configurator/components/ui-helpers.ts @@ -17,6 +17,7 @@ import { scaleOrdinal, schemeAccent, schemeBlues, + schemeBrBG, schemeCategory10, schemeDark2, schemeGreens, @@ -25,6 +26,8 @@ import { schemePaired, schemePastel1, schemePastel2, + schemePiYG, + schemePuOr, schemePurples, schemeReds, schemeSet1, @@ -49,7 +52,12 @@ import { getD3TimeFormatLocale, } from "../../locales/locales"; import { useLocale } from "../../locales/use-locale"; -import { TableColumn, TableFields } from "../config-types"; +import { + DivergingPaletteType, + SequentialPaletteType, + TableColumn, + TableFields, +} from "../config-types"; // FIXME: We should cover more time format const parseSecond = timeParse("%Y-%m-%dT%H:%M:%S"); @@ -644,6 +652,7 @@ export function getFieldLabel(field: string): string { } } +// Colors export const getPalette = (palette?: string): ReadonlyArray => { switch (palette) { case "accent": @@ -671,33 +680,65 @@ export const getPalette = (palette?: string): ReadonlyArray => { return schemeCategory10; } }; + export const getSingleHueSequentialPalette = ({ nbClass = 5, palette, }: { nbClass: number; - palette?: string; + palette?: DivergingPaletteType | SequentialPaletteType; }): ReadonlyArray => { switch (palette) { + case "BrBG": + return schemeBrBG[nbClass]; + case "PRGn": + return schemePiYG[nbClass]; + case "PiYG": + return schemePiYG[nbClass]; + case "PuOr": + return schemePuOr[nbClass]; case "blues": return schemeBlues[nbClass]; case "greens": return schemeGreens[nbClass]; - case "oranges": - return schemeOranges[nbClass]; case "greys": return schemeGreys[nbClass]; - case "reds": - return schemeReds[nbClass]; + case "oranges": + return schemeOranges[nbClass]; case "purples": return schemePurples[nbClass]; + case "reds": + return schemeReds[nbClass]; default: return schemeOranges[nbClass]; } }; + +export const categoricalPalettes: Array<{ + label: string; + value: string; + colors: ReadonlyArray; +}> = [ + { + label: "category10", + value: "category10", + colors: getPalette("category10"), + }, + { label: "accent", value: "accent", colors: getPalette("accent") }, + { label: "dark2", value: "dark2", colors: getPalette("dark2") }, + { label: "paired", value: "paired", colors: getPalette("paired") }, + { label: "pastel1", value: "pastel1", colors: getPalette("pastel1") }, + { label: "pastel2", value: "pastel2", colors: getPalette("pastel2") }, + { label: "set1", value: "set1", colors: getPalette("set1") }, + { label: "set2", value: "set2", colors: getPalette("set2") }, + { label: "set3", value: "set3", colors: getPalette("set3") }, +]; + +export const getDefaultCategoricalPalette = () => categoricalPalettes[0]; + export const getColorInterpolator = ( - palette?: string + palette?: SequentialPaletteType | DivergingPaletteType ): ((t: number) => string) => { switch (palette) { case "BrBG": @@ -726,60 +767,60 @@ export const getColorInterpolator = ( } }; -export const categoricalPalettes: Array<{ +type Palette = { label: string; - value: string; - colors: ReadonlyArray; -}> = [ - { - label: "category10", - value: "category10", - colors: getPalette("category10"), - }, - { label: "accent", value: "accent", colors: getPalette("accent") }, - { label: "dark2", value: "dark2", colors: getPalette("dark2") }, - { label: "paired", value: "paired", colors: getPalette("paired") }, - { label: "pastel1", value: "pastel1", colors: getPalette("pastel1") }, - { label: "pastel2", value: "pastel2", colors: getPalette("pastel2") }, - { label: "set1", value: "set1", colors: getPalette("set1") }, - { label: "set2", value: "set2", colors: getPalette("set2") }, - { label: "set3", value: "set3", colors: getPalette("set3") }, -]; - -export const getDefaultCategoricalPalette = () => categoricalPalettes[0]; + value: T; + interpolator: (t: number) => string; +}; -const sequentialPaletteSteps = [ - 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, -]; -// Diverging color palettes -export const sequentialPalettes: Array<{ - label: string; - value: string; +type SteppedPalette = Omit, "interpolator"> & { colors: ReadonlyArray; -}> = [ - { - label: "BrBG", - value: "BrBG", - colors: sequentialPaletteSteps.map((d) => getColorInterpolator("BrBG")(d)), - }, - { - label: "PRGn", - value: "PRGn", - colors: sequentialPaletteSteps.map((d) => getColorInterpolator("PRGn")(d)), - }, - { - label: "PiYG", - value: "PiYG", - colors: sequentialPaletteSteps.map((d) => getColorInterpolator("PiYG")(d)), - }, - { - label: "PuOr", - value: "PuOr", - colors: sequentialPaletteSteps.map((d) => getColorInterpolator("PuOr")(d)), - }, -]; +}; -export const getDefaultSequentialPalette = () => sequentialPalettes[0]; +const steppedPaletteSteps = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]; + +const divergingPaletteKeys = [ + "BrBG", + "PRGn", + "PiYG", + "PuOr", +] as DivergingPaletteType[]; + +export const divergingPalettes = divergingPaletteKeys.map((d) => ({ + label: d, + value: d, + interpolator: getColorInterpolator(d), +})) as Palette[]; + +export const divergingSteppedPalettes = divergingPaletteKeys.map((d) => ({ + label: d, + value: d, + colors: steppedPaletteSteps.map((s) => getColorInterpolator(d)(s)), +})) as SteppedPalette[]; + +export const getDefaultDivergingSteppedPalette = () => + divergingSteppedPalettes[0]; + +const sequentialPaletteKeys = [ + "blues", + "greens", + "greys", + "oranges", + "purples", + "reds", +] as SequentialPaletteType[]; + +export const sequentialPalettes = sequentialPaletteKeys.map((d) => ({ + label: d, + value: d, + interpolator: getColorInterpolator(d), +})) as Palette[]; + +export const sequentialSteppedPalettes = sequentialPaletteKeys.map((d) => ({ + label: d, + value: d, + colors: steppedPaletteSteps.map((s) => getColorInterpolator(d)(s)), +})) as SteppedPalette[]; export const mapColorsToComponentValuesIris = ({ palette, diff --git a/app/configurator/config-types.ts b/app/configurator/config-types.ts index 67b0eda49..f53bebeb0 100644 --- a/app/configurator/config-types.ts +++ b/app/configurator/config-types.ts @@ -359,6 +359,42 @@ const PieConfig = t.type( export type PieFields = t.TypeOf; export type PieConfig = t.TypeOf; +const DivergingPaletteType = t.union([ + t.literal("BrBG"), + t.literal("PRGn"), + t.literal("PiYG"), + t.literal("PuOr"), +]); + +export type DivergingPaletteType = t.TypeOf; + +const SequentialPaletteType = t.union([ + t.literal("blues"), + t.literal("greens"), + t.literal("greys"), + t.literal("oranges"), + t.literal("purples"), + t.literal("reds"), +]); + +export type SequentialPaletteType = t.TypeOf; + +const ColorScaleType = t.union([ + t.literal("continuous"), + t.literal("discrete"), +]); +export type ColorScaleType = t.TypeOf; + +const ColorScaleInterpolationType = t.union([ + t.literal("linear"), + t.literal("quantize"), + t.literal("quantile"), + t.literal("jenks"), +]); +export type ColorScaleInterpolationType = t.TypeOf< + typeof ColorScaleInterpolationType +>; + const ColumnTextStyle = t.union([t.literal("regular"), t.literal("bold")]); const ColumnStyleText = t.type({ @@ -376,7 +412,7 @@ const ColumnStyleCategory = t.type({ const ColumnStyleHeatmap = t.type({ type: t.literal("heatmap"), textStyle: ColumnTextStyle, - palette: t.string, + palette: DivergingPaletteType, }); const ColumnStyleBar = t.type({ type: t.literal("bar"), @@ -436,24 +472,30 @@ const TableConfig = t.type( export type TableFields = t.TypeOf; export type TableConfig = t.TypeOf; -// FIXME: These MapFields types are only placeholders for the map prototype -const PaletteType = t.union([ - t.literal("continuous"), - t.literal("discrete"), - t.literal("quantile"), - t.literal("jenks"), +const MapAreaLayer = t.intersection([ + t.type({ + componentIri: t.string, + measureIri: t.string, + hierarchyLevel: t.number, + show: t.boolean, + palette: t.union([DivergingPaletteType, SequentialPaletteType]), + nbClass: t.number, + }), + t.union([ + t.type({ + colorScaleType: t.literal("continuous"), + colorScaleInterpolationType: t.literal("linear"), + }), + t.type({ + colorScaleType: t.literal("discrete"), + colorScaleInterpolationType: t.union([ + t.literal("quantize"), + t.literal("quantile"), + t.literal("jenks"), + ]), + }), + ]), ]); -export type PaletteType = t.TypeOf; - -const MapAreaLayer = t.type({ - componentIri: t.string, - measureIri: t.string, - hierarchyLevel: t.number, - show: t.boolean, - palette: t.string, - paletteType: PaletteType, - nbClass: t.number, -}); export type MapAreaLayer = t.TypeOf; const MapSymbolLayer = t.type({ diff --git a/app/configurator/configurator-state.tsx b/app/configurator/configurator-state.tsx index 251e05484..628338f17 100644 --- a/app/configurator/configurator-state.tsx +++ b/app/configurator/configurator-state.tsx @@ -15,6 +15,7 @@ import { ImputationType, isAreaConfig, isColumnConfig, + isMapConfig, isSegmentInConfig, } from "."; import { fetchChartConfig, saveChartConfig } from "../api"; @@ -736,7 +737,22 @@ const reducer: Reducer = ( action.value.value, Object ); + + if ( + isMapConfig(draft.chartConfig) && + action.value.field === "areaLayer" && + action.value.path === "colorScaleType" + ) { + const path = `chartConfig.fields.areaLayer.colorScaleInterpolationType`; + + if (action.value.value === "continuous") { + setWith(draft, path, "linear", Object); + } else if (action.value.value === "discrete") { + setWith(draft, path, "jenks", Object); + } + } } + return draft; case "CHART_PALETTE_CHANGED": diff --git a/app/configurator/map/map-chart-options.tsx b/app/configurator/map/map-chart-options.tsx index d2425d774..3b1c5b18b 100644 --- a/app/configurator/map/map-chart-options.tsx +++ b/app/configurator/map/map-chart-options.tsx @@ -1,5 +1,6 @@ import { t, Trans } from "@lingui/macro"; import React, { memo, useMemo } from "react"; +import { Flex } from "theme-ui"; import { ConfiguratorStateConfiguringChart, MapConfig } from ".."; import { FieldSetLegend } from "../../components/form"; import { @@ -9,6 +10,7 @@ import { } from "../../domain/data"; import { GeoShapesDimension } from "../../graphql/query-hooks"; import { DataCubeMetadata } from "../../graphql/types"; +import { ColorRampField } from "../components/chart-controls/color-ramp"; import { ControlSection, ControlSectionContent, @@ -21,14 +23,6 @@ import { ColorPickerField, } from "../components/field"; -const NUMBER_OF_CLASSES_OPTIONS = Array.from( - { length: 7 }, - (_, i) => i + 3 -).map((d) => ({ - value: d, - label: `${d}`, -})); - export const MapColumnOptions = ({ state, metaData, @@ -44,16 +38,11 @@ export const MapColumnOptions = ({ return ; case "areaLayer": return ( - + ); case "symbolLayer": return ( @@ -93,14 +82,13 @@ export const BaseLayersSettings = memo(() => { export const AreaLayerSettings = memo( ({ - activeField, chartConfig, metaData, }: { - activeField: string; chartConfig: MapConfig; metaData: DataCubeMetadata; }) => { + const activeField = "areaLayer"; const geoShapesDimensions = useMemo( () => getGeoShapesDimensions(metaData.dimensions), [metaData.dimensions] @@ -139,6 +127,25 @@ export const AreaLayerSettings = memo( [metaData.measures] ); + const numberOfGeoShapes = ( + dimension + ? dimension.geoShapes.topology.objects.shapes.geometries.length + : 0 + ) as number; + + const numberOfColorScaleClasses = useMemo( + () => + Array.from( + { length: Math.min(7, Math.max(0, numberOfGeoShapes - 2)) }, + (_, i) => i + 3 + ).map((d) => ({ value: d, label: `${d}` })), + [numberOfGeoShapes] + ); + + const currentNumberOfColorScaleClasses = + chartConfig.fields.areaLayer.nbClass; + const currentColorScaleType = chartConfig.fields.areaLayer.colorScaleType; + const disabled = !chartConfig.fields.areaLayer.show; return ( @@ -171,7 +178,7 @@ export const AreaLayerSettings = memo( path="componentIri" options={geoShapesDimensionsOptions} disabled={disabled} - > + /> @@ -185,7 +192,7 @@ export const AreaLayerSettings = memo( options={hierarchyLevelOptions} getValue={(d) => +d} disabled={disabled} - > + /> @@ -198,70 +205,90 @@ export const AreaLayerSettings = memo( path="measureIri" options={measuresOptions} disabled={disabled} - > + /> Color scale - + + + + {/* Limit the number of clusters to min. 3 */} + {numberOfGeoShapes >= 3 && ( + + )} + + + ({ - value: d, - label: d, - }))} + nbClass={ + currentColorScaleType === "discrete" + ? currentNumberOfColorScaleClasses + : undefined + } disabled={disabled} - > - - - - - - - - - + /> + + {chartConfig.fields.areaLayer.colorScaleType === "discrete" && + numberOfGeoShapes >= 3 && ( + <> + + + + id="areaLayer.nbClass" + label="Number of classes" + field={activeField} + path="nbClass" + options={numberOfColorScaleClasses} + disabled={disabled} + getValue={(d) => +d} + /> + + )} @@ -271,14 +298,13 @@ export const AreaLayerSettings = memo( export const SymbolLayerSettings = memo( ({ - activeField, chartConfig, metaData, }: { - activeField: string; chartConfig: MapConfig; metaData: DataCubeMetadata; }) => { + const activeField = "symbolLayer"; const geoDimensions = useMemo( () => getGeoDimensions(metaData.dimensions), [metaData.dimensions] @@ -333,7 +359,7 @@ export const SymbolLayerSettings = memo( path="componentIri" options={geoDimensionsOptions} disabled={disabled} - > + /> @@ -346,7 +372,7 @@ export const SymbolLayerSettings = memo( path="measureIri" options={measuresOptions} disabled={disabled} - > + /> @@ -357,7 +383,7 @@ export const SymbolLayerSettings = memo( field={activeField} path="color" disabled={disabled} - > + /> diff --git a/app/configurator/table/table-chart-options.tsx b/app/configurator/table/table-chart-options.tsx index f410daee7..1d9d44867 100644 --- a/app/configurator/table/table-chart-options.tsx +++ b/app/configurator/table/table-chart-options.tsx @@ -23,7 +23,7 @@ import { } from "../components/filters"; import { getDefaultCategoricalPalette, - getDefaultSequentialPalette, + getDefaultDivergingSteppedPalette, getIconName, mapColorsToComponentValuesIris, } from "../components/ui-helpers"; @@ -264,7 +264,7 @@ export const TableColumnOptions = ({ return { type: "heatmap", textStyle: "regular", - palette: getDefaultSequentialPalette().value, + palette: getDefaultDivergingSteppedPalette().value, }; case "bar": return { diff --git a/app/docs/color-ramp.docs.tsx b/app/docs/color-ramp.docs.tsx new file mode 100644 index 000000000..14000b69a --- /dev/null +++ b/app/docs/color-ramp.docs.tsx @@ -0,0 +1,78 @@ +import { markdown } from "catalog"; +import { interpolateBrBG, interpolateOranges } from "d3-scale-chromatic"; +import { Box } from "theme-ui"; +import { ColorRamp } from "../configurator/components/chart-controls/color-ramp"; + +export default () => + markdown` +> is able to display all values from a color interpolator (currently suited to the ones from D3). + +## How to use + +~~~ +import { ColorRamp } from "./components/chart-controls/color-ramp" + + +~~~ + +### Continuous + +~~~ + +~~~ + +${( + + + +)} + +### Discrete + +~~~ + +~~~ + +${( + + + +)} + +### Custom width and height + +~~~ + +~~~ + +${( + + + +)} + +### Disabled + +~~~ + +~~~ + +${( + + + +)} + +## ColorRampField + +> is a custom select element which can be used to display and select several palette categories. You need to use it inside of so it can access and update the state. + +~~~ + +~~~ +`; diff --git a/app/docs/fixtures.ts b/app/docs/fixtures.ts index 71677d8de..933411db5 100644 --- a/app/docs/fixtures.ts +++ b/app/docs/fixtures.ts @@ -930,7 +930,7 @@ export const tableConfig: TableConfig = { componentType: "Measure", columnStyle: { type: "heatmap", - palette: "oranges", + palette: "BrBG", textStyle: "regular", }, }, @@ -985,7 +985,7 @@ export const tableConfig: TableConfig = { isGroup: false, isHidden: false, componentType: "Measure", - columnStyle: { type: "heatmap", palette: "turbo", textStyle: "regular" }, + columnStyle: { type: "heatmap", palette: "PRGn", textStyle: "regular" }, }, "http://environment.ld.admin.ch/foen/px/0703010000_105/measure/6": { componentIri: @@ -997,7 +997,7 @@ export const tableConfig: TableConfig = { columnStyle: { type: "heatmap", textStyle: "regular", - palette: "cividis", + palette: "PiYG", }, }, "http://environment.ld.admin.ch/foen/px/0703010000_105/measure/7": { diff --git a/app/locales/de/messages.po b/app/locales/de/messages.po index 9486858ff..7f784f815 100644 --- a/app/locales/de/messages.po +++ b/app/locales/de/messages.po @@ -231,55 +231,55 @@ msgstr "Normal" msgid "controls..interactiveFilters.time.defaultSettings" msgstr "Standardeinstellung" -#: app/configurator/components/ui-helpers.ts:379 +#: app/configurator/components/ui-helpers.ts:387 msgid "controls.axis.horizontal" msgstr "Horizontale Achse" -#: app/configurator/components/ui-helpers.ts:387 +#: app/configurator/components/ui-helpers.ts:395 msgid "controls.axis.vertical" msgstr "Vertikale Achse" -#: app/configurator/map/map-chart-options.tsx:82 +#: app/configurator/map/map-chart-options.tsx:76 msgid "controls.baseLayer.showLakes" msgstr "" -#: app/configurator/map/map-chart-options.tsx:74 +#: app/configurator/map/map-chart-options.tsx:68 msgid "controls.baseLayer.showRelief" msgstr "" -#: app/configurator/components/ui-helpers.ts:481 +#: app/configurator/components/ui-helpers.ts:489 msgid "controls.chart.type.area" msgstr "Flächen" -#: app/configurator/components/ui-helpers.ts:473 +#: app/configurator/components/ui-helpers.ts:481 msgid "controls.chart.type.bar" msgstr "Balken" -#: app/configurator/components/ui-helpers.ts:469 +#: app/configurator/components/ui-helpers.ts:477 msgid "controls.chart.type.column" msgstr "Säulen" -#: app/configurator/components/ui-helpers.ts:477 +#: app/configurator/components/ui-helpers.ts:485 msgid "controls.chart.type.line" msgstr "Linien" -#: app/configurator/components/ui-helpers.ts:497 +#: app/configurator/components/ui-helpers.ts:505 msgid "controls.chart.type.map" msgstr "Karte" -#: app/configurator/components/ui-helpers.ts:489 +#: app/configurator/components/ui-helpers.ts:497 msgid "controls.chart.type.pie" msgstr "Kreis" -#: app/configurator/components/ui-helpers.ts:485 +#: app/configurator/components/ui-helpers.ts:493 msgid "controls.chart.type.scatterplot" msgstr "Scatterplot" -#: app/configurator/components/ui-helpers.ts:493 +#: app/configurator/components/ui-helpers.ts:501 msgid "controls.chart.type.table" msgstr "Tabelle" -#: app/configurator/components/ui-helpers.ts:391 +#: app/configurator/components/ui-helpers.ts:399 msgid "controls.color" msgstr "Farbe" @@ -288,27 +288,36 @@ msgid "controls.color.add" msgstr "Hinzufügen …" #: app/configurator/components/chart-controls/color-palette.tsx:78 +#: app/configurator/components/chart-controls/color-ramp.tsx:106 msgid "controls.color.palette" msgstr "Farbpalette" +#: app/configurator/components/chart-controls/color-ramp.tsx:147 +msgid "controls.color.palette.diverging" +msgstr "Divergierend" + #: app/configurator/components/chart-controls/color-palette.tsx:257 #: app/configurator/components/chart-controls/color-palette.tsx:263 msgid "controls.color.palette.reset" msgstr "Farbpalette zurücksetzen" +#: app/configurator/components/chart-controls/color-ramp.tsx:161 +msgid "controls.color.palette.sequential" +msgstr "Sequentiell" + #: app/configurator/components/chart-controls/color-picker.tsx:158 msgid "controls.colorpicker.open" msgstr "Farbauswahl öffnen" -#: app/configurator/components/ui-helpers.ts:401 +#: app/configurator/components/ui-helpers.ts:409 msgid "controls.column.grouped" msgstr "gruppiert" -#: app/configurator/components/ui-helpers.ts:397 +#: app/configurator/components/ui-helpers.ts:405 msgid "controls.column.stacked" msgstr "gestapelt" -#: app/configurator/components/ui-helpers.ts:393 +#: app/configurator/components/ui-helpers.ts:401 msgid "controls.description" msgstr "Beschreibung hinzufügen" @@ -347,7 +356,7 @@ msgstr "Bitte eine Designoption oder Datendimension auswählen, um diese zu bear msgid "controls.hint.describing.chart" msgstr "Bitte ein Beschreibungsfeld auswählen, um dieses zu bearbeiten." -#: app/configurator/components/ui-helpers.ts:453 +#: app/configurator/components/ui-helpers.ts:461 msgid "controls.imputation" msgstr "Imputationstyp" @@ -387,36 +396,36 @@ msgstr "Keine Zeitdimension verfügbar!" msgid "controls.interactiveFilters.time.toggleTimeFilter" msgstr "Zeitfilter anzeigen" -#: app/configurator/components/ui-helpers.ts:501 +#: app/configurator/components/ui-helpers.ts:509 msgid "controls.language.english" msgstr "Englisch" -#: app/configurator/components/ui-helpers.ts:509 +#: app/configurator/components/ui-helpers.ts:517 msgid "controls.language.french" msgstr "Französisch" -#: app/configurator/components/ui-helpers.ts:505 +#: app/configurator/components/ui-helpers.ts:513 msgid "controls.language.german" msgstr "Deutsch" -#: app/configurator/components/ui-helpers.ts:513 +#: app/configurator/components/ui-helpers.ts:521 msgid "controls.language.italian" msgstr "Italienisch" -#: app/configurator/components/ui-helpers.ts:409 +#: app/configurator/components/ui-helpers.ts:417 msgid "controls.map.areaLayer" msgstr "" #: app/configurator/components/chart-options-selector.tsx:176 -#: app/configurator/components/ui-helpers.ts:405 +#: app/configurator/components/ui-helpers.ts:413 msgid "controls.map.baseLayer" msgstr "" -#: app/configurator/components/ui-helpers.ts:413 +#: app/configurator/components/ui-helpers.ts:421 msgid "controls.map.symbolLayer" msgstr "" -#: app/configurator/components/ui-helpers.ts:383 +#: app/configurator/components/ui-helpers.ts:391 msgid "controls.measure" msgstr "Messwert" @@ -432,11 +441,11 @@ msgstr "Aus" msgid "controls.search.clear" msgstr "Suche zurücksetzen" -#: app/configurator/map/map-chart-options.tsx:148 +#: app/configurator/map/map-chart-options.tsx:158 msgid "controls.section.areaLayer" msgstr "" -#: app/configurator/map/map-chart-options.tsx:70 +#: app/configurator/map/map-chart-options.tsx:64 msgid "controls.section.baseLayer" msgstr "" @@ -493,7 +502,7 @@ msgstr "Datenfilter" msgid "controls.section.sorting" msgstr "Sortieren" -#: app/configurator/map/map-chart-options.tsx:310 +#: app/configurator/map/map-chart-options.tsx:329 msgid "controls.section.symbolLayer" msgstr "" @@ -581,11 +590,11 @@ msgstr "Dimension hinzufügen" msgid "controls.sorting.byDimensionLabel" msgstr "Name" -#: app/configurator/components/ui-helpers.ts:421 +#: app/configurator/components/ui-helpers.ts:429 msgid "controls.sorting.byDimensionLabel.ascending" msgstr "A → Z" -#: app/configurator/components/ui-helpers.ts:425 +#: app/configurator/components/ui-helpers.ts:433 msgid "controls.sorting.byDimensionLabel.descending" msgstr "Z → A" @@ -593,11 +602,11 @@ msgstr "Z → A" msgid "controls.sorting.byMeasure" msgstr "Messwert" -#: app/configurator/components/ui-helpers.ts:445 +#: app/configurator/components/ui-helpers.ts:453 msgid "controls.sorting.byMeasure.ascending" msgstr "1 → 9" -#: app/configurator/components/ui-helpers.ts:449 +#: app/configurator/components/ui-helpers.ts:457 msgid "controls.sorting.byMeasure.descending" msgstr "9 → 1" @@ -605,19 +614,19 @@ msgstr "9 → 1" msgid "controls.sorting.byTotalSize" msgstr "Gesamtgrösse" -#: app/configurator/components/ui-helpers.ts:429 +#: app/configurator/components/ui-helpers.ts:437 msgid "controls.sorting.byTotalSize.ascending" msgstr "Kleinste zuerst" -#: app/configurator/components/ui-helpers.ts:441 +#: app/configurator/components/ui-helpers.ts:449 msgid "controls.sorting.byTotalSize.largestBottom" msgstr "Grösste unten" -#: app/configurator/components/ui-helpers.ts:433 +#: app/configurator/components/ui-helpers.ts:441 msgid "controls.sorting.byTotalSize.largestFirst" msgstr "Grösste zuerst" -#: app/configurator/components/ui-helpers.ts:437 +#: app/configurator/components/ui-helpers.ts:445 msgid "controls.sorting.byTotalSize.largestTop" msgstr "Kleinste unten" @@ -629,7 +638,7 @@ msgstr "Sortierung entfernen" msgid "controls.sorting.selectDimension" msgstr "Wählen Sie eine Dimension aus …" -#: app/configurator/components/ui-helpers.ts:417 +#: app/configurator/components/ui-helpers.ts:425 #: app/configurator/table/table-chart-sorting-options.tsx:305 msgid "controls.sorting.sortBy" msgstr "Sortieren nach" @@ -654,7 +663,7 @@ msgstr "Sortierung" msgid "controls.tableSettings.showSearch" msgstr "Suche anzeigen" -#: app/configurator/components/ui-helpers.ts:392 +#: app/configurator/components/ui-helpers.ts:400 msgid "controls.title" msgstr "Titel hinzufügen" @@ -736,11 +745,11 @@ msgstr "Luftzug" msgid "datatable.showing.first.rows" msgstr "Die ersten 10 Zeilen werden angezeigt" -#: app/configurator/map/map-chart-options.tsx:152 +#: app/configurator/map/map-chart-options.tsx:162 msgid "fields.areaLayer.show" msgstr "" -#: app/configurator/map/map-chart-options.tsx:314 +#: app/configurator/map/map-chart-options.tsx:333 msgid "fields.symbolLayer.show" msgstr "" diff --git a/app/locales/en/messages.po b/app/locales/en/messages.po index f300040ff..5dc3ceefd 100644 --- a/app/locales/en/messages.po +++ b/app/locales/en/messages.po @@ -231,55 +231,55 @@ msgstr "Regular" msgid "controls..interactiveFilters.time.defaultSettings" msgstr "Default Settings" -#: app/configurator/components/ui-helpers.ts:379 +#: app/configurator/components/ui-helpers.ts:387 msgid "controls.axis.horizontal" msgstr "Horizontal Axis" -#: app/configurator/components/ui-helpers.ts:387 +#: app/configurator/components/ui-helpers.ts:395 msgid "controls.axis.vertical" msgstr "Vertical Axis" -#: app/configurator/map/map-chart-options.tsx:82 +#: app/configurator/map/map-chart-options.tsx:76 msgid "controls.baseLayer.showLakes" msgstr "Show lakes" -#: app/configurator/map/map-chart-options.tsx:74 +#: app/configurator/map/map-chart-options.tsx:68 msgid "controls.baseLayer.showRelief" msgstr "Show relief" -#: app/configurator/components/ui-helpers.ts:481 +#: app/configurator/components/ui-helpers.ts:489 msgid "controls.chart.type.area" msgstr "Areas" -#: app/configurator/components/ui-helpers.ts:473 +#: app/configurator/components/ui-helpers.ts:481 msgid "controls.chart.type.bar" msgstr "Bars" -#: app/configurator/components/ui-helpers.ts:469 +#: app/configurator/components/ui-helpers.ts:477 msgid "controls.chart.type.column" msgstr "Columns" -#: app/configurator/components/ui-helpers.ts:477 +#: app/configurator/components/ui-helpers.ts:485 msgid "controls.chart.type.line" msgstr "Lines" -#: app/configurator/components/ui-helpers.ts:497 +#: app/configurator/components/ui-helpers.ts:505 msgid "controls.chart.type.map" msgstr "Map" -#: app/configurator/components/ui-helpers.ts:489 +#: app/configurator/components/ui-helpers.ts:497 msgid "controls.chart.type.pie" msgstr "Pie" -#: app/configurator/components/ui-helpers.ts:485 +#: app/configurator/components/ui-helpers.ts:493 msgid "controls.chart.type.scatterplot" msgstr "Scatterplot" -#: app/configurator/components/ui-helpers.ts:493 +#: app/configurator/components/ui-helpers.ts:501 msgid "controls.chart.type.table" msgstr "Table" -#: app/configurator/components/ui-helpers.ts:391 +#: app/configurator/components/ui-helpers.ts:399 msgid "controls.color" msgstr "Color" @@ -288,27 +288,36 @@ msgid "controls.color.add" msgstr "Add ..." #: app/configurator/components/chart-controls/color-palette.tsx:78 +#: app/configurator/components/chart-controls/color-ramp.tsx:106 msgid "controls.color.palette" msgstr "Color palette" +#: app/configurator/components/chart-controls/color-ramp.tsx:147 +msgid "controls.color.palette.diverging" +msgstr "Diverging" + #: app/configurator/components/chart-controls/color-palette.tsx:257 #: app/configurator/components/chart-controls/color-palette.tsx:263 msgid "controls.color.palette.reset" msgstr "Reset color palette" +#: app/configurator/components/chart-controls/color-ramp.tsx:161 +msgid "controls.color.palette.sequential" +msgstr "Sequential" + #: app/configurator/components/chart-controls/color-picker.tsx:158 msgid "controls.colorpicker.open" msgstr "Open Color Picker" -#: app/configurator/components/ui-helpers.ts:401 +#: app/configurator/components/ui-helpers.ts:409 msgid "controls.column.grouped" msgstr "Grouped" -#: app/configurator/components/ui-helpers.ts:397 +#: app/configurator/components/ui-helpers.ts:405 msgid "controls.column.stacked" msgstr "Stacked" -#: app/configurator/components/ui-helpers.ts:393 +#: app/configurator/components/ui-helpers.ts:401 msgid "controls.description" msgstr "Description" @@ -347,7 +356,7 @@ msgstr "Select a design element or a data dimension to modify its options." msgid "controls.hint.describing.chart" msgstr "Select an annotation field to modify its content." -#: app/configurator/components/ui-helpers.ts:453 +#: app/configurator/components/ui-helpers.ts:461 msgid "controls.imputation" msgstr "Imputation type" @@ -387,36 +396,36 @@ msgstr "There is no time dimension!" msgid "controls.interactiveFilters.time.toggleTimeFilter" msgstr "Show time filter" -#: app/configurator/components/ui-helpers.ts:501 +#: app/configurator/components/ui-helpers.ts:509 msgid "controls.language.english" msgstr "English" -#: app/configurator/components/ui-helpers.ts:509 +#: app/configurator/components/ui-helpers.ts:517 msgid "controls.language.french" msgstr "French" -#: app/configurator/components/ui-helpers.ts:505 +#: app/configurator/components/ui-helpers.ts:513 msgid "controls.language.german" msgstr "German" -#: app/configurator/components/ui-helpers.ts:513 +#: app/configurator/components/ui-helpers.ts:521 msgid "controls.language.italian" msgstr "Italian" -#: app/configurator/components/ui-helpers.ts:409 +#: app/configurator/components/ui-helpers.ts:417 msgid "controls.map.areaLayer" msgstr "Area layer" #: app/configurator/components/chart-options-selector.tsx:176 -#: app/configurator/components/ui-helpers.ts:405 +#: app/configurator/components/ui-helpers.ts:413 msgid "controls.map.baseLayer" msgstr "Base layer" -#: app/configurator/components/ui-helpers.ts:413 +#: app/configurator/components/ui-helpers.ts:421 msgid "controls.map.symbolLayer" msgstr "Symbol layer" -#: app/configurator/components/ui-helpers.ts:383 +#: app/configurator/components/ui-helpers.ts:391 msgid "controls.measure" msgstr "Measure" @@ -432,11 +441,11 @@ msgstr "Off" msgid "controls.search.clear" msgstr "Clear search field" -#: app/configurator/map/map-chart-options.tsx:148 +#: app/configurator/map/map-chart-options.tsx:158 msgid "controls.section.areaLayer" msgstr "Settings" -#: app/configurator/map/map-chart-options.tsx:70 +#: app/configurator/map/map-chart-options.tsx:64 msgid "controls.section.baseLayer" msgstr "Settings" @@ -493,7 +502,7 @@ msgstr "Data Filters" msgid "controls.section.sorting" msgstr "Sort" -#: app/configurator/map/map-chart-options.tsx:310 +#: app/configurator/map/map-chart-options.tsx:329 msgid "controls.section.symbolLayer" msgstr "Settings" @@ -581,11 +590,11 @@ msgstr "Add dimension" msgid "controls.sorting.byDimensionLabel" msgstr "Name" -#: app/configurator/components/ui-helpers.ts:421 +#: app/configurator/components/ui-helpers.ts:429 msgid "controls.sorting.byDimensionLabel.ascending" msgstr "A → Z" -#: app/configurator/components/ui-helpers.ts:425 +#: app/configurator/components/ui-helpers.ts:433 msgid "controls.sorting.byDimensionLabel.descending" msgstr "Z → A" @@ -593,11 +602,11 @@ msgstr "Z → A" msgid "controls.sorting.byMeasure" msgstr "Measure" -#: app/configurator/components/ui-helpers.ts:445 +#: app/configurator/components/ui-helpers.ts:453 msgid "controls.sorting.byMeasure.ascending" msgstr "1 → 9" -#: app/configurator/components/ui-helpers.ts:449 +#: app/configurator/components/ui-helpers.ts:457 msgid "controls.sorting.byMeasure.descending" msgstr "9 → 1" @@ -605,19 +614,19 @@ msgstr "9 → 1" msgid "controls.sorting.byTotalSize" msgstr "Total size" -#: app/configurator/components/ui-helpers.ts:429 +#: app/configurator/components/ui-helpers.ts:437 msgid "controls.sorting.byTotalSize.ascending" msgstr "Largest last" -#: app/configurator/components/ui-helpers.ts:441 +#: app/configurator/components/ui-helpers.ts:449 msgid "controls.sorting.byTotalSize.largestBottom" msgstr "Largest bottom" -#: app/configurator/components/ui-helpers.ts:433 +#: app/configurator/components/ui-helpers.ts:441 msgid "controls.sorting.byTotalSize.largestFirst" msgstr "Largest first" -#: app/configurator/components/ui-helpers.ts:437 +#: app/configurator/components/ui-helpers.ts:445 msgid "controls.sorting.byTotalSize.largestTop" msgstr "Largest top" @@ -629,7 +638,7 @@ msgstr "Remove sorting dimension" msgid "controls.sorting.selectDimension" msgstr "Select a dimension …" -#: app/configurator/components/ui-helpers.ts:417 +#: app/configurator/components/ui-helpers.ts:425 #: app/configurator/table/table-chart-sorting-options.tsx:305 msgid "controls.sorting.sortBy" msgstr "Sort by" @@ -654,7 +663,7 @@ msgstr "Sorting" msgid "controls.tableSettings.showSearch" msgstr "Show search field" -#: app/configurator/components/ui-helpers.ts:392 +#: app/configurator/components/ui-helpers.ts:400 msgid "controls.title" msgstr "Title" @@ -736,11 +745,11 @@ msgstr "Draft" msgid "datatable.showing.first.rows" msgstr "Showing first 10 rows" -#: app/configurator/map/map-chart-options.tsx:152 +#: app/configurator/map/map-chart-options.tsx:162 msgid "fields.areaLayer.show" msgstr "Show layer" -#: app/configurator/map/map-chart-options.tsx:314 +#: app/configurator/map/map-chart-options.tsx:333 msgid "fields.symbolLayer.show" msgstr "Show layer" diff --git a/app/locales/fr/messages.po b/app/locales/fr/messages.po index 8cdf09ad0..960061268 100644 --- a/app/locales/fr/messages.po +++ b/app/locales/fr/messages.po @@ -231,55 +231,55 @@ msgstr "Normal" msgid "controls..interactiveFilters.time.defaultSettings" msgstr "Paramètres d'origine" -#: app/configurator/components/ui-helpers.ts:379 +#: app/configurator/components/ui-helpers.ts:387 msgid "controls.axis.horizontal" msgstr "Axe horizontal" -#: app/configurator/components/ui-helpers.ts:387 +#: app/configurator/components/ui-helpers.ts:395 msgid "controls.axis.vertical" msgstr "Axe vertical" -#: app/configurator/map/map-chart-options.tsx:82 +#: app/configurator/map/map-chart-options.tsx:76 msgid "controls.baseLayer.showLakes" msgstr "" -#: app/configurator/map/map-chart-options.tsx:74 +#: app/configurator/map/map-chart-options.tsx:68 msgid "controls.baseLayer.showRelief" msgstr "" -#: app/configurator/components/ui-helpers.ts:481 +#: app/configurator/components/ui-helpers.ts:489 msgid "controls.chart.type.area" msgstr "Surfaces" -#: app/configurator/components/ui-helpers.ts:473 +#: app/configurator/components/ui-helpers.ts:481 msgid "controls.chart.type.bar" msgstr "Barres" -#: app/configurator/components/ui-helpers.ts:469 +#: app/configurator/components/ui-helpers.ts:477 msgid "controls.chart.type.column" msgstr "Colonnes" -#: app/configurator/components/ui-helpers.ts:477 +#: app/configurator/components/ui-helpers.ts:485 msgid "controls.chart.type.line" msgstr "Lignes" -#: app/configurator/components/ui-helpers.ts:497 +#: app/configurator/components/ui-helpers.ts:505 msgid "controls.chart.type.map" msgstr "Carte" -#: app/configurator/components/ui-helpers.ts:489 +#: app/configurator/components/ui-helpers.ts:497 msgid "controls.chart.type.pie" msgstr "Secteurs" -#: app/configurator/components/ui-helpers.ts:485 +#: app/configurator/components/ui-helpers.ts:493 msgid "controls.chart.type.scatterplot" msgstr "Nuage de points" -#: app/configurator/components/ui-helpers.ts:493 +#: app/configurator/components/ui-helpers.ts:501 msgid "controls.chart.type.table" msgstr "Tableau" -#: app/configurator/components/ui-helpers.ts:391 +#: app/configurator/components/ui-helpers.ts:399 msgid "controls.color" msgstr "Couleur" @@ -288,27 +288,36 @@ msgid "controls.color.add" msgstr "Ajouter…" #: app/configurator/components/chart-controls/color-palette.tsx:78 +#: app/configurator/components/chart-controls/color-ramp.tsx:106 msgid "controls.color.palette" msgstr "Couleurs" +#: app/configurator/components/chart-controls/color-ramp.tsx:147 +msgid "controls.color.palette.diverging" +msgstr "Divergent" + #: app/configurator/components/chart-controls/color-palette.tsx:257 #: app/configurator/components/chart-controls/color-palette.tsx:263 msgid "controls.color.palette.reset" msgstr "Réinitialiser la palette de couleurs" +#: app/configurator/components/chart-controls/color-ramp.tsx:161 +msgid "controls.color.palette.sequential" +msgstr "Séquentielle" + #: app/configurator/components/chart-controls/color-picker.tsx:158 msgid "controls.colorpicker.open" msgstr "Ouvrir la pipette à couleur" -#: app/configurator/components/ui-helpers.ts:401 +#: app/configurator/components/ui-helpers.ts:409 msgid "controls.column.grouped" msgstr "groupées" -#: app/configurator/components/ui-helpers.ts:397 +#: app/configurator/components/ui-helpers.ts:405 msgid "controls.column.stacked" msgstr "empilées" -#: app/configurator/components/ui-helpers.ts:393 +#: app/configurator/components/ui-helpers.ts:401 msgid "controls.description" msgstr "Description" @@ -347,7 +356,7 @@ msgstr "Sélectionnez un élément de design ou une dimension du jeu de données msgid "controls.hint.describing.chart" msgstr "Sélectionnez une des annotations proposées pour la modifier." -#: app/configurator/components/ui-helpers.ts:453 +#: app/configurator/components/ui-helpers.ts:461 msgid "controls.imputation" msgstr "Type d'imputation" @@ -387,36 +396,36 @@ msgstr "Il n'y a pas de dimension temporelle!" msgid "controls.interactiveFilters.time.toggleTimeFilter" msgstr "Afficher le filtre temporel" -#: app/configurator/components/ui-helpers.ts:501 +#: app/configurator/components/ui-helpers.ts:509 msgid "controls.language.english" msgstr "Anglais" -#: app/configurator/components/ui-helpers.ts:509 +#: app/configurator/components/ui-helpers.ts:517 msgid "controls.language.french" msgstr "Français" -#: app/configurator/components/ui-helpers.ts:505 +#: app/configurator/components/ui-helpers.ts:513 msgid "controls.language.german" msgstr "Allemand" -#: app/configurator/components/ui-helpers.ts:513 +#: app/configurator/components/ui-helpers.ts:521 msgid "controls.language.italian" msgstr "Italien" -#: app/configurator/components/ui-helpers.ts:409 +#: app/configurator/components/ui-helpers.ts:417 msgid "controls.map.areaLayer" msgstr "" #: app/configurator/components/chart-options-selector.tsx:176 -#: app/configurator/components/ui-helpers.ts:405 +#: app/configurator/components/ui-helpers.ts:413 msgid "controls.map.baseLayer" msgstr "" -#: app/configurator/components/ui-helpers.ts:413 +#: app/configurator/components/ui-helpers.ts:421 msgid "controls.map.symbolLayer" msgstr "" -#: app/configurator/components/ui-helpers.ts:383 +#: app/configurator/components/ui-helpers.ts:391 msgid "controls.measure" msgstr "Variable mesurée" @@ -432,11 +441,11 @@ msgstr "Inactif" msgid "controls.search.clear" msgstr "Effacer la recherche" -#: app/configurator/map/map-chart-options.tsx:148 +#: app/configurator/map/map-chart-options.tsx:158 msgid "controls.section.areaLayer" msgstr "" -#: app/configurator/map/map-chart-options.tsx:70 +#: app/configurator/map/map-chart-options.tsx:64 msgid "controls.section.baseLayer" msgstr "" @@ -493,7 +502,7 @@ msgstr "Filtres de données" msgid "controls.section.sorting" msgstr "Trier" -#: app/configurator/map/map-chart-options.tsx:310 +#: app/configurator/map/map-chart-options.tsx:329 msgid "controls.section.symbolLayer" msgstr "" @@ -581,11 +590,11 @@ msgstr "Ajouter une dimension" msgid "controls.sorting.byDimensionLabel" msgstr "Nom" -#: app/configurator/components/ui-helpers.ts:421 +#: app/configurator/components/ui-helpers.ts:429 msgid "controls.sorting.byDimensionLabel.ascending" msgstr "A → Z" -#: app/configurator/components/ui-helpers.ts:425 +#: app/configurator/components/ui-helpers.ts:433 msgid "controls.sorting.byDimensionLabel.descending" msgstr "Z → A" @@ -593,11 +602,11 @@ msgstr "Z → A" msgid "controls.sorting.byMeasure" msgstr "Mesure" -#: app/configurator/components/ui-helpers.ts:445 +#: app/configurator/components/ui-helpers.ts:453 msgid "controls.sorting.byMeasure.ascending" msgstr "1 → 9" -#: app/configurator/components/ui-helpers.ts:449 +#: app/configurator/components/ui-helpers.ts:457 msgid "controls.sorting.byMeasure.descending" msgstr "9 → 1" @@ -605,19 +614,19 @@ msgstr "9 → 1" msgid "controls.sorting.byTotalSize" msgstr "Taille totale" -#: app/configurator/components/ui-helpers.ts:429 +#: app/configurator/components/ui-helpers.ts:437 msgid "controls.sorting.byTotalSize.ascending" msgstr "Croissant" -#: app/configurator/components/ui-helpers.ts:441 +#: app/configurator/components/ui-helpers.ts:449 msgid "controls.sorting.byTotalSize.largestBottom" msgstr "Décroissant de bas en haut" -#: app/configurator/components/ui-helpers.ts:433 +#: app/configurator/components/ui-helpers.ts:441 msgid "controls.sorting.byTotalSize.largestFirst" msgstr "Décroissant" -#: app/configurator/components/ui-helpers.ts:437 +#: app/configurator/components/ui-helpers.ts:445 msgid "controls.sorting.byTotalSize.largestTop" msgstr "Décroissant de haut en bas" @@ -629,7 +638,7 @@ msgstr "Supprimer la dimension de tri" msgid "controls.sorting.selectDimension" msgstr "Sélectionner une dimension…" -#: app/configurator/components/ui-helpers.ts:417 +#: app/configurator/components/ui-helpers.ts:425 #: app/configurator/table/table-chart-sorting-options.tsx:305 msgid "controls.sorting.sortBy" msgstr "Trier par" @@ -654,7 +663,7 @@ msgstr "Tri" msgid "controls.tableSettings.showSearch" msgstr "Afficher le champ de recherche" -#: app/configurator/components/ui-helpers.ts:392 +#: app/configurator/components/ui-helpers.ts:400 msgid "controls.title" msgstr "Titre" @@ -736,11 +745,11 @@ msgstr "Brouillon" msgid "datatable.showing.first.rows" msgstr "Seules les 10 premières lignes sont affichées" -#: app/configurator/map/map-chart-options.tsx:152 +#: app/configurator/map/map-chart-options.tsx:162 msgid "fields.areaLayer.show" msgstr "" -#: app/configurator/map/map-chart-options.tsx:314 +#: app/configurator/map/map-chart-options.tsx:333 msgid "fields.symbolLayer.show" msgstr "" diff --git a/app/locales/it/messages.po b/app/locales/it/messages.po index 932970fc2..f9c88f8c2 100644 --- a/app/locales/it/messages.po +++ b/app/locales/it/messages.po @@ -231,55 +231,55 @@ msgstr "Regular" msgid "controls..interactiveFilters.time.defaultSettings" msgstr "Impostazioni predefinite" -#: app/configurator/components/ui-helpers.ts:379 +#: app/configurator/components/ui-helpers.ts:387 msgid "controls.axis.horizontal" msgstr "Asse orizzontale" -#: app/configurator/components/ui-helpers.ts:387 +#: app/configurator/components/ui-helpers.ts:395 msgid "controls.axis.vertical" msgstr "Asse verticale" -#: app/configurator/map/map-chart-options.tsx:82 +#: app/configurator/map/map-chart-options.tsx:76 msgid "controls.baseLayer.showLakes" msgstr "" -#: app/configurator/map/map-chart-options.tsx:74 +#: app/configurator/map/map-chart-options.tsx:68 msgid "controls.baseLayer.showRelief" msgstr "" -#: app/configurator/components/ui-helpers.ts:481 +#: app/configurator/components/ui-helpers.ts:489 msgid "controls.chart.type.area" msgstr "Aree" -#: app/configurator/components/ui-helpers.ts:473 +#: app/configurator/components/ui-helpers.ts:481 msgid "controls.chart.type.bar" msgstr "Barre" -#: app/configurator/components/ui-helpers.ts:469 +#: app/configurator/components/ui-helpers.ts:477 msgid "controls.chart.type.column" msgstr "Colonne" -#: app/configurator/components/ui-helpers.ts:477 +#: app/configurator/components/ui-helpers.ts:485 msgid "controls.chart.type.line" msgstr "Linee" -#: app/configurator/components/ui-helpers.ts:497 +#: app/configurator/components/ui-helpers.ts:505 msgid "controls.chart.type.map" msgstr "Mappa" -#: app/configurator/components/ui-helpers.ts:489 +#: app/configurator/components/ui-helpers.ts:497 msgid "controls.chart.type.pie" msgstr "Torta" -#: app/configurator/components/ui-helpers.ts:485 +#: app/configurator/components/ui-helpers.ts:493 msgid "controls.chart.type.scatterplot" msgstr "Scatterplot" -#: app/configurator/components/ui-helpers.ts:493 +#: app/configurator/components/ui-helpers.ts:501 msgid "controls.chart.type.table" msgstr "Tabella" -#: app/configurator/components/ui-helpers.ts:391 +#: app/configurator/components/ui-helpers.ts:399 msgid "controls.color" msgstr "Colore" @@ -288,27 +288,36 @@ msgid "controls.color.add" msgstr "Aggiungi ..." #: app/configurator/components/chart-controls/color-palette.tsx:78 +#: app/configurator/components/chart-controls/color-ramp.tsx:106 msgid "controls.color.palette" msgstr "Palette di colori" +#: app/configurator/components/chart-controls/color-ramp.tsx:147 +msgid "controls.color.palette.diverging" +msgstr "Divergente" + #: app/configurator/components/chart-controls/color-palette.tsx:257 #: app/configurator/components/chart-controls/color-palette.tsx:263 msgid "controls.color.palette.reset" msgstr "Ripristina la tavolozza dei colori" +#: app/configurator/components/chart-controls/color-ramp.tsx:161 +msgid "controls.color.palette.sequential" +msgstr "Sequenziale" + #: app/configurator/components/chart-controls/color-picker.tsx:158 msgid "controls.colorpicker.open" msgstr "Apri il selettore di colore" -#: app/configurator/components/ui-helpers.ts:401 +#: app/configurator/components/ui-helpers.ts:409 msgid "controls.column.grouped" msgstr "raggruppate" -#: app/configurator/components/ui-helpers.ts:397 +#: app/configurator/components/ui-helpers.ts:405 msgid "controls.column.stacked" msgstr "impilate" -#: app/configurator/components/ui-helpers.ts:393 +#: app/configurator/components/ui-helpers.ts:401 msgid "controls.description" msgstr "Descrizione" @@ -347,7 +356,7 @@ msgstr "Seleziona un elemento di design o una dimensione dei dati per modificarn msgid "controls.hint.describing.chart" msgstr "Seleziona una delle annotazioni proposte per modificarla." -#: app/configurator/components/ui-helpers.ts:453 +#: app/configurator/components/ui-helpers.ts:461 msgid "controls.imputation" msgstr "Tipo di imputazione" @@ -387,36 +396,36 @@ msgstr "Nessuna dimensione temporale disponibile!" msgid "controls.interactiveFilters.time.toggleTimeFilter" msgstr "Mostra i filtri temporali" -#: app/configurator/components/ui-helpers.ts:501 +#: app/configurator/components/ui-helpers.ts:509 msgid "controls.language.english" msgstr "Inglese" -#: app/configurator/components/ui-helpers.ts:509 +#: app/configurator/components/ui-helpers.ts:517 msgid "controls.language.french" msgstr "Francese" -#: app/configurator/components/ui-helpers.ts:505 +#: app/configurator/components/ui-helpers.ts:513 msgid "controls.language.german" msgstr "Tedesco" -#: app/configurator/components/ui-helpers.ts:513 +#: app/configurator/components/ui-helpers.ts:521 msgid "controls.language.italian" msgstr "Italiano" -#: app/configurator/components/ui-helpers.ts:409 +#: app/configurator/components/ui-helpers.ts:417 msgid "controls.map.areaLayer" msgstr "" #: app/configurator/components/chart-options-selector.tsx:176 -#: app/configurator/components/ui-helpers.ts:405 +#: app/configurator/components/ui-helpers.ts:413 msgid "controls.map.baseLayer" msgstr "" -#: app/configurator/components/ui-helpers.ts:413 +#: app/configurator/components/ui-helpers.ts:421 msgid "controls.map.symbolLayer" msgstr "" -#: app/configurator/components/ui-helpers.ts:383 +#: app/configurator/components/ui-helpers.ts:391 msgid "controls.measure" msgstr "Misura" @@ -432,11 +441,11 @@ msgstr "Inattivo" msgid "controls.search.clear" msgstr "Cancella la ricerca" -#: app/configurator/map/map-chart-options.tsx:148 +#: app/configurator/map/map-chart-options.tsx:158 msgid "controls.section.areaLayer" msgstr "" -#: app/configurator/map/map-chart-options.tsx:70 +#: app/configurator/map/map-chart-options.tsx:64 msgid "controls.section.baseLayer" msgstr "" @@ -493,7 +502,7 @@ msgstr "Filtri di dati" msgid "controls.section.sorting" msgstr "Ordina" -#: app/configurator/map/map-chart-options.tsx:310 +#: app/configurator/map/map-chart-options.tsx:329 msgid "controls.section.symbolLayer" msgstr "" @@ -581,11 +590,11 @@ msgstr "Aggiungi una dimensione" msgid "controls.sorting.byDimensionLabel" msgstr "Nome" -#: app/configurator/components/ui-helpers.ts:421 +#: app/configurator/components/ui-helpers.ts:429 msgid "controls.sorting.byDimensionLabel.ascending" msgstr "A → Z" -#: app/configurator/components/ui-helpers.ts:425 +#: app/configurator/components/ui-helpers.ts:433 msgid "controls.sorting.byDimensionLabel.descending" msgstr "Z → A" @@ -593,11 +602,11 @@ msgstr "Z → A" msgid "controls.sorting.byMeasure" msgstr "Misura" -#: app/configurator/components/ui-helpers.ts:445 +#: app/configurator/components/ui-helpers.ts:453 msgid "controls.sorting.byMeasure.ascending" msgstr "1 → 9" -#: app/configurator/components/ui-helpers.ts:449 +#: app/configurator/components/ui-helpers.ts:457 msgid "controls.sorting.byMeasure.descending" msgstr "9 → 1" @@ -605,19 +614,19 @@ msgstr "9 → 1" msgid "controls.sorting.byTotalSize" msgstr "Grandezza totale" -#: app/configurator/components/ui-helpers.ts:429 +#: app/configurator/components/ui-helpers.ts:437 msgid "controls.sorting.byTotalSize.ascending" msgstr "Il più grande per ultimo" -#: app/configurator/components/ui-helpers.ts:441 +#: app/configurator/components/ui-helpers.ts:449 msgid "controls.sorting.byTotalSize.largestBottom" msgstr "Il più grande sotto" -#: app/configurator/components/ui-helpers.ts:433 +#: app/configurator/components/ui-helpers.ts:441 msgid "controls.sorting.byTotalSize.largestFirst" msgstr "Il più grande per primo" -#: app/configurator/components/ui-helpers.ts:437 +#: app/configurator/components/ui-helpers.ts:445 msgid "controls.sorting.byTotalSize.largestTop" msgstr "Il più grande sopra" @@ -629,7 +638,7 @@ msgstr "Rimuovi l'ordinamento" msgid "controls.sorting.selectDimension" msgstr "Seleziona una dimensione ..." -#: app/configurator/components/ui-helpers.ts:417 +#: app/configurator/components/ui-helpers.ts:425 #: app/configurator/table/table-chart-sorting-options.tsx:305 msgid "controls.sorting.sortBy" msgstr "Ordina per" @@ -654,7 +663,7 @@ msgstr "Ordinamento" msgid "controls.tableSettings.showSearch" msgstr "Mostra il campo di ricerca" -#: app/configurator/components/ui-helpers.ts:392 +#: app/configurator/components/ui-helpers.ts:400 msgid "controls.title" msgstr "Titolo" @@ -736,11 +745,11 @@ msgstr "" msgid "datatable.showing.first.rows" msgstr "Sono mostrate soltanto le prime 10 righe" -#: app/configurator/map/map-chart-options.tsx:152 +#: app/configurator/map/map-chart-options.tsx:162 msgid "fields.areaLayer.show" msgstr "" -#: app/configurator/map/map-chart-options.tsx:314 +#: app/configurator/map/map-chart-options.tsx:333 msgid "fields.symbolLayer.show" msgstr "" diff --git a/app/pages/docs.tsx b/app/pages/docs.tsx index ca34d925e..c598290c6 100644 --- a/app/pages/docs.tsx +++ b/app/pages/docs.tsx @@ -128,6 +128,11 @@ const pages: ConfigPageOrGroup[] = [ title: "Button", content: require("../docs/button.docs"), }, + { + path: "/components/color-ramp", + title: "Color Ramp", + content: require("../docs/color-ramp.docs"), + }, { path: "/components/controls", title: "Controls", diff --git a/app/themes/federal.ts b/app/themes/federal.ts index c737dbc4c..f168ec2a0 100644 --- a/app/themes/federal.ts +++ b/app/themes/federal.ts @@ -370,6 +370,28 @@ export const theme: Theme = { color: "monochrome500", }, }, + selectColorPicker: { + color: "monochrome700", + display: "flex", + justifyContent: "space-between", + alignItems: "center", + bg: "monochrome100", + p: 1, + height: "40px", + borderWidth: "1px", + borderStyle: "solid", + borderColor: "monochrome500", + ":hover": { + bg: "monochrome100", + }, + ":active": { + bg: "monochrome100", + }, + ":disabled": { + cursor: "initial", + bg: "muted", + }, + }, arrow: { variant: "buttons.inline", padding: "0 0.25rem",