MCPcopy Create free account
hub / github.com/microsoft/SandDance / binnableColorScale

Function binnableColorScale

packages/sanddance-specs/src/scales.ts:52–97  ·  view source on GitHub ↗
(scaleName: string, colorBin: ColorBin, data: string, field: string, scheme?: string)

Source from the content-addressed store, hash-verified

50}
51
52export 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}

Callers 1

addColorFunction · 0.90

Calls 1

safeFieldNameFunction · 0.90

Tested by

no test coverage detected