From 39ba96d211307eaf9d51e96f5cc97df174931615 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Mon, 8 Apr 2024 17:00:18 -0700 Subject: [PATCH] support save custom colorScale --- src/components/src/index.ts | 2 +- src/layers/src/base-layer.ts | 9 ++++++--- src/layers/src/layer-utils.ts | 2 +- src/schemas/src/vis-state-schema.ts | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/src/index.ts b/src/components/src/index.ts index 0415805009..0f789b618e 100644 --- a/src/components/src/index.ts +++ b/src/components/src/index.ts @@ -28,7 +28,7 @@ import {appInjector} from './container'; export {default as KeplerGl, default, injectComponents, ContainerFactory, ERROR_MSG} from './container'; // factories -export {default as KeplerGlFactory, DEFAULT_KEPLER_GL_PROPS, getVisibleDatasets, makeGetActionCreators, mapFieldsSelector, plotContainerSelector} from './kepler-gl'; +export {default as KeplerGlFactory, DEFAULT_KEPLER_GL_PROPS, getVisibleDatasets, makeGetActionCreators, mapFieldsSelector, plotContainerSelector, sidePanelSelector} from './kepler-gl'; export {default as SidePanelFactory} from './side-panel'; export {default as PanelTitleFactory} from './side-panel/panel-title'; export {default as MapContainerFactory, Attribution} from './map-container'; diff --git a/src/layers/src/base-layer.ts b/src/layers/src/base-layer.ts index 9db490dda3..b52e826665 100644 --- a/src/layers/src/base-layer.ts +++ b/src/layers/src/base-layer.ts @@ -73,6 +73,9 @@ export type LayerBaseConfig = { dataId: string; label: string; color: RGBColor; + colorScale?: VisualChannelScale; + colorField?: VisualChannelField; + colorDomain?: VisualChannelDomain; columns: LayerColumns; isVisible: boolean; @@ -459,9 +462,9 @@ class Layer { // TODO: refactor this into separate visual Channel config // color by field, domain is set by filters, field, scale type - colorField: null, - colorDomain: [0, 1], - colorScale: SCALE_TYPES.quantile, + colorField: props.colorField || null, + colorDomain: props.colorDomain || [0, 1], + colorScale: props.colorScale || SCALE_TYPES.quantile, // color by size, domain is set by filters, field, scale type sizeDomain: [0, 1], diff --git a/src/layers/src/layer-utils.ts b/src/layers/src/layer-utils.ts index 96ddb07319..f93b31face 100644 --- a/src/layers/src/layer-utils.ts +++ b/src/layers/src/layer-utils.ts @@ -58,7 +58,7 @@ export function getGeojsonLayerMetaFromArrow({ chunkOffset: geoColumn.data[0].length * chunkIndex } : {}), - triangulate: true, + triangulate: false, calculateMeanCenters: true }; // create binary data from arrow data for GeoJsonLayer diff --git a/src/schemas/src/vis-state-schema.ts b/src/schemas/src/vis-state-schema.ts index 47bafb75cd..d661d436f7 100644 --- a/src/schemas/src/vis-state-schema.ts +++ b/src/schemas/src/vis-state-schema.ts @@ -530,6 +530,9 @@ export const layerPropsV1 = { dataId: null, label: null, color: null, + colorScale: null, + colorField: null, + colorDomain: null, highlightColor: null, columns: new ColumnSchemaV1({ version: VERSIONS.v1,