@lightdash/common 0.1377.0 → 0.1377.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -333,7 +333,7 @@ export declare const getDefaultSeriesColor: (index: number) => string;
333
333
  export declare const isSeriesWithMixedChartTypes: (series: Series[] | undefined) => boolean;
334
334
  export declare const getChartType: (chartKind: ChartKind | undefined) => ChartType;
335
335
  export declare const getChartKind: (chartType: ChartType, value: ChartConfig['config']) => ChartKind | undefined;
336
- export declare const getEChartsChartTypeFromChartKind: (chartKind: ChartKind.VERTICAL_BAR | ChartKind.LINE | ChartKind.AREA | ChartKind.SCATTER) => CartesianSeriesType;
336
+ export declare const getEChartsChartTypeFromChartKind: (chartKind: ChartKind) => CartesianSeriesType;
337
337
  export type ChartSummary = Pick<SavedChart, 'uuid' | 'name' | 'description' | 'spaceName' | 'spaceUuid' | 'projectUuid' | 'organizationUuid' | 'pinnedListUuid' | 'dashboardUuid' | 'dashboardName' | 'slug'> & {
338
338
  chartType?: ChartType | undefined;
339
339
  chartKind?: ChartKind | undefined;
@@ -195,7 +195,7 @@ const getEChartsChartTypeFromChartKind = (chartKind) => {
195
195
  case ChartKind.SCATTER:
196
196
  return CartesianSeriesType.SCATTER;
197
197
  default:
198
- return (0, assertUnreachable_1.default)(chartKind, `Unknown chart kind: ${chartKind}`);
198
+ return CartesianSeriesType.BAR;
199
199
  }
200
200
  };
201
201
  exports.getEChartsChartTypeFromChartKind = getEChartsChartTypeFromChartKind;
@@ -1,7 +1,7 @@
1
1
  import { Format } from '../types/field';
2
2
  import { type Organization } from '../types/organization';
3
3
  import { type RawResultRow } from '../types/results';
4
- import { ChartKind } from '../types/savedCharts';
4
+ import { ChartKind, type CartesianSeriesType } from '../types/savedCharts';
5
5
  import { type SemanticLayerQuery } from '../types/semanticLayer';
6
6
  import { VizIndexType, type PivotChartData, type PivotChartLayout, type VizCartesianChartConfig, type VizCartesianChartOptions } from './types';
7
7
  import { type IResultsRunner } from './types/IResultsRunner';
@@ -69,7 +69,7 @@ export type CartesianChartDisplay = {
69
69
  format?: Format;
70
70
  yAxisIndex?: number;
71
71
  color?: string;
72
- type?: ChartKind.LINE | ChartKind.VERTICAL_BAR;
72
+ type?: CartesianSeriesType.LINE | CartesianSeriesType.BAR;
73
73
  valueLabelPosition?: ValueLabelPositionOptions;
74
74
  };
75
75
  };
@@ -296,21 +296,24 @@ class CartesianChartDataModel {
296
296
  const shouldStack = display?.stack === true;
297
297
  const xAxisReference = transformedData.indexColumn?.reference;
298
298
  const series = transformedData.valuesColumns.map((seriesColumn, index) => {
299
- const seriesFormat = Object.values(display?.series || {}).find((s) => s.yAxisIndex === index)?.format ?? display?.yAxis?.[0]?.format; // TODO: don't always use the first y-axis format once there are multiple y-axes
299
+ const seriesDisplay = Object.values(display?.series || {}).find((s) => s.yAxisIndex === index);
300
+ const seriesFormat = seriesDisplay?.format ?? display?.yAxis?.[0]?.format; // TODO: don't always use the first y-axis format once there are multiple y-axes;
301
+ const seriesColor = seriesDisplay?.color;
302
+ const seriesValueLabelPosition = seriesDisplay?.valueLabelPosition;
303
+ const seriesType = seriesDisplay?.type ?? defaultSeriesType;
300
304
  const singleYAxisLabel =
301
305
  // NOTE: When there's only one y-axis left, set the label on the series as well
302
306
  transformedData.valuesColumns.length === 1 &&
303
307
  display?.yAxis?.[0]?.label
304
308
  ? display.yAxis[0].label
305
309
  : undefined;
306
- const seriesLabel = singleYAxisLabel ??
307
- Object.values(display?.series || {}).find((s) => s.yAxisIndex === index)?.label;
308
- const seriesColor = Object.values(display?.series || {}).find((s) => s.yAxisIndex === index)?.color;
309
- const seriesValueLabelPosition = Object.values(display?.series || {}).find((s) => s.yAxisIndex === index)?.valueLabelPosition;
310
+ const seriesLabel = singleYAxisLabel ?? seriesDisplay?.label;
310
311
  return {
311
312
  dimensions: [xAxisReference, seriesColumn],
312
- type: defaultSeriesType,
313
- stack: shouldStack ? 'stack-all-series' : undefined,
313
+ type: seriesType ?? defaultSeriesType,
314
+ stack: shouldStack && seriesType === 'bar'
315
+ ? 'stack-all-series'
316
+ : undefined,
314
317
  name: seriesLabel ||
315
318
  (0, field_1.capitalize)(seriesColumn.toLowerCase()).replaceAll('_', ' '),
316
319
  encode: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1377.0",
3
+ "version": "0.1377.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [