Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/expand uncommon charts #157

Merged
merged 6 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
469 changes: 467 additions & 2 deletions packages/vmind/__tests__/browser/src/constants/mockData.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ import {
SalesRecordsData,
gmvData,
mockProgressData,
liquidData
liquidData,
bubbleCirclePackingData,
rangeColumnChartData,
sunburstChartData,
treemapChartData,
gaugeChartData,
linearProgressChartData,
basicHeatMapChartData,
vennChartData,
mapChartData
} from '../../constants/mockData';
import VMind, { ArcoTheme, builtinThemeMap, BuiltinThemeType } from '../../../../../src/index';
import { Model } from '../../../../../src/index';
import { isArray } from '@visactor/vutils';
import VChart from '@visactor/vchart';

const TextArea = Input.TextArea;
const Option = Select.Option;
Expand Down Expand Up @@ -87,7 +97,16 @@ const demoDataList: { [key: string]: any } = {
DataQuery: mockUserInput18,
salesData: SalesRecordsData,
progress: mockProgressData,
liquid: liquidData
liquid: liquidData,
BubbleCirclePacking: bubbleCirclePackingData,
Map: mapChartData,
RangeColumn: rangeColumnChartData,
Sunburst: sunburstChartData,
TreeMap: treemapChartData,
Gauge: gaugeChartData,
LinearProgress: linearProgressChartData,
BasicHeatMap: basicHeatMapChartData,
Venn: vennChartData
};

const globalVariables = (import.meta as any).env;
Expand All @@ -99,6 +118,7 @@ const ModelConfigMap: any = {
};
const OPENAI_API_URL = 'https://api.openai.com/v1/chat/completions';

const MAP_CHART_BASEMAP = 'https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/geojson/world.json';
const specTemplateTest = false;
export function DataInput(props: IPropsType) {
const defaultDataKey = Object.keys(demoDataList)[3];
Expand Down Expand Up @@ -150,6 +170,13 @@ export function DataInput(props: IPropsType) {
const finalDataset = specTemplateTest && model !== Model.CHART_ADVISOR ? undefined : dataset;

const startTime = new Date().getTime();

// The map chart requires the user to register a base map named map in advance using VChart.registerMap
if (csv === demoDataList.Map.csv) {
const response = await fetch(MAP_CHART_BASEMAP);
const geoJson = await response.json();
VChart.registerMap('map', geoJson);
}
const chartGenerationRes = await vmind.generateChart(describe, finalFieldInfo, finalDataset, {
//enableDataQuery: false,
//chartTypeList: [ChartType.BarChart, ChartType.LineChart],
Expand Down
2 changes: 1 addition & 1 deletion packages/vmind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "6.9.0",
"@visactor/vchart": "^1.10.4",
"@visactor/vchart": "^1.11.4",
"@rollup/plugin-dynamic-import-vars": "~2.1.0",
"@types/node": "*",
"dotenv": "~16.3.1",
Expand Down
39 changes: 38 additions & 1 deletion packages/vmind/src/applications/chartGeneration/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
import { ChartType } from '../../common/typings';
import type { BasemapOption } from '../../common/typings';
import { ChartType, MapRegionCoordinate } from '../../common/typings';

export const SUPPORTED_CHART_LIST = Object.values(ChartType);

export const NEED_COLOR_FIELD_CHART_LIST = [ChartType.PieChart, ChartType.RoseChart, ChartType.LinearProgress];

export const NEED_SIZE_FIELD_CHART_LIST = [ChartType.ScatterPlot, ChartType.BasicHeatMap];

export const NEED_COLOR_AND_SIZE_CHART_LIST = [
ChartType.WordCloud,
ChartType.MapChart,
ChartType.BubbleCirclePacking,
ChartType.VennChart,
ChartType.Gauge,
ChartType.SunburstChart,
ChartType.TreemapChart,
ChartType.CircularProgress,
ChartType.LiquidChart
];

export const CARTESIAN_CHART_LIST = [
ChartType.DynamicBarChart,
ChartType.BarChart,
ChartType.LineChart,
ChartType.ScatterPlot,
ChartType.FunnelChart,
ChartType.DualAxisChart,
ChartType.WaterFallChart,
ChartType.BoxPlot,
ChartType.RangeColumnChart,
ChartType.LinearProgress
];

export const DEFAULT_MAP_OPTION: BasemapOption = {
regionProjectType: null,
regionCoordinate: MapRegionCoordinate.GEO,
zoom: 1,
center: null
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ import { chartGenerationRequestLLM, parseChartGenerationResponse } from './utils
import { GPTChartGenerationPrompt } from './prompt';
import {
patchAxisField,
patchBasicHeatMapChart,
patchBoxPlot,
patchCartesianXField,
patchColorField,
patchDualAxis,
patchDynamicBarChart,
patchLabelField,
patchLinearProgressChart,
patchNeedColor,
patchNeedSize,
patchPieChart,
patchRangeColumnChart,
patchWordCloud,
patchYField
} from './patcher';
Expand All @@ -34,11 +39,16 @@ const ChartGenerationTaskNodeGPTMeta: LLMBasedTaskNodeMeta<
patchColorField,
patchLabelField,
patchYField,
patchNeedColor,
patchNeedSize,
patchBoxPlot,
patchDualAxis,
patchPieChart,
patchWordCloud,
patchDynamicBarChart,
patchRangeColumnChart,
patchLinearProgressChart,
patchBasicHeatMapChart,
patchCartesianXField
],
requester: chartGenerationRequestLLM,
Expand Down
Loading
Loading