Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deck.gl): add color range for deck.gl 3D chart #19520

Merged
merged 1 commit into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
import { GridLayer } from 'deck.gl';
import React from 'react';
import { t } from '@superset-ui/core';
import { t, CategoricalColorNamespace } from '@superset-ui/core';

import { commonLayerProps, getAggFunc } from '../common';
import sandboxedEval from '../../utils/sandbox';
import { hexToRGB } from '../../utils/colors';
import { createDeckGLComponent } from '../../factory';
import TooltipRow from '../../TooltipRow';

Expand All @@ -42,11 +43,9 @@ function setTooltipContent(o) {

export function getLayer(formData, payload, onAddFilter, setTooltip) {
const fd = formData;
const c = fd.color_picker;
let data = payload.data.features.map(d => ({
...d,
color: [c.r, c.g, c.b, 255 * c.a],
}));
const colorScale = CategoricalColorNamespace.getScale(fd.color_scheme);
const colorRange = colorScale.range().map(color => hexToRGB(color));
let data = payload.data.features;

if (fd.js_data_mutator) {
// Applying user defined data mutator if defined
Expand All @@ -61,9 +60,8 @@ export function getLayer(formData, payload, onAddFilter, setTooltip) {
data,
pickable: true,
cellSize: fd.grid_size,
minColor: [0, 0, 0, 0],
extruded: fd.extruded,
maxColor: [c.r, c.g, c.b, 255 * c.a],
colorRange,
outline: false,
getElevationValue: aggFunc,
getColorValue: aggFunc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ const config: ControlPanelConfig = {
label: t('Map'),
controlSetRows: [
[mapboxStyle, viewport],
['color_picker', autozoom],
[gridSize, extruded],
['color_scheme'],
[autozoom],
[gridSize],
[extruded],
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
*/
import { HexagonLayer } from 'deck.gl';
import React from 'react';
import { t } from '@superset-ui/core';
import { t, CategoricalColorNamespace } from '@superset-ui/core';

import { commonLayerProps, getAggFunc } from '../common';
import sandboxedEval from '../../utils/sandbox';
import { hexToRGB } from '../../utils/colors';
import { createDeckGLComponent } from '../../factory';
import TooltipRow from '../../TooltipRow';

Expand All @@ -42,11 +43,9 @@ function setTooltipContent(o) {

export function getLayer(formData, payload, onAddFilter, setTooltip) {
const fd = formData;
const c = fd.color_picker;
let data = payload.data.features.map(d => ({
...d,
color: [c.r, c.g, c.b, 255 * c.a],
}));
const colorScale = CategoricalColorNamespace.getScale(fd.color_scheme);
const colorRange = colorScale.range().map(color => hexToRGB(color));
let data = payload.data.features;

if (fd.js_data_mutator) {
// Applying user defined data mutator if defined
Expand All @@ -60,9 +59,8 @@ export function getLayer(formData, payload, onAddFilter, setTooltip) {
data,
pickable: true,
radius: fd.grid_size,
minColor: [0, 0, 0, 0],
extruded: fd.extruded,
maxColor: [c.r, c.g, c.b, 255 * c.a],
colorRange,
outline: false,
getElevationValue: aggFunc,
getColorValue: aggFunc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const config: ControlPanelConfig = {
label: t('Map'),
controlSetRows: [
[mapboxStyle, viewport],
['color_picker'],
['color_scheme'],
[autozoom],
[gridSize],
[extruded],
Expand Down