forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi layers DECK.GL visualization (apache#4096)
* Multi layers DECK.GL viz * Fix tests * rebasing * Fix error handling in chartActions * Addressing comments
- Loading branch information
1 parent
09fbfd2
commit c8e2ae6
Showing
21 changed files
with
280 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { GridLayer } from 'deck.gl'; | ||
|
||
export default function getLayer(formData, payload) { | ||
const fd = formData; | ||
const c = fd.color_picker; | ||
const data = payload.data.features.map(d => ({ | ||
...d, | ||
color: [c.r, c.g, c.b, 255 * c.a], | ||
})); | ||
|
||
return new GridLayer({ | ||
id: `grid-layer-${fd.slice_id}`, | ||
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], | ||
outline: false, | ||
getElevationValue: points => points.reduce((sum, point) => sum + point.weight, 0), | ||
getColorValue: points => points.reduce((sum, point) => sum + point.weight, 0), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { HexagonLayer } from 'deck.gl'; | ||
|
||
export default function getLayer(formData, payload) { | ||
const fd = formData; | ||
const c = fd.color_picker; | ||
const data = payload.data.features.map(d => ({ | ||
...d, | ||
color: [c.r, c.g, c.b, 255 * c.a], | ||
})); | ||
|
||
return new HexagonLayer({ | ||
id: `hex-layer-${fd.slice_id}`, | ||
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], | ||
outline: false, | ||
getElevationValue: points => points.reduce((sum, point) => sum + point.weight, 0), | ||
getColorValue: points => points.reduce((sum, point) => sum + point.weight, 0), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint camelcase: 0 */ | ||
import deck_grid from './grid'; | ||
import deck_screengrid from './screengrid'; | ||
import deck_path from './path'; | ||
import deck_hex from './hex'; | ||
import deck_scatter from './scatter'; | ||
import deck_geojson from './geojson'; | ||
|
||
const layerGenerators = { | ||
deck_grid, | ||
deck_screengrid, | ||
deck_path, | ||
deck_hex, | ||
deck_scatter, | ||
deck_geojson, | ||
}; | ||
export default layerGenerators; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { PathLayer } from 'deck.gl'; | ||
|
||
export default function getLayer(formData, payload) { | ||
const fd = formData; | ||
const c = fd.color_picker; | ||
const fixedColor = [c.r, c.g, c.b, 255 * c.a]; | ||
const data = payload.data.paths.map(path => ({ | ||
path, | ||
width: fd.line_width, | ||
color: fixedColor, | ||
})); | ||
|
||
return new PathLayer({ | ||
id: `path-layer-${fd.slice_id}`, | ||
data, | ||
rounded: true, | ||
widthScale: 1, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ScatterplotLayer } from 'deck.gl'; | ||
|
||
import { getColorFromScheme, hexToRGB } from '../../../javascripts/modules/colors'; | ||
import { unitToRadius } from '../../../javascripts/modules/geo'; | ||
|
||
export default function getLayer(formData, payload) { | ||
const fd = formData; | ||
const c = fd.color_picker || { r: 0, g: 0, b: 0, a: 1 }; | ||
const fixedColor = [c.r, c.g, c.b, 255 * c.a]; | ||
|
||
const data = payload.data.features.map((d) => { | ||
let radius = unitToRadius(fd.point_unit, d.radius) || 10; | ||
if (fd.multiplier) { | ||
radius *= fd.multiplier; | ||
} | ||
let color; | ||
if (fd.dimension) { | ||
color = hexToRGB(getColorFromScheme(d.cat_color, fd.color_scheme), c.a * 255); | ||
} else { | ||
color = fixedColor; | ||
} | ||
return { | ||
...d, | ||
radius, | ||
color, | ||
}; | ||
}); | ||
return new ScatterplotLayer({ | ||
id: `scatter-layer-${fd.slice_id}`, | ||
data, | ||
pickable: true, | ||
fp64: true, | ||
outline: false, | ||
}); | ||
} |
Oops, something went wrong.