(scaleName: string, colorBin: ColorBin, data: string, field: string, scheme?: string)
| 50 | } |
| 51 | |
| 52 | export function binnableColorScale(scaleName: string, colorBin: ColorBin, data: string, field: string, scheme?: string) { |
| 53 | scheme = scheme || ColorScaleNone; |
| 54 | const domain: ScaleData = { |
| 55 | data, |
| 56 | field: safeFieldName(field), |
| 57 | }; |
| 58 | const range: RangeScheme = { |
| 59 | scheme, |
| 60 | }; |
| 61 | const reverse: SignalRef = { signal: SignalNames.ColorReverse }; |
| 62 | if (colorBin !== 'continuous') { |
| 63 | range.count = { signal: SignalNames.ColorBinCount }; |
| 64 | } |
| 65 | switch (colorBin) { |
| 66 | case 'continuous': { |
| 67 | const sequentialScale: LinearScale = { |
| 68 | name: scaleName, |
| 69 | type: 'linear', |
| 70 | domain, |
| 71 | range, |
| 72 | reverse, |
| 73 | }; |
| 74 | return sequentialScale; |
| 75 | } |
| 76 | case 'quantile': { |
| 77 | const quantileScale: QuantileScale = { |
| 78 | name: scaleName, |
| 79 | type: 'quantile', |
| 80 | domain, |
| 81 | range, |
| 82 | reverse, |
| 83 | }; |
| 84 | return quantileScale; |
| 85 | } |
| 86 | default: { |
| 87 | const quantizeScale: QuantizeScale = { |
| 88 | name: scaleName, |
| 89 | type: 'quantize', |
| 90 | domain, |
| 91 | range, |
| 92 | reverse, |
| 93 | }; |
| 94 | return quantizeScale; |
| 95 | } |
| 96 | } |
| 97 | } |
no test coverage detected