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

Function createOrdinals

packages/sanddance-specs/src/ordinal.ts:12–41  ·  view source on GitHub ↗
(source: string, prefix: string, binFields: string[], sortOrder: SortOrder)

Source from the content-addressed store, hash-verified

10}
11
12export function createOrdinals(source: string, prefix: string, binFields: string[], sortOrder: SortOrder): OrdinalResult {
13 const _binFields = binFields.map(safeFieldName);
14 const dataName = `${prefix}_bin_order`;
15 const data: Data = {
16 name: dataName,
17 source,
18 transform: [
19 {
20 type: 'aggregate',
21 groupby: _binFields,
22 },
23 {
24 type: 'collect',
25 sort: {
26 field: _binFields,
27 order: _binFields.map(f => sortOrder),
28 },
29 },
30 {
31 type: 'window',
32 ops: ['row_number'],
33 as: [FieldNames.Ordinal],
34 },
35 ],
36 };
37 return {
38 data,
39 scale: ordinalScale(dataName, `scale_${prefix}_order`, binFields),
40 };
41}
42
43export function ordinalScale(dataName: string, scaleName: string, binFields: string[]): OrdinalScale {
44 return {

Callers 2

buildMethod · 0.90
buildMethod · 0.90

Calls 1

ordinalScaleFunction · 0.70

Tested by

no test coverage detected