Merge pull request #5706 from mistercrunch/color_arcs

[deck arcs] add JS hooks for sourceColor & targetColor
This commit is contained in:
Beto Dealmeida 2018-08-27 16:33:54 -07:00 committed by GitHub
commit 1e6a3b0401
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 7 deletions

View File

@ -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'),
@ -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]),
},

View File

@ -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'],
],
},
{

View File

@ -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) {

View File

@ -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),
});