@lightdash/common 0.1459.1 → 0.1459.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -276,7 +276,7 @@ class CartesianChartDataModel {
276
276
  return {
277
277
  columns: [
278
278
  transformedData.indexColumn.reference,
279
- ...transformedData.valuesColumns,
279
+ ...transformedData.valuesColumns.map((valueColumn) => valueColumn.pivotColumnName),
280
280
  ],
281
281
  rows: transformedData.results,
282
282
  };
@@ -303,6 +303,7 @@ class CartesianChartDataModel {
303
303
  const rightYAxisSeriesReferences = [];
304
304
  const series = transformedData.valuesColumns.map((seriesColumn, index) => {
305
305
  const seriesDisplay = Object.values(display?.series || {}).find((s) => s.yAxisIndex === index);
306
+ const seriesColumnId = seriesColumn.pivotColumnName;
306
307
  const seriesColor = seriesDisplay?.color;
307
308
  const seriesValueLabelPosition = seriesDisplay?.valueLabelPosition;
308
309
  const seriesType = seriesDisplay?.type ?? defaultSeriesType;
@@ -318,22 +319,22 @@ class CartesianChartDataModel {
318
319
  : undefined;
319
320
  const seriesLabel = singleYAxisLabel ?? seriesDisplay?.label;
320
321
  if (whichYAxis === 1) {
321
- rightYAxisSeriesReferences.push(seriesColumn);
322
+ rightYAxisSeriesReferences.push(seriesColumnId);
322
323
  }
323
324
  else {
324
- leftYAxisSeriesReferences.push(seriesColumn);
325
+ leftYAxisSeriesReferences.push(seriesColumnId);
325
326
  }
326
327
  return {
327
- dimensions: [xAxisReference, seriesColumn],
328
+ dimensions: [xAxisReference, seriesColumnId],
328
329
  type: seriesType ?? defaultSeriesType,
329
330
  stack: shouldStack && seriesType === 'bar'
330
331
  ? 'stack-all-series'
331
332
  : undefined,
332
333
  name: seriesLabel ||
333
- (0, field_1.capitalize)(seriesColumn.toLowerCase()).replaceAll('_', ' '),
334
+ (0, field_1.capitalize)(seriesColumnId.toLowerCase()).replaceAll('_', ' '),
334
335
  encode: {
335
336
  x: xAxisReference,
336
- y: seriesColumn,
337
+ y: seriesColumnId,
337
338
  },
338
339
  // NOTE: this yAxisIndex is the echarts option, NOT the yAxisIndex
339
340
  // we had been storing in the display object.
@@ -357,7 +358,6 @@ class CartesianChartDataModel {
357
358
  },
358
359
  color: seriesColor ||
359
360
  CartesianChartDataModel.getDefaultColor(index, orgColors),
360
- // this.getSeriesColor( seriesColumn, possibleXAxisValues, orgColors),
361
361
  };
362
362
  });
363
363
  const xAxisType = display?.xAxis?.type ||
@@ -243,7 +243,10 @@ class PieChartDataModel {
243
243
  ? result[transformedData.indexColumn.reference]
244
244
  : '-',
245
245
  groupId: transformedData.indexColumn?.reference,
246
- value: result[transformedData.valuesColumns[0]],
246
+ // Pie chart uses only the first value column, though others
247
+ // could be returned from the pivot query. If the pie chart
248
+ // ever supports pivoting, we'll need to update this.
249
+ value: result[transformedData.valuesColumns[0].pivotColumnName],
247
250
  })),
248
251
  },
249
252
  ],
@@ -54,11 +54,20 @@ export type PivotIndexColum = {
54
54
  reference: string;
55
55
  type: VizIndexType;
56
56
  } | undefined;
57
+ export type PivotValuesColumn = {
58
+ referenceField: string;
59
+ pivotColumnName: string;
60
+ aggregation: VizAggregationOptions;
61
+ pivotValues: {
62
+ referenceField: string;
63
+ value: string;
64
+ }[];
65
+ };
57
66
  export type PivotChartData = {
58
67
  fileUrl: string | undefined;
59
68
  results: RawResultRow[];
60
69
  indexColumn: PivotIndexColum;
61
- valuesColumns: string[];
70
+ valuesColumns: PivotValuesColumn[];
62
71
  columns: VizColumn[];
63
72
  };
64
73
  export type PivotChartLayout = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1459.1",
3
+ "version": "0.1459.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [