(currentData: object[], showSelectedData: boolean, showActive: boolean, viewerOptions: ViewerOptions)
| 12 | import { GL_ORDINAL } from './constants'; |
| 13 | |
| 14 | export function getSelectedColorMap(currentData: object[], showSelectedData: boolean, showActive: boolean, viewerOptions: ViewerOptions) { |
| 15 | function getSelectionColorItem(datum: object) { |
| 16 | let item: ColorMappedItem; |
| 17 | if (showSelectedData) { |
| 18 | item = datum[FieldNames.Selected] ? |
| 19 | { color: VegaDeckGl.util.colorFromString(viewerOptions.colors.selectedCube) } |
| 20 | : |
| 21 | { unSelected: true }; |
| 22 | } |
| 23 | if (showActive && datum[FieldNames.Active]) { |
| 24 | item = { color: VegaDeckGl.util.colorFromString(viewerOptions.colors.activeCube) }; |
| 25 | } |
| 26 | return item; |
| 27 | } |
| 28 | const colorMap: ColorMap = {}; |
| 29 | currentData.forEach(datum => { |
| 30 | const selectionColor = getSelectionColorItem(datum); |
| 31 | if (selectionColor) { |
| 32 | const ordinal = datum[GL_ORDINAL]; |
| 33 | colorMap[ordinal] = selectionColor; |
| 34 | } |
| 35 | }); |
| 36 | return colorMap; |
| 37 | } |
| 38 | |
| 39 | export function colorMapFromCubes(cubes: VegaDeckGl.types.Cube[]) { |
| 40 | const map: ColorMap = {}; |
no test coverage detected