mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 17:24:00 +00:00
SYNC: charts fix
This commit is contained in:
committed by
Diflow
parent
28439c010f
commit
cd505abb22
@@ -48,6 +48,7 @@ export interface ChartDefinition {
|
|||||||
title?: string;
|
title?: string;
|
||||||
pieRatioLimit?: number; // limit for pie chart, if the value is below this, it will be grouped into "Other"
|
pieRatioLimit?: number; // limit for pie chart, if the value is below this, it will be grouped into "Other"
|
||||||
pieCountLimit?: number; // limit for number of pie chart slices, if the number of slices is above this, it will be grouped into "Other"
|
pieCountLimit?: number; // limit for number of pie chart slices, if the number of slices is above this, it will be grouped into "Other"
|
||||||
|
trimXCountLimit?: number; // limit for number of x values, if the number of x values is above this, it will be trimmed
|
||||||
|
|
||||||
xdef: ChartXFieldDefinition;
|
xdef: ChartXFieldDefinition;
|
||||||
ydefs: ChartYFieldDefinition[];
|
ydefs: ChartYFieldDefinition[];
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export class ChartProcessor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let addedChart: ProcessedChart = chart;
|
let addedChart: ProcessedChart = chart;
|
||||||
if (chart.rowsAdded == 0) {
|
if (chart.rowsAdded == 0 && !chart.isGivenDefinition) {
|
||||||
continue; // skip empty charts
|
continue; // skip empty charts
|
||||||
}
|
}
|
||||||
const sortOrder = chart.definition.xdef.sortOrder ?? 'ascKeys';
|
const sortOrder = chart.definition.xdef.sortOrder ?? 'ascKeys';
|
||||||
@@ -277,6 +277,13 @@ export class ChartProcessor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
addedChart.definition.trimXCountLimit != null &&
|
||||||
|
addedChart.bucketKeysOrdered.length > addedChart.definition.trimXCountLimit
|
||||||
|
) {
|
||||||
|
addedChart.bucketKeysOrdered = addedChart.bucketKeysOrdered.slice(0, addedChart.definition.trimXCountLimit);
|
||||||
|
}
|
||||||
|
|
||||||
if (addedChart) {
|
if (addedChart) {
|
||||||
addedChart.availableColumns = this.availableColumns;
|
addedChart.availableColumns = this.availableColumns;
|
||||||
this.charts.push(addedChart);
|
this.charts.push(addedChart);
|
||||||
|
|||||||
@@ -373,4 +373,34 @@ describe('Chart processor', () => {
|
|||||||
expect(chart.buckets).toEqual(expectedBuckets);
|
expect(chart.buckets).toEqual(expectedBuckets);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.only('Incorrect chart definition', () => {
|
||||||
|
const processor = new ChartProcessor([
|
||||||
|
{
|
||||||
|
chartType: 'bar',
|
||||||
|
xdef: {
|
||||||
|
field: 'category',
|
||||||
|
transformFunction: 'date:day',
|
||||||
|
},
|
||||||
|
ydefs: [],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
processor.addRows(...DS1.slice(0, 3));
|
||||||
|
processor.finalize();
|
||||||
|
|
||||||
|
expect(processor.charts.length).toEqual(1);
|
||||||
|
const chart = processor.charts[0];
|
||||||
|
expect(chart.definition.xdef.transformFunction).toEqual('date:day');
|
||||||
|
|
||||||
|
// console.log(getChartDebugPrint(processor.charts[0]));
|
||||||
|
|
||||||
|
|
||||||
|
// expect(chart.definition.xdef.transformFunction).toEqual('date:day');
|
||||||
|
// expect(chart.definition.ydefs).toEqual([
|
||||||
|
// expect.objectContaining({
|
||||||
|
// field: 'value',
|
||||||
|
// }),
|
||||||
|
// ]);
|
||||||
|
// expect(chart.bucketKeysOrdered).toEqual(['2023-10-01', '2023-10-02', '2023-10-03']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user