Skip to content
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
2 changes: 2 additions & 0 deletions packages/generate-vchart/src/transformers/bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const colorBar = (context: GenerateChartInput) => {
const colorThemes = COLOR_THEMES.default;

spec.color = colorThemes.slice();
} else if ('palette' in context && context.palette) {
spec.color = context.palette;
} else {
const colorThemes = COLOR_THEMES.default;
//apply transparent gradient
Expand Down
4 changes: 2 additions & 2 deletions packages/generate-vchart/src/transformers/cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export const seriesField = (context: GenerateChartInput) => {

export const axis = (context: GenerateChartInput) => {
const { spec, cell, fieldInfo, axes, transpose } = context;
// 现在只有柱图和rangeColumn 支持了转置
const validTranspose = transpose && (spec.type === 'bar' || spec.type === 'rangeColumn');
// 现在只有柱图 rangeColumn 瀑布图 支持了转置
const validTranspose = transpose && (spec.type === 'bar' || spec.type === 'rangeColumn' || spec.type === 'waterfall');
const bandAxisOrient = validTranspose ? 'left' : 'bottom';
const linearAxisOrient = validTranspose ? 'bottom' : 'left';

Expand Down
9 changes: 6 additions & 3 deletions packages/generate-vchart/src/transformers/waterfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { color, data, discreteLegend, formatXFields, labelForDefaultHide } from

export const waterfallField = (context: GenerateChartInput) => {
//assign field in spec according to cell
const { cell, spec, waterfallTotal } = context;
spec.xField = cell.x;
spec.yField = cell.y;
const { cell, spec, waterfallTotal, transpose } = context;
spec.xField = transpose ? cell.y : cell.x;
spec.yField = transpose ? cell.x : cell.y;
if (transpose) {
spec.direction = 'horizontal';
}

if (waterfallTotal?.visible !== false) {
spec.total = {
Expand Down
13 changes: 13 additions & 0 deletions packages/vmind/src/atom/chartGenerator/rule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ const formatDataTable = (simpleVChartSpec: SimpleVChartSpec, data: DataTable) =>
value1: arr[1]
};
});
} else if (type === 'waterfall') {
const finalData = [];
for (let i = data.length - 1; i >= 0; i--) {
if (i === 0 || i === data.length - 1) {
finalData.push({ name: data[i].name, value: data[i].value });
} else {
finalData.push({ name: data[i].name, value: Number(data[i].value) - Number(data[i - 1].value) });
}
}
finalData.reverse();
return finalData;
}

return data;
Expand Down Expand Up @@ -104,6 +115,8 @@ export const getContextBySimpleVChartSpec = (simpleVChartSpec: SimpleVChartSpec)
: originalSeries?.[0]?.type === 'bar' && coordinate === 'polar'
? 'rose'
: originalSeries?.[0]?.type ?? type
: type === 'bar' && 'value' in data[0] && 'value1' in data[0]
? 'rangeColumn'
: type;

let series = originalSeries;
Expand Down
11 changes: 7 additions & 4 deletions packages/vmind/src/atom/imageReader/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ When executing the task, you need to meet the following requirements:
1. You must first determine the type before proceeding, and the type must be one of the following:
"common"|"area"|"line"|"bar"|"rangeColumn"|"rangeArea"|"map"|"pie"|"radar"|"rose"|"scatter"|"sequence"|"circularProgress"|"linearProgress"|"wordCloud"|"funnel"|"waterfall"|"boxPlot"|"gauge"|"sankey"|"treemap"|"sunburst"|"circlePacking"|"heatmap"|"liquid"|"venn"|"mosaic"|"bidirectionalBar"
2. Only return JSON that can be used to recreate the chart
3. If the image is a composite chart, return the type as 'common'. All data for composite charts must be returned through the series field, not placed in the top-level data field
4. If all series in a composite chart are unidirectional bar charts, return the type as 'bar'; if the image is symmetrically distributed on both sides, must return the type as 'bidirectionalBar'
5. You should pay attention to distinguish radar chart and rose chart
6. If the type is treemap, the background color of each block needs to be used as the group value
3. If this is a bar chart (type is 'bar'), with dashed lines connecting each bar, and different colors between bars indicating increase or decrease relationships, then the type should be returned as 'waterfall'.If the bars are arranged horizontally, return transpose as true.
4. If the chart is a bar chart (type is 'bar') and the starting points of each bar are not aligned (i.e., not starting from 0), then each bar needs to return the corresponding starting and ending values, which are 'value' and 'value1' respectively.
5. If the image is a composite chart, return the type as 'common'. All data for composite charts must be returned through the series field, not placed in the top-level data field
6. If all series in a composite chart are unidirectional bar charts, return the type as 'bar'; if the image is symmetrically distributed on both sides, must return the type as 'bidirectionalBar'
7. You should pay attention to distinguish radar chart and rose chart
8. If the type is treemap, the background color of each block needs to be used as the group value
9. For the type property of each element object in the axes field, it must be 'band' or 'linear'

# Answer
\`\`\`
Expand Down