MCPcopy Index your code
hub / github.com/microsoft/SandDance / initPrefs

Function initPrefs

packages/sanddance-explorer/src/partialInsight.ts:17–52  ·  view source on GitHub ↗
(prefs: Prefs, partialInsight: Partial<SandDance.specs.Insight>)

Source from the content-addressed store, hash-verified

15}
16
17export function initPrefs(prefs: Prefs, partialInsight: Partial<SandDance.specs.Insight>) {
18 if (partialInsight) {
19 const specTypePrefs = prefs[partialInsight.chart] || {};
20 prefs[partialInsight.chart] = specTypePrefs;
21
22 for (const _role in partialInsight.columns) {
23 const role = _role as SandDance.specs.InsightColumnRoles;
24 if (role === 'color' || role === 'x') {
25 const rolePrefs = specTypePrefs[role] || {};
26 specTypePrefs[role] = rolePrefs;
27 const column = partialInsight.columns[role];
28 const copySignalValue = (signalName: string) => {
29 if (partialInsight.signalValues && partialInsight.signalValues[signalName] && rolePrefs[column]) {
30 const signalValues = rolePrefs[column].signalValues || {};
31 signalValues[signalName] = partialInsight.signalValues[signalName];
32 rolePrefs[column].signalValues = signalValues;
33 }
34 };
35
36 switch (role) {
37 case 'color':
38 rolePrefs[column] = {
39 scheme: partialInsight.scheme,
40 colorBin: partialInsight.colorBin,
41 };
42 copySignalValue(SandDance.constants.SignalNames.ColorBinCount);
43 break;
44
45 case 'x':
46 copySignalValue(SandDance.constants.SignalNames.XBins);
47 break;
48 }
49 }
50 }
51 }
52}
53
54export function saveSignalValuePref(prefs: Prefs, chart: SandDance.specs.Chart, role: string, column: string, signalName: string, signalValue: string) {
55 const partialInsight = savePref(prefs, chart, role, column, { signalValues: {} });

Callers 1

loadFinalMethod · 0.90

Calls 1

copySignalValueFunction · 0.70

Tested by

no test coverage detected