@vizzly/dashboard 0.15.0-dev-0bf2cc62e2eca0a88e685afc885c2424ce22349c → 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.
- package/dist/charts/src/v2/components/BarChart/BarChart.d.ts +1 -1
- package/dist/charts/src/v2/components/HorizontalBarChart/HorizontalBarChart.d.ts +1 -1
- package/dist/charts/src/v2/utils/components/BarStacked.d.ts +2 -1
- package/dist/charts/src/v2/utils/components/HorizontalBarStacked.d.ts +2 -1
- package/dist/dashboard.cjs.development.js +83 -22
- package/dist/dashboard.cjs.production.min.js +1 -1
- package/dist/dashboard.esm.js +83 -22
- package/dist/shared-logic/src/BarChartV2/buildBarChartRepresentation.d.ts +1 -1
- package/dist/shared-logic/src/ChartsV2/convertToStackedPercentages.d.ts +1 -0
- package/dist/shared-logic/src/Component/types.d.ts +2 -2
- package/dist/shared-logic/src/HorizontalBarChartV2/buildHorizontalBarChartRepresentation.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -4749,7 +4749,7 @@ var BarChart = function BarChart(config) {
|
|
|
4749
4749
|
|
|
4750
4750
|
var attributesSchema$3 = function attributesSchema(config) {
|
|
4751
4751
|
return Joi.object(_extends({}, baseAttributesSchema(config.attributesSchemaOptions), timeDimensionQuerySchema(config.queryEngineConfig, config.attributesSchemaOptions), {
|
|
4752
|
-
stacked: Joi.valid(true, false),
|
|
4752
|
+
stacked: Joi.valid(true, false, '100%'),
|
|
4753
4753
|
legend: Joi.valid(true, false),
|
|
4754
4754
|
labels: Joi.valid(true, false).optional(),
|
|
4755
4755
|
type: Joi.valid('barChartV2').required(),
|
|
@@ -8009,7 +8009,7 @@ var HorizontalBarChart = function HorizontalBarChart(config) {
|
|
|
8009
8009
|
|
|
8010
8010
|
var attributesSchema$b = function attributesSchema(config) {
|
|
8011
8011
|
return Joi.object(_extends({}, baseAttributesSchema(config.attributesSchemaOptions), timeDimensionQuerySchema(config.queryEngineConfig, config.attributesSchemaOptions), {
|
|
8012
|
-
stacked: Joi.valid(true, false),
|
|
8012
|
+
stacked: Joi.valid(true, false, '100%'),
|
|
8013
8013
|
legend: Joi.valid(true, false),
|
|
8014
8014
|
labels: Joi.valid(true, false).optional(),
|
|
8015
8015
|
type: Joi.valid('horizontalBarChartV2').required(),
|
|
@@ -34701,9 +34701,10 @@ var getLabelDictionary = function getLabelDictionary(formattedData, keys) {
|
|
|
34701
34701
|
};
|
|
34702
34702
|
var getFormattedValue = function getFormattedValue(value, dictionary) {
|
|
34703
34703
|
var _dictionary$normalize;
|
|
34704
|
-
|
|
34705
|
-
|
|
34706
|
-
|
|
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;
|
|
34707
34708
|
};
|
|
34708
34709
|
var getAllChartValues = function getAllChartValues(data, keys) {
|
|
34709
34710
|
var allValues = [];
|
|
@@ -45786,7 +45787,8 @@ var BarStacked = function BarStacked(_ref) {
|
|
|
45786
45787
|
height = _ref.height,
|
|
45787
45788
|
width = _ref.width,
|
|
45788
45789
|
showLabels = _ref.showLabels,
|
|
45789
|
-
labelDictionary = _ref.labelDictionary
|
|
45790
|
+
labelDictionary = _ref.labelDictionary,
|
|
45791
|
+
isStacked100 = _ref.isStacked100;
|
|
45790
45792
|
var handleGetXValue = function handleGetXValue(d) {
|
|
45791
45793
|
var xValue = d[xScaleKey];
|
|
45792
45794
|
if (xScaleDataType === 'string') return String(xValue);
|
|
@@ -45813,7 +45815,7 @@ var BarStacked = function BarStacked(_ref) {
|
|
|
45813
45815
|
},
|
|
45814
45816
|
height: height,
|
|
45815
45817
|
width: width,
|
|
45816
|
-
offset:
|
|
45818
|
+
offset: isStacked100 ? 'expand' : 'none',
|
|
45817
45819
|
children: function children(barStacks) {
|
|
45818
45820
|
return barStacks.map(function (barStack) {
|
|
45819
45821
|
return barStack.bars.map(function (bar) {
|
|
@@ -45956,6 +45958,7 @@ var BarChart$5 = function BarChart(_ref) {
|
|
|
45956
45958
|
var showDetailedSubGroupingLabels = !options.stacked && numberOfDimensions === 2 && width > 450;
|
|
45957
45959
|
var hasBottomTitle = chart.x.title != null;
|
|
45958
45960
|
var hasLeftTitle = chart.y.title != null;
|
|
45961
|
+
var isStacked100 = options.stacked === '100%';
|
|
45959
45962
|
var _useGroupingAxisBaseL = useGroupingAxisBaseLineShift({
|
|
45960
45963
|
hasBottomTitle: hasBottomTitle,
|
|
45961
45964
|
hasLeftTitle: hasLeftTitle,
|
|
@@ -45966,13 +45969,24 @@ var BarChart$5 = function BarChart(_ref) {
|
|
|
45966
45969
|
leftOffset = _useGroupingAxisBaseL.leftOffset;
|
|
45967
45970
|
var margin = buildMargin(chart.y.ticks, options.axis.showYAxisLabels, hasLeftTitle, hasBottomTitle, showDetailedSubGroupingLabels);
|
|
45968
45971
|
var innerWidth = width - margin.left - margin.right;
|
|
45969
|
-
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));
|
|
45970
45973
|
var xKey = chart.x.key;
|
|
45971
45974
|
var xScaleKey = chart.x.scale.key;
|
|
45972
45975
|
var xScaleDataType = chart.x.scale.dataType;
|
|
45973
45976
|
var xScale = useBarXScale(xScaleDataType, innerWidth, xScaleKey, chart.data);
|
|
45974
45977
|
var yScaleKeys = chart.y.keys;
|
|
45975
|
-
var
|
|
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]);
|
|
45976
45990
|
var yTickValues = chart.y.ticks.map(function (tick) {
|
|
45977
45991
|
return Number(tick.value);
|
|
45978
45992
|
});
|
|
@@ -46111,7 +46125,8 @@ var BarChart$5 = function BarChart(_ref) {
|
|
|
46111
46125
|
height: innerHeight,
|
|
46112
46126
|
width: innerWidth,
|
|
46113
46127
|
showLabels: options.showLabels,
|
|
46114
|
-
labelDictionary: formattedLabelsDict
|
|
46128
|
+
labelDictionary: formattedLabelsDict,
|
|
46129
|
+
isStacked100: isStacked100
|
|
46115
46130
|
})]
|
|
46116
46131
|
})]
|
|
46117
46132
|
}), tooltipData && jsxRuntime.jsx("g", {
|
|
@@ -46605,7 +46620,8 @@ var HorizontalBarStacked = function HorizontalBarStacked(_ref) {
|
|
|
46605
46620
|
height = _ref.height,
|
|
46606
46621
|
width = _ref.width,
|
|
46607
46622
|
showLabels = _ref.showLabels,
|
|
46608
|
-
labelDictionary = _ref.labelDictionary
|
|
46623
|
+
labelDictionary = _ref.labelDictionary,
|
|
46624
|
+
isStacked100 = _ref.isStacked100;
|
|
46609
46625
|
var handleGetYValue = function handleGetYValue(d) {
|
|
46610
46626
|
var yValue = d[yScaleKey];
|
|
46611
46627
|
if (yScaleDataType === 'string') return String(yValue);
|
|
@@ -46632,7 +46648,7 @@ var HorizontalBarStacked = function HorizontalBarStacked(_ref) {
|
|
|
46632
46648
|
},
|
|
46633
46649
|
height: height,
|
|
46634
46650
|
width: width,
|
|
46635
|
-
offset:
|
|
46651
|
+
offset: isStacked100 ? 'expand' : 'none',
|
|
46636
46652
|
children: function children(barStacks) {
|
|
46637
46653
|
return barStacks.map(function (barStack) {
|
|
46638
46654
|
return barStack.bars.map(function (bar) {
|
|
@@ -46962,9 +46978,21 @@ var HorizontalBarChart$3 = function HorizontalBarChart(_ref) {
|
|
|
46962
46978
|
var margin = buildMarginForHorizontalChart(chart.x.ticks, chart.y.ticks, options.axis.showXAxisLabels, options.axis.showYAxisLabels, hasLeftTitle, hasBottomTitle);
|
|
46963
46979
|
var legendOffset = options.showLegend ? 50 : 10;
|
|
46964
46980
|
var innerWidth = width - margin.left - margin.right + groupingAxisBaselineShift;
|
|
46965
|
-
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%';
|
|
46966
46983
|
var xScaleKeys = chart.x.keys;
|
|
46967
|
-
var
|
|
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]);
|
|
46968
46996
|
var barGroupXScale = useHorizontalBarXScale(innerWidth, chart.x.scale, 0);
|
|
46969
46997
|
var xTickValues = chart.x.ticks.map(function (tick) {
|
|
46970
46998
|
return Number(tick.value);
|
|
@@ -47169,7 +47197,8 @@ var HorizontalBarChart$3 = function HorizontalBarChart(_ref) {
|
|
|
47169
47197
|
height: innerHeight,
|
|
47170
47198
|
width: innerWidth,
|
|
47171
47199
|
showLabels: options.showLabels,
|
|
47172
|
-
labelDictionary: formattedLabelsDict
|
|
47200
|
+
labelDictionary: formattedLabelsDict,
|
|
47201
|
+
isStacked100: isStacked100
|
|
47173
47202
|
})]
|
|
47174
47203
|
})]
|
|
47175
47204
|
}), tooltipData && jsxRuntime.jsx("g", {
|
|
@@ -50108,6 +50137,35 @@ var AreaChartV2 = function AreaChartV2(props) {
|
|
|
50108
50137
|
});
|
|
50109
50138
|
};
|
|
50110
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
|
+
|
|
50111
50169
|
var buildBarChartRepresentation = function buildBarChartRepresentation(_ref) {
|
|
50112
50170
|
var _xKeys$, _axisTitles$x, _axisTitles$y;
|
|
50113
50171
|
var axisTitles = _ref.axisTitles,
|
|
@@ -50210,6 +50268,7 @@ var buildBarChartRepresentation = function buildBarChartRepresentation(_ref) {
|
|
|
50210
50268
|
}
|
|
50211
50269
|
if (stacked) {
|
|
50212
50270
|
data = fillMissingKeysForChartData(data);
|
|
50271
|
+
if (stacked === '100%') data = convertToStackedPercentages(data, yKeys, xKey);
|
|
50213
50272
|
}
|
|
50214
50273
|
return data;
|
|
50215
50274
|
}();
|
|
@@ -50236,7 +50295,7 @@ var buildBarChartRepresentation = function buildBarChartRepresentation(_ref) {
|
|
|
50236
50295
|
nullValue: nullValue,
|
|
50237
50296
|
order: order,
|
|
50238
50297
|
goalLines: goalLines,
|
|
50239
|
-
stacked: stacked
|
|
50298
|
+
stacked: stacked === true || stacked === '100%'
|
|
50240
50299
|
});
|
|
50241
50300
|
|
|
50242
50301
|
// ----- Lines -----
|
|
@@ -50435,14 +50494,14 @@ var BarChartV2View = function BarChartV2View(props) {
|
|
|
50435
50494
|
overflowX: 'hidden'
|
|
50436
50495
|
},
|
|
50437
50496
|
children: function children(parent) {
|
|
50438
|
-
var _props$attributes$lab;
|
|
50497
|
+
var _props$attributes$sta, _props$attributes$lab;
|
|
50439
50498
|
if (chartRepresentation.bars.length === 0) return jsxRuntime.jsx(LoadingComponent, {});
|
|
50440
50499
|
return jsxRuntime.jsx(BarChart$5, {
|
|
50441
50500
|
width: parent.width,
|
|
50442
50501
|
height: parent.height,
|
|
50443
50502
|
chart: adjustTicks(chartRepresentation, parent.width, parent.height, xKeyField),
|
|
50444
50503
|
options: {
|
|
50445
|
-
stacked:
|
|
50504
|
+
stacked: (_props$attributes$sta = props.attributes.stacked) != null ? _props$attributes$sta : false,
|
|
50446
50505
|
removeStroke: false,
|
|
50447
50506
|
showRoundedTotal: false,
|
|
50448
50507
|
showLegend: props.attributes.legend,
|
|
@@ -53978,6 +54037,7 @@ var buildHorizontalBarChartRepresentation = function buildHorizontalBarChartRepr
|
|
|
53978
54037
|
}
|
|
53979
54038
|
if (stacked) {
|
|
53980
54039
|
data = fillMissingKeysForChartData(data);
|
|
54040
|
+
if (stacked === '100%') data = convertToStackedPercentages(data, xKeys, yKey);
|
|
53981
54041
|
}
|
|
53982
54042
|
return data;
|
|
53983
54043
|
}();
|
|
@@ -54004,7 +54064,7 @@ var buildHorizontalBarChartRepresentation = function buildHorizontalBarChartRepr
|
|
|
54004
54064
|
nullValue: nullValue,
|
|
54005
54065
|
order: order,
|
|
54006
54066
|
goalLines: goalLines,
|
|
54007
|
-
stacked: stacked
|
|
54067
|
+
stacked: stacked === true || stacked === '100%'
|
|
54008
54068
|
});
|
|
54009
54069
|
var flippedTicks = {
|
|
54010
54070
|
x: {
|
|
@@ -54212,14 +54272,14 @@ var HorizontalBarChartV2View = function HorizontalBarChartV2View(props) {
|
|
|
54212
54272
|
overflowX: 'hidden'
|
|
54213
54273
|
},
|
|
54214
54274
|
children: function children(parent) {
|
|
54215
|
-
var _props$attributes$lab;
|
|
54275
|
+
var _props$attributes$sta, _props$attributes$lab;
|
|
54216
54276
|
if (chartRepresentation.bars.length === 0) return jsxRuntime.jsx(LoadingComponent, {});
|
|
54217
54277
|
return jsxRuntime.jsx(HorizontalBarChart$3, {
|
|
54218
54278
|
width: parent.width,
|
|
54219
54279
|
height: parent.height,
|
|
54220
54280
|
chart: adjustTicksForHorizontalChart(chartRepresentation, parent.width, parent.height, yKeyField),
|
|
54221
54281
|
options: {
|
|
54222
|
-
stacked:
|
|
54282
|
+
stacked: (_props$attributes$sta = props.attributes.stacked) != null ? _props$attributes$sta : false,
|
|
54223
54283
|
removeStroke: false,
|
|
54224
54284
|
showRoundedTotal: false,
|
|
54225
54285
|
showLegend: props.attributes.legend,
|
|
@@ -64738,7 +64798,8 @@ var ChartSettingsSection = function ChartSettingsSection(_ref) {
|
|
|
64738
64798
|
label: textOverride('stacked', 'Stacked'),
|
|
64739
64799
|
value: true
|
|
64740
64800
|
}];
|
|
64741
|
-
|
|
64801
|
+
var chartTypes = ['areaChart', 'barChart', 'barChartV2', 'horizontalBarChartV2'];
|
|
64802
|
+
if (chartTypes.includes(attributes.type)) {
|
|
64742
64803
|
options.push({
|
|
64743
64804
|
label: textOverride('stacked_100prc', 'Stacked (100%)'),
|
|
64744
64805
|
value: '100%'
|