@lightdash/common 0.1387.0 → 0.1388.0
Sign up to get free protection for your applications and to get access to all the features.
package/dist/types/coder.d.ts
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
import type { SavedChart } from '..';
|
1
|
+
import type { PromotionChanges, SavedChart } from '..';
|
2
2
|
export declare const currentVersion = 1;
|
3
|
-
export type ChartAsCode = Pick<SavedChart, 'name' | 'description' | 'tableName' | 'metricQuery' | 'chartConfig' | 'tableConfig' | 'slug' | 'dashboardUuid' | '
|
3
|
+
export type ChartAsCode = Pick<SavedChart, 'name' | 'description' | 'tableName' | 'metricQuery' | 'chartConfig' | 'tableConfig' | 'slug' | 'dashboardUuid' | 'updatedAt'> & {
|
4
4
|
version: number;
|
5
5
|
spaceSlug: string;
|
6
|
+
downloadedAt?: Date;
|
6
7
|
};
|
7
8
|
export type ApiChartAsCodeListResponse = {
|
8
9
|
status: 'ok';
|
@@ -10,8 +11,5 @@ export type ApiChartAsCodeListResponse = {
|
|
10
11
|
};
|
11
12
|
export type ApiChartAsCodeUpsertResponse = {
|
12
13
|
status: 'ok';
|
13
|
-
results:
|
14
|
-
chart: ChartAsCode;
|
15
|
-
created: boolean;
|
16
|
-
};
|
14
|
+
results: PromotionChanges;
|
17
15
|
};
|
@@ -299,12 +299,17 @@ class CartesianChartDataModel {
|
|
299
299
|
const defaultSeriesType = type === savedCharts_1.ChartKind.VERTICAL_BAR ? 'bar' : 'line';
|
300
300
|
const shouldStack = display?.stack === true;
|
301
301
|
const xAxisReference = transformedData.indexColumn?.reference;
|
302
|
+
const leftYAxisSeriesReferences = [];
|
303
|
+
const rightYAxisSeriesReferences = [];
|
302
304
|
const series = transformedData.valuesColumns.map((seriesColumn, index) => {
|
303
305
|
const seriesDisplay = Object.values(display?.series || {}).find((s) => s.yAxisIndex === index);
|
304
|
-
const seriesFormat = seriesDisplay?.format ?? display?.yAxis?.[0]?.format; // TODO: don't always use the first y-axis format once there are multiple y-axes;
|
305
306
|
const seriesColor = seriesDisplay?.color;
|
306
307
|
const seriesValueLabelPosition = seriesDisplay?.valueLabelPosition;
|
307
308
|
const seriesType = seriesDisplay?.type ?? defaultSeriesType;
|
309
|
+
// Any value other than 1 is considered the left axis.
|
310
|
+
const whichYAxis = seriesDisplay?.whichYAxis === 1 ? 1 : 0;
|
311
|
+
const seriesFormat = seriesDisplay?.format ??
|
312
|
+
display?.yAxis?.[whichYAxis]?.format;
|
308
313
|
const singleYAxisLabel =
|
309
314
|
// NOTE: When there's only one y-axis left, set the label on the series as well
|
310
315
|
transformedData.valuesColumns.length === 1 &&
|
@@ -312,6 +317,12 @@ class CartesianChartDataModel {
|
|
312
317
|
? display.yAxis[0].label
|
313
318
|
: undefined;
|
314
319
|
const seriesLabel = singleYAxisLabel ?? seriesDisplay?.label;
|
320
|
+
if (whichYAxis === 1) {
|
321
|
+
rightYAxisSeriesReferences.push(seriesColumn);
|
322
|
+
}
|
323
|
+
else {
|
324
|
+
leftYAxisSeriesReferences.push(seriesColumn);
|
325
|
+
}
|
315
326
|
return {
|
316
327
|
dimensions: [xAxisReference, seriesColumn],
|
317
328
|
type: seriesType ?? defaultSeriesType,
|
@@ -324,9 +335,9 @@ class CartesianChartDataModel {
|
|
324
335
|
x: xAxisReference,
|
325
336
|
y: seriesColumn,
|
326
337
|
},
|
327
|
-
|
328
|
-
|
329
|
-
|
338
|
+
// NOTE: this yAxisIndex is the echarts option, NOT the yAxisIndex
|
339
|
+
// we had been storing in the display object.
|
340
|
+
yAxisIndex: whichYAxis,
|
330
341
|
tooltip: {
|
331
342
|
valueFormatter: seriesFormat
|
332
343
|
? CartesianChartDataModel.getTooltipFormatter(seriesFormat)
|
@@ -387,10 +398,10 @@ class CartesianChartDataModel {
|
|
387
398
|
{
|
388
399
|
type: 'value',
|
389
400
|
position: display?.yAxis?.[0]?.position || 'left',
|
390
|
-
name:
|
391
|
-
|
392
|
-
|
393
|
-
|
401
|
+
name: leftYAxisSeriesReferences.length > 0
|
402
|
+
? display?.yAxis?.[0]?.label ||
|
403
|
+
(0, field_1.friendlyName)(leftYAxisSeriesReferences[0])
|
404
|
+
: '',
|
394
405
|
nameLocation: 'center',
|
395
406
|
nameGap: 50,
|
396
407
|
nameRotate: 90,
|
@@ -405,6 +416,27 @@ class CartesianChartDataModel {
|
|
405
416
|
}
|
406
417
|
: {}),
|
407
418
|
},
|
419
|
+
{
|
420
|
+
type: 'value',
|
421
|
+
position: 'right',
|
422
|
+
name: rightYAxisSeriesReferences.length > 0
|
423
|
+
? display?.yAxis?.[1]?.label ||
|
424
|
+
(0, field_1.friendlyName)(rightYAxisSeriesReferences[0])
|
425
|
+
: '',
|
426
|
+
nameLocation: 'center',
|
427
|
+
nameGap: 50,
|
428
|
+
nameRotate: -90,
|
429
|
+
nameTextStyle: {
|
430
|
+
fontWeight: 'bold',
|
431
|
+
},
|
432
|
+
...(display?.yAxis?.[1]?.format
|
433
|
+
? {
|
434
|
+
axisLabel: {
|
435
|
+
formatter: CartesianChartDataModel.getTooltipFormatter(display?.yAxis?.[1].format),
|
436
|
+
},
|
437
|
+
}
|
438
|
+
: {}),
|
439
|
+
},
|
408
440
|
],
|
409
441
|
dataset: {
|
410
442
|
id: 'dataset',
|