@vizzly/dashboard 0.15.0-dev-304623eadd21ab4d934b2446ffd1f7a4c56d7067 → 0.15.0-dev-cbddccd98a4baff445756f4e7ff1398b9f72901c

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.
@@ -8,7 +8,7 @@ export declare type BarChartProps = {
8
8
  theme?: ChartTheme;
9
9
  chart: BarChartRepresentation;
10
10
  options: {
11
- stacked: boolean;
11
+ stacked: boolean | string;
12
12
  showRoundedTotal: boolean;
13
13
  showLegend: boolean;
14
14
  showLabels: boolean;
@@ -7,7 +7,7 @@ export declare type HorizontalBarChartProps = {
7
7
  theme?: ChartTheme;
8
8
  chart: HorizontalBarChartRepresentation;
9
9
  options: {
10
- stacked: boolean;
10
+ stacked: boolean | string;
11
11
  showRoundedTotal: boolean;
12
12
  showLegend: boolean;
13
13
  showLabels: boolean;
@@ -18,5 +18,6 @@ export declare type BarStackedProps = {
18
18
  labelDictionary: {
19
19
  [key: string]: string;
20
20
  };
21
+ isStacked100?: boolean;
21
22
  };
22
- export declare const BarStacked: ({ xScaleDataType, data, xScaleKey, yScale, keys, bars, conditionalFormattingRules, xScale, height, width, showLabels, labelDictionary, }: BarStackedProps) => JSX.Element;
23
+ export declare const BarStacked: ({ xScaleDataType, data, xScaleKey, yScale, keys, bars, conditionalFormattingRules, xScale, height, width, showLabels, labelDictionary, isStacked100, }: BarStackedProps) => JSX.Element;
@@ -18,5 +18,6 @@ export declare type HorizontalBarStackedProps = {
18
18
  labelDictionary: {
19
19
  [key: string]: string;
20
20
  };
21
+ isStacked100?: boolean;
21
22
  };
22
- export declare const HorizontalBarStacked: ({ yScaleDataType, data, yScaleKey, yScale, keys, bars, conditionalFormattingRules, xScale, height, width, showLabels, labelDictionary, }: HorizontalBarStackedProps) => JSX.Element;
23
+ export declare const HorizontalBarStacked: ({ yScaleDataType, data, yScaleKey, yScale, keys, bars, conditionalFormattingRules, xScale, height, width, showLabels, labelDictionary, isStacked100, }: HorizontalBarStackedProps) => JSX.Element;
@@ -1844,26 +1844,6 @@ function removeEmptyConditions(conditions) {
1844
1844
  });
1845
1845
  });
1846
1846
  }
1847
- var buildAdvancedFilters = function buildAdvancedFilters(filterValue, field, dataSetId) {
1848
- if (!filterValue) return [];
1849
- var hasValidConditions = Array.isArray(filterValue) && filterValue.every(function (conditionGroup) {
1850
- return Array.isArray(conditionGroup);
1851
- });
1852
- if (hasValidConditions) {
1853
- filterValue = removeEmptyConditions(filterValue);
1854
- if (filterValue.length === 0) return [];
1855
- if (field.dataSetId !== dataSetId) return [];
1856
- var correctFiltersForField = filterValue.map(function (conditionGroup) {
1857
- return conditionGroup.filter(function (filter) {
1858
- return filter.field === field.fieldId;
1859
- });
1860
- }).filter(function (conditionGroup) {
1861
- return conditionGroup.length > 0;
1862
- });
1863
- return correctFiltersForField;
1864
- }
1865
- return [];
1866
- };
1867
1847
  function getFilterDataType(filter, dataSets) {
1868
1848
  var _filter$appliesToFiel;
1869
1849
  if (filter.type == SINGLE_SELECT_FILTER || filter.type == DATE_FILTER || filter.type == DATE_AND_TIME_FILTER) {
@@ -1883,6 +1863,10 @@ function getFilterDataType(filter, dataSets) {
1883
1863
  }
1884
1864
 
1885
1865
  var toQueryAttributesFilter = function toQueryAttributesFilter(dataSet, filter, customTimeRangeFuncs) {
1866
+ // For any filter that already contains the full filter object,
1867
+ if (isAdditionalFilter(filter.value)) {
1868
+ return removeEmptyConditions(filter.value || []);
1869
+ }
1886
1870
  return filter.appliesToFields.flatMap(function (field) {
1887
1871
  var _filter$value, _filter$value2, _filter$value3;
1888
1872
  if (field.dataSetId != dataSet.id) return [];
@@ -1948,8 +1932,6 @@ var toQueryAttributesFilter = function toQueryAttributesFilter(dataSet, filter,
1948
1932
  op: '=',
1949
1933
  value: value
1950
1934
  }]];
1951
- } else if (isAdditionalFilter(filter.value)) {
1952
- return buildAdvancedFilters(filter.value, field, dataSet.id);
1953
1935
  } else if (filter.type == MULTI_SELECT_FILTER && filter.value.length > 0) {
1954
1936
  return [[{
1955
1937
  field: field.fieldId,
@@ -4767,7 +4749,7 @@ var BarChart = function BarChart(config) {
4767
4749
 
4768
4750
  var attributesSchema$3 = function attributesSchema(config) {
4769
4751
  return Joi.object(_extends({}, baseAttributesSchema(config.attributesSchemaOptions), timeDimensionQuerySchema(config.queryEngineConfig, config.attributesSchemaOptions), {
4770
- stacked: Joi.valid(true, false),
4752
+ stacked: Joi.valid(true, false, '100%'),
4771
4753
  legend: Joi.valid(true, false),
4772
4754
  labels: Joi.valid(true, false).optional(),
4773
4755
  type: Joi.valid('barChartV2').required(),
@@ -8027,7 +8009,7 @@ var HorizontalBarChart = function HorizontalBarChart(config) {
8027
8009
 
8028
8010
  var attributesSchema$b = function attributesSchema(config) {
8029
8011
  return Joi.object(_extends({}, baseAttributesSchema(config.attributesSchemaOptions), timeDimensionQuerySchema(config.queryEngineConfig, config.attributesSchemaOptions), {
8030
- stacked: Joi.valid(true, false),
8012
+ stacked: Joi.valid(true, false, '100%'),
8031
8013
  legend: Joi.valid(true, false),
8032
8014
  labels: Joi.valid(true, false).optional(),
8033
8015
  type: Joi.valid('horizontalBarChartV2').required(),
@@ -34719,9 +34701,10 @@ var getLabelDictionary = function getLabelDictionary(formattedData, keys) {
34719
34701
  };
34720
34702
  var getFormattedValue = function getFormattedValue(value, dictionary) {
34721
34703
  var _dictionary$normalize;
34722
- if (!dictionary) return value;
34723
- var normalizedKey = normalizeKey(value);
34724
- return (_dictionary$normalize = dictionary[normalizedKey]) != null ? _dictionary$normalize : value;
34704
+ var actualValue = (value == null ? void 0 : value.value) !== undefined ? value.value : value;
34705
+ if (!dictionary) return actualValue;
34706
+ var normalizedKey = normalizeKey(actualValue);
34707
+ return (_dictionary$normalize = dictionary[normalizedKey]) != null ? _dictionary$normalize : actualValue;
34725
34708
  };
34726
34709
  var getAllChartValues = function getAllChartValues(data, keys) {
34727
34710
  var allValues = [];
@@ -45804,7 +45787,8 @@ var BarStacked = function BarStacked(_ref) {
45804
45787
  height = _ref.height,
45805
45788
  width = _ref.width,
45806
45789
  showLabels = _ref.showLabels,
45807
- labelDictionary = _ref.labelDictionary;
45790
+ labelDictionary = _ref.labelDictionary,
45791
+ isStacked100 = _ref.isStacked100;
45808
45792
  var handleGetXValue = function handleGetXValue(d) {
45809
45793
  var xValue = d[xScaleKey];
45810
45794
  if (xScaleDataType === 'string') return String(xValue);
@@ -45831,7 +45815,7 @@ var BarStacked = function BarStacked(_ref) {
45831
45815
  },
45832
45816
  height: height,
45833
45817
  width: width,
45834
- offset: "none",
45818
+ offset: isStacked100 ? 'expand' : 'none',
45835
45819
  children: function children(barStacks) {
45836
45820
  return barStacks.map(function (barStack) {
45837
45821
  return barStack.bars.map(function (bar) {
@@ -45974,6 +45958,7 @@ var BarChart$5 = function BarChart(_ref) {
45974
45958
  var showDetailedSubGroupingLabels = !options.stacked && numberOfDimensions === 2 && width > 450;
45975
45959
  var hasBottomTitle = chart.x.title != null;
45976
45960
  var hasLeftTitle = chart.y.title != null;
45961
+ var isStacked100 = options.stacked === '100%';
45977
45962
  var _useGroupingAxisBaseL = useGroupingAxisBaseLineShift({
45978
45963
  hasBottomTitle: hasBottomTitle,
45979
45964
  hasLeftTitle: hasLeftTitle,
@@ -45984,13 +45969,24 @@ var BarChart$5 = function BarChart(_ref) {
45984
45969
  leftOffset = _useGroupingAxisBaseL.leftOffset;
45985
45970
  var margin = buildMargin(chart.y.ticks, options.axis.showYAxisLabels, hasLeftTitle, hasBottomTitle, showDetailedSubGroupingLabels);
45986
45971
  var innerWidth = width - margin.left - margin.right;
45987
- var innerHeight = height - margin.top - margin.bottom - (options.showLegend ? 50 : 0) - (showDetailedSubGroupingLabels ? 50 : 0) + (options.axis.showXAxisLabels ? 0 : 25);
45972
+ var innerHeight = Math.max(0, height - margin.top - margin.bottom - (options.showLegend ? 50 : 0) - (showDetailedSubGroupingLabels ? 50 : 0) + (options.axis.showXAxisLabels ? 0 : 25));
45988
45973
  var xKey = chart.x.key;
45989
45974
  var xScaleKey = chart.x.scale.key;
45990
45975
  var xScaleDataType = chart.x.scale.dataType;
45991
45976
  var xScale = useBarXScale(xScaleDataType, innerWidth, xScaleKey, chart.data);
45992
45977
  var yScaleKeys = chart.y.keys;
45993
- var yScale = useYScale(innerHeight, chart.y.scale);
45978
+ var defaultYScale = useYScale(innerHeight, chart.y.scale);
45979
+ var yScale = React.useMemo(function () {
45980
+ if (isStacked100) {
45981
+ return scale.scaleLinear({
45982
+ range: [innerHeight, 0],
45983
+ domain: [0, 1],
45984
+ nice: true,
45985
+ round: true
45986
+ });
45987
+ }
45988
+ return defaultYScale;
45989
+ }, [innerHeight, defaultYScale, options.stacked]);
45994
45990
  var yTickValues = chart.y.ticks.map(function (tick) {
45995
45991
  return Number(tick.value);
45996
45992
  });
@@ -46129,7 +46125,8 @@ var BarChart$5 = function BarChart(_ref) {
46129
46125
  height: innerHeight,
46130
46126
  width: innerWidth,
46131
46127
  showLabels: options.showLabels,
46132
- labelDictionary: formattedLabelsDict
46128
+ labelDictionary: formattedLabelsDict,
46129
+ isStacked100: isStacked100
46133
46130
  })]
46134
46131
  })]
46135
46132
  }), tooltipData && jsxRuntime.jsx("g", {
@@ -46623,7 +46620,8 @@ var HorizontalBarStacked = function HorizontalBarStacked(_ref) {
46623
46620
  height = _ref.height,
46624
46621
  width = _ref.width,
46625
46622
  showLabels = _ref.showLabels,
46626
- labelDictionary = _ref.labelDictionary;
46623
+ labelDictionary = _ref.labelDictionary,
46624
+ isStacked100 = _ref.isStacked100;
46627
46625
  var handleGetYValue = function handleGetYValue(d) {
46628
46626
  var yValue = d[yScaleKey];
46629
46627
  if (yScaleDataType === 'string') return String(yValue);
@@ -46650,7 +46648,7 @@ var HorizontalBarStacked = function HorizontalBarStacked(_ref) {
46650
46648
  },
46651
46649
  height: height,
46652
46650
  width: width,
46653
- offset: "none",
46651
+ offset: isStacked100 ? 'expand' : 'none',
46654
46652
  children: function children(barStacks) {
46655
46653
  return barStacks.map(function (barStack) {
46656
46654
  return barStack.bars.map(function (bar) {
@@ -46980,9 +46978,21 @@ var HorizontalBarChart$3 = function HorizontalBarChart(_ref) {
46980
46978
  var margin = buildMarginForHorizontalChart(chart.x.ticks, chart.y.ticks, options.axis.showXAxisLabels, options.axis.showYAxisLabels, hasLeftTitle, hasBottomTitle);
46981
46979
  var legendOffset = options.showLegend ? 50 : 10;
46982
46980
  var innerWidth = width - margin.left - margin.right + groupingAxisBaselineShift;
46983
- var innerHeight = height - margin.top - margin.bottom - legendOffset;
46981
+ var innerHeight = Math.max(0, height - margin.top - margin.bottom - legendOffset);
46982
+ var isStacked100 = options.stacked === '100%';
46984
46983
  var xScaleKeys = chart.x.keys;
46985
- var xScale = useHorizontalBarXScale(innerWidth, chart.x.scale, -groupingAxisBaselineShift);
46984
+ var defaultXScale = useHorizontalBarXScale(innerWidth, chart.x.scale, -groupingAxisBaselineShift);
46985
+ var xScale = React.useMemo(function () {
46986
+ if (isStacked100) {
46987
+ return scale.scaleLinear({
46988
+ range: [-groupingAxisBaselineShift, innerWidth + -groupingAxisBaselineShift],
46989
+ domain: [0, 1],
46990
+ nice: true,
46991
+ round: true
46992
+ });
46993
+ }
46994
+ return defaultXScale;
46995
+ }, [innerWidth, defaultXScale, groupingAxisBaselineShift, options.stacked]);
46986
46996
  var barGroupXScale = useHorizontalBarXScale(innerWidth, chart.x.scale, 0);
46987
46997
  var xTickValues = chart.x.ticks.map(function (tick) {
46988
46998
  return Number(tick.value);
@@ -47187,7 +47197,8 @@ var HorizontalBarChart$3 = function HorizontalBarChart(_ref) {
47187
47197
  height: innerHeight,
47188
47198
  width: innerWidth,
47189
47199
  showLabels: options.showLabels,
47190
- labelDictionary: formattedLabelsDict
47200
+ labelDictionary: formattedLabelsDict,
47201
+ isStacked100: isStacked100
47191
47202
  })]
47192
47203
  })]
47193
47204
  }), tooltipData && jsxRuntime.jsx("g", {
@@ -50126,6 +50137,35 @@ var AreaChartV2 = function AreaChartV2(props) {
50126
50137
  });
50127
50138
  };
50128
50139
 
50140
+ function convertToStackedPercentages(data, yKeys, xKey) {
50141
+ if (!xKey || yKeys.length === 0) {
50142
+ return data;
50143
+ }
50144
+ return data.map(function (item) {
50145
+ var convertedItem = _extends({}, item);
50146
+ var total = 0;
50147
+ yKeys.forEach(function (key) {
50148
+ var _item$key;
50149
+ var value = Number((_item$key = item[key]) == null ? void 0 : _item$key.value) || 0;
50150
+ total += value;
50151
+ });
50152
+ if (total === 0) {
50153
+ return convertedItem;
50154
+ }
50155
+ yKeys.forEach(function (key) {
50156
+ if (item[key]) {
50157
+ var value = Number(item[key].value) || 0;
50158
+ var percentage = value / total;
50159
+ convertedItem[key] = _extends({}, item[key], {
50160
+ value: percentage,
50161
+ originalValue: item[key].value
50162
+ });
50163
+ }
50164
+ });
50165
+ return convertedItem;
50166
+ });
50167
+ }
50168
+
50129
50169
  var buildBarChartRepresentation = function buildBarChartRepresentation(_ref) {
50130
50170
  var _xKeys$, _axisTitles$x, _axisTitles$y;
50131
50171
  var axisTitles = _ref.axisTitles,
@@ -50228,6 +50268,7 @@ var buildBarChartRepresentation = function buildBarChartRepresentation(_ref) {
50228
50268
  }
50229
50269
  if (stacked) {
50230
50270
  data = fillMissingKeysForChartData(data);
50271
+ if (stacked === '100%') data = convertToStackedPercentages(data, yKeys, xKey);
50231
50272
  }
50232
50273
  return data;
50233
50274
  }();
@@ -50254,7 +50295,7 @@ var buildBarChartRepresentation = function buildBarChartRepresentation(_ref) {
50254
50295
  nullValue: nullValue,
50255
50296
  order: order,
50256
50297
  goalLines: goalLines,
50257
- stacked: stacked
50298
+ stacked: stacked === true || stacked === '100%'
50258
50299
  });
50259
50300
 
50260
50301
  // ----- Lines -----
@@ -50453,14 +50494,14 @@ var BarChartV2View = function BarChartV2View(props) {
50453
50494
  overflowX: 'hidden'
50454
50495
  },
50455
50496
  children: function children(parent) {
50456
- var _props$attributes$lab;
50497
+ var _props$attributes$sta, _props$attributes$lab;
50457
50498
  if (chartRepresentation.bars.length === 0) return jsxRuntime.jsx(LoadingComponent, {});
50458
50499
  return jsxRuntime.jsx(BarChart$5, {
50459
50500
  width: parent.width,
50460
50501
  height: parent.height,
50461
50502
  chart: adjustTicks(chartRepresentation, parent.width, parent.height, xKeyField),
50462
50503
  options: {
50463
- stacked: !!props.attributes.stacked,
50504
+ stacked: (_props$attributes$sta = props.attributes.stacked) != null ? _props$attributes$sta : false,
50464
50505
  removeStroke: false,
50465
50506
  showRoundedTotal: false,
50466
50507
  showLegend: props.attributes.legend,
@@ -53996,6 +54037,7 @@ var buildHorizontalBarChartRepresentation = function buildHorizontalBarChartRepr
53996
54037
  }
53997
54038
  if (stacked) {
53998
54039
  data = fillMissingKeysForChartData(data);
54040
+ if (stacked === '100%') data = convertToStackedPercentages(data, xKeys, yKey);
53999
54041
  }
54000
54042
  return data;
54001
54043
  }();
@@ -54022,7 +54064,7 @@ var buildHorizontalBarChartRepresentation = function buildHorizontalBarChartRepr
54022
54064
  nullValue: nullValue,
54023
54065
  order: order,
54024
54066
  goalLines: goalLines,
54025
- stacked: stacked
54067
+ stacked: stacked === true || stacked === '100%'
54026
54068
  });
54027
54069
  var flippedTicks = {
54028
54070
  x: {
@@ -54230,14 +54272,14 @@ var HorizontalBarChartV2View = function HorizontalBarChartV2View(props) {
54230
54272
  overflowX: 'hidden'
54231
54273
  },
54232
54274
  children: function children(parent) {
54233
- var _props$attributes$lab;
54275
+ var _props$attributes$sta, _props$attributes$lab;
54234
54276
  if (chartRepresentation.bars.length === 0) return jsxRuntime.jsx(LoadingComponent, {});
54235
54277
  return jsxRuntime.jsx(HorizontalBarChart$3, {
54236
54278
  width: parent.width,
54237
54279
  height: parent.height,
54238
54280
  chart: adjustTicksForHorizontalChart(chartRepresentation, parent.width, parent.height, yKeyField),
54239
54281
  options: {
54240
- stacked: !!props.attributes.stacked,
54282
+ stacked: (_props$attributes$sta = props.attributes.stacked) != null ? _props$attributes$sta : false,
54241
54283
  removeStroke: false,
54242
54284
  showRoundedTotal: false,
54243
54285
  showLegend: props.attributes.legend,
@@ -64756,7 +64798,8 @@ var ChartSettingsSection = function ChartSettingsSection(_ref) {
64756
64798
  label: textOverride('stacked', 'Stacked'),
64757
64799
  value: true
64758
64800
  }];
64759
- if (attributes.type === 'barChart' || attributes.type === 'areaChart') {
64801
+ var chartTypes = ['areaChart', 'barChart', 'barChartV2', 'horizontalBarChartV2'];
64802
+ if (chartTypes.includes(attributes.type)) {
64760
64803
  options.push({
64761
64804
  label: textOverride('stacked_100prc', 'Stacked (100%)'),
64762
64805
  value: '100%'