Skip to content

Commit

Permalink
Merge pull request #5706 from mistercrunch/color_arcs
Browse files Browse the repository at this point in the history
[deck arcs] add JS hooks for sourceColor & targetColor
  • Loading branch information
betodealmeida authored Aug 27, 2018
2 parents 0d6201d + 71866f6 commit 1e6a3b0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
9 changes: 9 additions & 0 deletions superset/assets/src/explore/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ export const controls = {
renderTrigger: true,
},

target_color_picker: {
label: t('Target Color'),
description: t('Color of the target location'),
type: 'ColorPickerControl',
default: colorPrimary,
renderTrigger: true,
},

legend_position: {
label: t('Legend Position'),
description: t('Choose the position of the legend'),
Expand Down Expand Up @@ -726,6 +734,7 @@ export const controls = {
label: t('Stroke Width'),
validators: [v.integer],
default: null,
renderTrigger: true,
choices: formatSelectOptions([1, 2, 3, 4, 5]),
},

Expand Down
4 changes: 2 additions & 2 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,9 @@ export const visTypes = {
{
label: t('Arc'),
controlSetRows: [
['color_picker', 'legend_position'],
['color_picker', 'target_color_picker'],
['dimension', 'color_scheme'],
['stroke_width', null],
['stroke_width', 'legend_position'],
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ export default class CategoricalDeckGLContainer extends React.PureComponent {
}
addColor(data, fd) {
const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 };
const fixedColor = [c.r, c.g, c.b, 255 * c.a];

return data.map((d) => {
let color;
if (fd.dimension) {
color = hexToRGB(getColorFromScheme(d.cat_color, fd.color_scheme), c.a * 255);
} else {
color = fixedColor;
return { ...d, color };
}
return { ...d, color };
return d;
});
}
getLayers(values) {
Expand Down
4 changes: 4 additions & 0 deletions superset/assets/src/visualizations/deckgl/layers/arc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ function getPoints(data) {
}

function getLayer(fd, data, slice) {
const sc = fd.color_picker;
const tc = fd.target_color_picker;
return new ArcLayer({
id: `path-layer-${fd.slice_id}`,
data,
getSourceColor: d => d.sourceColor || d.color || [sc.r, sc.g, sc.b, 255 * sc.a],
getTargetColor: d => d.targetColor || d.color || [tc.r, tc.g, tc.b, 255 * tc.a],
strokeWidth: (fd.stroke_width) ? fd.stroke_width : 3,
...common.commonLayerProps(fd, slice),
});
Expand Down

0 comments on commit 1e6a3b0

Please sign in to comment.