@data360/mcp-viz-core 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-spec.d.ts","sourceRoot":"","sources":["../src/prepare-spec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIhD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAG9C;AAwBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,SAAM,GAAG,MAAM,CAkDnE;AAID,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,CAwBrE"}
1
+ {"version":3,"file":"prepare-spec.d.ts","sourceRoot":"","sources":["../src/prepare-spec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAIhD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAG9C;AAwBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,SAAM,GAAG,MAAM,CAkDnE;AAID,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,CA8BrE"}
@@ -91,7 +91,13 @@ export function parseSpec(spec, palette) {
91
91
  ? spec.datasets[name]
92
92
  : (spec.data?.values ?? []);
93
93
  const isQuantitative = spec.encoding?.color?.type === "quantitative";
94
- const colorField = isQuantitative ? null : (spec.encoding?.color?.field ?? null);
94
+ const legendVal = spec.encoding?.color?.legend;
95
+ const xField = spec.encoding?.x?.field ?? null;
96
+ const yField = spec.encoding?.y?.field ?? null;
97
+ const colorFieldVal = spec.encoding?.color?.field ?? null;
98
+ const isRepresentedOnAxis = colorFieldVal !== null && (colorFieldVal === xField || colorFieldVal === yField);
99
+ const hasNoLegend = legendVal === null || legendVal === false || isRepresentedOnAxis;
100
+ const colorField = (isQuantitative || hasNoLegend) ? null : colorFieldVal;
95
101
  const specTitle = typeof spec.title === "string"
96
102
  ? spec.title
97
103
  : spec.title?.text ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data360/mcp-viz-core",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Framework-agnostic Vega-Lite prep and World Bank theme for Data360 MCP viz tools.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",