Skip to content

Commit

Permalink
fix: fix data may not array in chart insights atom
Browse files Browse the repository at this point in the history
  • Loading branch information
666haiwen committed Mar 5, 2025
1 parent bb3d137 commit 0c5ded6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vmind/src/utils/spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray, isString, merge, uniqArray } from '@visactor/vutils';
import { array, isArray, isString, merge, uniqArray } from '@visactor/vutils';
import { ChartType } from '../types';
import type { DataItem, DataTable, DataCell, Cell, FieldInfo } from '../types';
import { getFieldInfoFromDataset } from './field';
Expand Down Expand Up @@ -85,15 +85,16 @@ export const getDatasetFromSpec = (spec: any) => {
if (!spec) {
return [];
}
return spec.data.map((d: any) => d.values).flat(2);
const originSpecData = array(spec.data);
return originSpecData.map((d: any) => d.values).flat(2);
};

export const getFieldMappingFromSpec = (spec: any) => {
if (!spec) {
return {};
}
let res = {};
spec.data.forEach((d: any) => {
array(spec.data).forEach((d: any) => {
if (d?.fields) {
res = merge(res, d.fields);
}
Expand Down

0 comments on commit 0c5ded6

Please sign in to comment.