(props: Props)
| 20 | } |
| 21 | |
| 22 | export function addColor(props: Props) { |
| 23 | const { colorReverseSignalName, dataName, scope, legendDataName, scaleName, specContext, topLookupName } = props; |
| 24 | let colorDataName = dataName; |
| 25 | const { insight, specColumns, specViewOptions } = specContext; |
| 26 | const legends = getLegends(specContext, scaleName); |
| 27 | if (legends) { |
| 28 | scope.legends = legends; |
| 29 | } |
| 30 | |
| 31 | const categoricalColor = specColumns.color && !specColumns.color.quantitative; |
| 32 | if (categoricalColor) { |
| 33 | addData(scope, ...topLookup(specColumns.color, specViewOptions.maxLegends, dataName, legendDataName, topLookupName, FieldNames.TopColor, FieldNames.TopIndex)); |
| 34 | colorDataName = legendDataName; |
| 35 | } |
| 36 | |
| 37 | if (specColumns.color && !specColumns.color.isColorData && !insight.directColor) { |
| 38 | if (specColumns.color.quantitative) { |
| 39 | addScales(scope, binnableColorScale(scaleName, insight.colorBin, dataName, specColumns.color.name, insight.scheme)); |
| 40 | } else { |
| 41 | addScales(scope, { |
| 42 | name: scaleName, |
| 43 | type: 'ordinal', |
| 44 | domain: { |
| 45 | data: colorDataName, |
| 46 | field: FieldNames.TopColor, |
| 47 | sort: true, |
| 48 | }, |
| 49 | range: { |
| 50 | scheme: insight.scheme || ColorScaleNone, |
| 51 | }, |
| 52 | reverse: { signal: colorReverseSignalName }, |
| 53 | }); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | addSignals(scope, |
| 58 | colorBinCountSignal(specContext), |
| 59 | colorReverseSignal(specContext), |
| 60 | ); |
| 61 | |
| 62 | return { topColorField: FieldNames.TopColor, colorDataName }; |
| 63 | } |
no test coverage detected