@vizzly/dashboard 0.15.0-dev-2951fa8f4bfb19f2edfb461044c09144bcc56296 → 0.15.0-dev-65c3e5d7491389a56cc8409b046f92683dd4725f
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/WaterfallChart/Tooltip.d.ts +2 -2
- package/dist/dashboard.cjs.development.js +258 -252
- package/dist/dashboard.cjs.production.min.js +1 -1
- package/dist/dashboard.esm.js +258 -252
- package/dist/shared-ui/src/components/WaterfallChart/WaterfallChartView.d.ts +3 -3
- package/package.json +1 -1
package/dist/dashboard.esm.js
CHANGED
|
@@ -10553,7 +10553,7 @@ var WaterfallChart = function WaterfallChart(config) {
|
|
|
10553
10553
|
return removeField$1(attrs, fieldId, config.queryEngineConfig);
|
|
10554
10554
|
},
|
|
10555
10555
|
isRunnable: function isRunnable(hydrated) {
|
|
10556
|
-
return hydrated.measure.length > 0;
|
|
10556
|
+
return hydrated.measure.length > 0 && (hydrated.dimension.length > 0 || hydrated.timeDimension !== null);
|
|
10557
10557
|
},
|
|
10558
10558
|
autoGenerate: function autoGenerate(dataSet) {
|
|
10559
10559
|
var _DataSet$buildQueryAt = buildQueryAttributes(dataSet, config.queryEngineConfig, 'waterfallChart'),
|
|
@@ -10578,7 +10578,8 @@ var WaterfallChart = function WaterfallChart(config) {
|
|
|
10578
10578
|
getValues: function getValues(attrs) {
|
|
10579
10579
|
return attrs.measure;
|
|
10580
10580
|
},
|
|
10581
|
-
testId: 'metric-input'
|
|
10581
|
+
testId: 'metric-input',
|
|
10582
|
+
maxAllowed: 1
|
|
10582
10583
|
}), _extends({}, namespace(CONSTANTS$l, 'field_x_axis'), {
|
|
10583
10584
|
fieldFilterOptions: {
|
|
10584
10585
|
forComponent: 'waterfallChart',
|
|
@@ -10591,7 +10592,7 @@ var WaterfallChart = function WaterfallChart(config) {
|
|
|
10591
10592
|
getValues: function getValues(attrs) {
|
|
10592
10593
|
return getGroupingWithTimeDimension(attrs);
|
|
10593
10594
|
},
|
|
10594
|
-
maxAllowed:
|
|
10595
|
+
maxAllowed: 1,
|
|
10595
10596
|
testId: 'add-dimension'
|
|
10596
10597
|
}), namespace(CONSTANTS$l, 'sort'), namespace(CONSTANTS$l, 'filter'), namespace(CONSTANTS$l, 'custom_metrics'), namespace(CONSTANTS$l, 'limit')];
|
|
10597
10598
|
},
|
|
@@ -53141,6 +53142,246 @@ var SunburstChart$2 = function SunburstChart(props) {
|
|
|
53141
53142
|
});
|
|
53142
53143
|
};
|
|
53143
53144
|
|
|
53145
|
+
function getNiceInterval$3(interval) {
|
|
53146
|
+
// Round the interval to a "nice" value (1, 2, 5, etc.)
|
|
53147
|
+
var exponent = Math.floor(Math.log10(interval));
|
|
53148
|
+
var fraction = interval / Math.pow(10, exponent);
|
|
53149
|
+
var niceFraction;
|
|
53150
|
+
if (fraction <= 1.5) niceFraction = 1;else if (fraction <= 3) niceFraction = 2;else if (fraction <= 7) niceFraction = 5;else niceFraction = 10;
|
|
53151
|
+
return niceFraction * Math.pow(10, exponent);
|
|
53152
|
+
}
|
|
53153
|
+
|
|
53154
|
+
var getYTicks = function getYTicks(_ref) {
|
|
53155
|
+
var yMinValue = _ref.yMinValue,
|
|
53156
|
+
yMaxValue = _ref.yMaxValue,
|
|
53157
|
+
approxYAxisLabelCount = _ref.approxYAxisLabelCount,
|
|
53158
|
+
formattingFunctionY = _ref.formattingFunctionY;
|
|
53159
|
+
var yTicks = [];
|
|
53160
|
+
var yTickInterval = getNiceInterval$3((yMaxValue - yMinValue) / (approxYAxisLabelCount - 1));
|
|
53161
|
+
for (var i = 0; i < approxYAxisLabelCount; i++) {
|
|
53162
|
+
var value = (yMinValue + i) * yTickInterval;
|
|
53163
|
+
var formattedValue = formattingFunctionY(value);
|
|
53164
|
+
yTicks.push({
|
|
53165
|
+
value: value,
|
|
53166
|
+
formattedValue: formattedValue,
|
|
53167
|
+
scaleValue: value
|
|
53168
|
+
});
|
|
53169
|
+
}
|
|
53170
|
+
return yTicks;
|
|
53171
|
+
};
|
|
53172
|
+
|
|
53173
|
+
var getRepresentationData = function getRepresentationData(_ref) {
|
|
53174
|
+
var content = _ref.content,
|
|
53175
|
+
xKey = _ref.xKey,
|
|
53176
|
+
yKey = _ref.yKey,
|
|
53177
|
+
approxYAxisLabelCount = _ref.approxYAxisLabelCount,
|
|
53178
|
+
showTotalBar = _ref.showTotalBar,
|
|
53179
|
+
formattingFunctionY = _ref.formattingFunctionY;
|
|
53180
|
+
var data = [];
|
|
53181
|
+
var steps = [];
|
|
53182
|
+
var xTicks = [];
|
|
53183
|
+
var yValueSum = 0;
|
|
53184
|
+
var yMinValue = 0;
|
|
53185
|
+
var yMaxValue = 0;
|
|
53186
|
+
content.forEach(function (dataItem, index) {
|
|
53187
|
+
var _dataItem$xValueIndex, _dataItem$xValueIndex2, _dataItem$yValueIndex, _dataItem$yValueIndex2, _data$push;
|
|
53188
|
+
var xValueIndex = 0;
|
|
53189
|
+
var yValueIndex = 1;
|
|
53190
|
+
var xValue = (_dataItem$xValueIndex = dataItem[xValueIndex]) == null ? void 0 : _dataItem$xValueIndex.value;
|
|
53191
|
+
var xFormattedValue = (_dataItem$xValueIndex2 = dataItem[xValueIndex]) == null ? void 0 : _dataItem$xValueIndex2.formattedValue;
|
|
53192
|
+
var yValue = Number((_dataItem$yValueIndex = (_dataItem$yValueIndex2 = dataItem[yValueIndex]) == null ? void 0 : _dataItem$yValueIndex2.value) != null ? _dataItem$yValueIndex : 0);
|
|
53193
|
+
var yValueDiff = yValue;
|
|
53194
|
+
if (index > 0) {
|
|
53195
|
+
var _content$yValueIndex;
|
|
53196
|
+
var prevYValue = Number((_content$yValueIndex = content[index - 1][yValueIndex]) == null ? void 0 : _content$yValueIndex.value);
|
|
53197
|
+
yValueDiff = yValue - prevYValue;
|
|
53198
|
+
}
|
|
53199
|
+
var prevYValueSum = yValueSum;
|
|
53200
|
+
yValueSum += yValueDiff;
|
|
53201
|
+
data.push((_data$push = {}, _data$push[xKey] = {
|
|
53202
|
+
value: xValue,
|
|
53203
|
+
formattedValue: xFormattedValue
|
|
53204
|
+
}, _data$push[yKey] = {
|
|
53205
|
+
value: yValueDiff,
|
|
53206
|
+
formattedValue: formattingFunctionY(yValueDiff)
|
|
53207
|
+
}, _data$push));
|
|
53208
|
+
xTicks.push({
|
|
53209
|
+
value: xValue,
|
|
53210
|
+
formattedValue: xFormattedValue,
|
|
53211
|
+
scaleValue: xValue
|
|
53212
|
+
});
|
|
53213
|
+
steps.push({
|
|
53214
|
+
x: xValue,
|
|
53215
|
+
y: yValue,
|
|
53216
|
+
start: prevYValueSum,
|
|
53217
|
+
end: yValueSum
|
|
53218
|
+
});
|
|
53219
|
+
yMinValue = Math.floor(Math.min(yMinValue, yValue));
|
|
53220
|
+
yMaxValue = Math.ceil(Math.max(yMaxValue, yValue));
|
|
53221
|
+
});
|
|
53222
|
+
if (showTotalBar) {
|
|
53223
|
+
var _data$push2;
|
|
53224
|
+
var totalLabel = 'Total';
|
|
53225
|
+
steps.push({
|
|
53226
|
+
x: totalLabel,
|
|
53227
|
+
y: yValueSum,
|
|
53228
|
+
start: 0,
|
|
53229
|
+
end: yValueSum
|
|
53230
|
+
});
|
|
53231
|
+
data.push((_data$push2 = {}, _data$push2[xKey] = {
|
|
53232
|
+
value: totalLabel,
|
|
53233
|
+
formattedValue: totalLabel
|
|
53234
|
+
}, _data$push2[yKey] = {
|
|
53235
|
+
value: yValueSum,
|
|
53236
|
+
formattedValue: formattingFunctionY(yValueSum)
|
|
53237
|
+
}, _data$push2));
|
|
53238
|
+
xTicks.push({
|
|
53239
|
+
value: totalLabel,
|
|
53240
|
+
formattedValue: totalLabel,
|
|
53241
|
+
scaleValue: totalLabel
|
|
53242
|
+
});
|
|
53243
|
+
}
|
|
53244
|
+
var yTicks = getYTicks({
|
|
53245
|
+
yMinValue: yMinValue,
|
|
53246
|
+
yMaxValue: yMaxValue,
|
|
53247
|
+
approxYAxisLabelCount: approxYAxisLabelCount,
|
|
53248
|
+
formattingFunctionY: formattingFunctionY
|
|
53249
|
+
});
|
|
53250
|
+
return {
|
|
53251
|
+
data: data,
|
|
53252
|
+
steps: steps,
|
|
53253
|
+
xTicks: xTicks,
|
|
53254
|
+
yTicks: yTicks,
|
|
53255
|
+
yMinValue: yMinValue,
|
|
53256
|
+
yMaxValue: yMaxValue
|
|
53257
|
+
};
|
|
53258
|
+
};
|
|
53259
|
+
|
|
53260
|
+
var buildWaterfallChartRepresentation = function buildWaterfallChartRepresentation(_ref) {
|
|
53261
|
+
var _formattedResult$fiel, _formattedResult$fiel2, _axisTitles$x, _axisTitles$y;
|
|
53262
|
+
var approxYAxisLabelCount = _ref.approxYAxisLabelCount,
|
|
53263
|
+
axisTitles = _ref.axisTitles,
|
|
53264
|
+
dateTimeFormatOptions = _ref.dateTimeFormatOptions,
|
|
53265
|
+
defaultFormats = _ref.defaultFormats,
|
|
53266
|
+
nullValue = _ref.nullValue,
|
|
53267
|
+
numberFormatOptions = _ref.numberFormatOptions,
|
|
53268
|
+
pivotConfig = _ref.pivotConfig,
|
|
53269
|
+
result = _ref.result,
|
|
53270
|
+
showTotalBar = _ref.showTotalBar,
|
|
53271
|
+
_valueAlias = _ref.valueAlias,
|
|
53272
|
+
xAxisFormat = _ref.xAxisFormat,
|
|
53273
|
+
xAxisPrefix = _ref.xAxisPrefix,
|
|
53274
|
+
xAxisPostfix = _ref.xAxisPostfix,
|
|
53275
|
+
yAxisFormat = _ref.yAxisFormat,
|
|
53276
|
+
yAxisPrefix = _ref.yAxisPrefix,
|
|
53277
|
+
yAxisPostfix = _ref.yAxisPostfix;
|
|
53278
|
+
var activeDateTimeFormats = {};
|
|
53279
|
+
var _buildFieldFormatMaps = buildFieldFormatMaps(result, pivotConfig, xAxisPrefix, xAxisPostfix, xAxisFormat, yAxisPrefix, yAxisPostfix, yAxisFormat, nullValue, numberFormatOptions),
|
|
53280
|
+
allPrefixes = _buildFieldFormatMaps.allPrefixes,
|
|
53281
|
+
allPostfixes = _buildFieldFormatMaps.allPostfixes,
|
|
53282
|
+
nullValues = _buildFieldFormatMaps.nullValues,
|
|
53283
|
+
activeNumberFormats = _buildFieldFormatMaps.activeNumberFormats;
|
|
53284
|
+
var params = {
|
|
53285
|
+
defaultFormats: defaultFormats,
|
|
53286
|
+
dateTimeFormatOptions: dateTimeFormatOptions,
|
|
53287
|
+
numberFormatOptions: numberFormatOptions,
|
|
53288
|
+
valueAlias: function valueAlias(params) {
|
|
53289
|
+
if (typeof _valueAlias === 'function') {
|
|
53290
|
+
return String(_valueAlias({
|
|
53291
|
+
fieldId: id({
|
|
53292
|
+
field: params.fieldId,
|
|
53293
|
+
"function": params["function"]
|
|
53294
|
+
}),
|
|
53295
|
+
value: params.value
|
|
53296
|
+
}));
|
|
53297
|
+
}
|
|
53298
|
+
return undefined;
|
|
53299
|
+
},
|
|
53300
|
+
nullValue: nullValues,
|
|
53301
|
+
prefixes: allPrefixes,
|
|
53302
|
+
postfixes: allPostfixes,
|
|
53303
|
+
activeNumberFormats: activeNumberFormats,
|
|
53304
|
+
activeDateTimeFormats: activeDateTimeFormats
|
|
53305
|
+
};
|
|
53306
|
+
var formattedResult = formatResult(result, params);
|
|
53307
|
+
var formattingFunctionY = function formattingFunctionY(value) {
|
|
53308
|
+
// Use any y axis field as they are all formatted in the same way (for now...);
|
|
53309
|
+
var nonPivotField = formattedResult.fields.find(function (resultField) {
|
|
53310
|
+
return ![].concat(pivotConfig.x, pivotConfig.y).includes(resultField.id);
|
|
53311
|
+
});
|
|
53312
|
+
if (!nonPivotField) return '';
|
|
53313
|
+
return formattedResult.formatterFunc(value, {
|
|
53314
|
+
fieldId: nonPivotField.fieldId,
|
|
53315
|
+
"function": nonPivotField["function"],
|
|
53316
|
+
outputDataType: nonPivotField.outputDataType
|
|
53317
|
+
}).formattedValue;
|
|
53318
|
+
};
|
|
53319
|
+
var keys = formattedResult.fields.map(function (field) {
|
|
53320
|
+
var _ref2;
|
|
53321
|
+
var key = field.fieldId;
|
|
53322
|
+
var keyFormatted = field.publicName;
|
|
53323
|
+
var dataType = field.dataType;
|
|
53324
|
+
return _ref2 = {}, _ref2[key] = {
|
|
53325
|
+
key: key,
|
|
53326
|
+
keyFormatted: keyFormatted,
|
|
53327
|
+
dataType: dataType
|
|
53328
|
+
}, _ref2;
|
|
53329
|
+
});
|
|
53330
|
+
var xKey = (_formattedResult$fiel = formattedResult.fields[0]) == null ? void 0 : _formattedResult$fiel.fieldId;
|
|
53331
|
+
var yKey = (_formattedResult$fiel2 = formattedResult.fields[1]) == null ? void 0 : _formattedResult$fiel2.fieldId;
|
|
53332
|
+
var content = formattedResult.content;
|
|
53333
|
+
var _getRepresentationDat = getRepresentationData({
|
|
53334
|
+
content: content,
|
|
53335
|
+
xKey: xKey,
|
|
53336
|
+
yKey: yKey,
|
|
53337
|
+
approxYAxisLabelCount: approxYAxisLabelCount,
|
|
53338
|
+
showTotalBar: showTotalBar,
|
|
53339
|
+
formattingFunctionY: formattingFunctionY
|
|
53340
|
+
}),
|
|
53341
|
+
data = _getRepresentationDat.data,
|
|
53342
|
+
steps = _getRepresentationDat.steps,
|
|
53343
|
+
xTicks = _getRepresentationDat.xTicks,
|
|
53344
|
+
yTicks = _getRepresentationDat.yTicks,
|
|
53345
|
+
yMinValue = _getRepresentationDat.yMinValue,
|
|
53346
|
+
yMaxValue = _getRepresentationDat.yMaxValue;
|
|
53347
|
+
var chartRepresentation = {
|
|
53348
|
+
keys: _extends({}, keys[0], keys[1]),
|
|
53349
|
+
x: {
|
|
53350
|
+
title: (_axisTitles$x = axisTitles == null ? void 0 : axisTitles.x) != null ? _axisTitles$x : null,
|
|
53351
|
+
ticks: xTicks,
|
|
53352
|
+
prefix: xAxisPrefix,
|
|
53353
|
+
postfix: xAxisPostfix,
|
|
53354
|
+
key: xKey,
|
|
53355
|
+
scale: {
|
|
53356
|
+
dataType: 'string',
|
|
53357
|
+
key: xKey,
|
|
53358
|
+
ordering: null,
|
|
53359
|
+
min: null,
|
|
53360
|
+
max: null
|
|
53361
|
+
}
|
|
53362
|
+
},
|
|
53363
|
+
y: {
|
|
53364
|
+
title: (_axisTitles$y = axisTitles == null ? void 0 : axisTitles.y) != null ? _axisTitles$y : null,
|
|
53365
|
+
ticks: yTicks,
|
|
53366
|
+
key: yKey,
|
|
53367
|
+
prefix: yAxisPrefix,
|
|
53368
|
+
postfix: yAxisPostfix,
|
|
53369
|
+
scale: {
|
|
53370
|
+
dataType: 'number',
|
|
53371
|
+
key: null,
|
|
53372
|
+
ordering: 'asc',
|
|
53373
|
+
min: yMinValue,
|
|
53374
|
+
max: yMaxValue
|
|
53375
|
+
}
|
|
53376
|
+
},
|
|
53377
|
+
data: data
|
|
53378
|
+
};
|
|
53379
|
+
return {
|
|
53380
|
+
waterfallChartRepresentation: chartRepresentation,
|
|
53381
|
+
waterfallChartSteps: steps
|
|
53382
|
+
};
|
|
53383
|
+
};
|
|
53384
|
+
|
|
53144
53385
|
var ASSUMED_AVERAGE_CHAR_WIDTH$2 = 8.8;
|
|
53145
53386
|
function calculateWordWidth$1(word, avgCharWidth) {
|
|
53146
53387
|
if (avgCharWidth === void 0) {
|
|
@@ -53242,7 +53483,7 @@ var Tooltip$2 = function Tooltip(_ref) {
|
|
|
53242
53483
|
if (!showTooltip || !tooltipData) return null;
|
|
53243
53484
|
var value = tooltipData[yKey].value;
|
|
53244
53485
|
var isPositiveValue = Number(value) > 0;
|
|
53245
|
-
return jsx(TooltipWithBounds, {
|
|
53486
|
+
return /*#__PURE__*/createPortal(jsx(TooltipWithBounds, {
|
|
53246
53487
|
left: tooltipLeft,
|
|
53247
53488
|
top: tooltipTop,
|
|
53248
53489
|
style: theme,
|
|
@@ -53277,7 +53518,7 @@ var Tooltip$2 = function Tooltip(_ref) {
|
|
|
53277
53518
|
})]
|
|
53278
53519
|
})]
|
|
53279
53520
|
})
|
|
53280
|
-
}, Math.random());
|
|
53521
|
+
}, Math.random()), document.body);
|
|
53281
53522
|
};
|
|
53282
53523
|
var IconNarrowRight$1 = function IconNarrowRight() {
|
|
53283
53524
|
var style = {
|
|
@@ -53285,7 +53526,7 @@ var IconNarrowRight$1 = function IconNarrowRight() {
|
|
|
53285
53526
|
height: 20,
|
|
53286
53527
|
display: 'block'
|
|
53287
53528
|
};
|
|
53288
|
-
var fill =
|
|
53529
|
+
var fill = '#12B76A';
|
|
53289
53530
|
return jsx("svg", {
|
|
53290
53531
|
fill: "none",
|
|
53291
53532
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -53305,7 +53546,7 @@ var IconTrendingDown$1 = function IconTrendingDown() {
|
|
|
53305
53546
|
height: 20,
|
|
53306
53547
|
display: 'block'
|
|
53307
53548
|
};
|
|
53308
|
-
var fill =
|
|
53549
|
+
var fill = '#F04438';
|
|
53309
53550
|
return jsx("svg", {
|
|
53310
53551
|
fill: "none",
|
|
53311
53552
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -53473,8 +53714,8 @@ var WaterfallChart$2 = function WaterfallChart(_ref) {
|
|
|
53473
53714
|
return Number(tick.value);
|
|
53474
53715
|
});
|
|
53475
53716
|
var xTickValues = formattedChartDataForBarChart.x.ticks.length > 0 ? formattedChartDataForBarChart.x.ticks.map(function (tick) {
|
|
53476
|
-
var
|
|
53477
|
-
return (
|
|
53717
|
+
var _String;
|
|
53718
|
+
return (_String = String(tick.scaleValue)) != null ? _String : '';
|
|
53478
53719
|
}) : undefined;
|
|
53479
53720
|
var handleMouseMove = useCallback(function (event) {
|
|
53480
53721
|
if (!xKey || !xScaleKey || xScale === null) return;
|
|
@@ -53507,7 +53748,7 @@ var WaterfallChart$2 = function WaterfallChart(_ref) {
|
|
|
53507
53748
|
tick = matchingTickValue || null;
|
|
53508
53749
|
} else {
|
|
53509
53750
|
var _matchingTickValue = formattedChartDataForBarChart.x.ticks.find(function (tickValue) {
|
|
53510
|
-
return tickValue.scaleValue === value;
|
|
53751
|
+
return String(tickValue.scaleValue) === value;
|
|
53511
53752
|
});
|
|
53512
53753
|
tick = _matchingTickValue || null;
|
|
53513
53754
|
}
|
|
@@ -53532,10 +53773,10 @@ var WaterfallChart$2 = function WaterfallChart(_ref) {
|
|
|
53532
53773
|
return '';
|
|
53533
53774
|
}, [formattedChartDataForBarChart.y.ticks]);
|
|
53534
53775
|
var getBarGroupPosition = useCallback(function (d) {
|
|
53535
|
-
if (xScaleKey == null || d == null) return;
|
|
53776
|
+
if (xScaleKey == null || d == null) return '';
|
|
53536
53777
|
var xValue = d[xScaleKey];
|
|
53537
|
-
if (xScaleDataType === 'string') return xValue;
|
|
53538
|
-
return;
|
|
53778
|
+
if (xScaleDataType === 'string') return String(xValue);
|
|
53779
|
+
return '';
|
|
53539
53780
|
}, [xScaleKey, xScaleDataType]);
|
|
53540
53781
|
if (width === 0 || height === 0 || xScale == null) return null;
|
|
53541
53782
|
return jsxs(Fragment$1, {
|
|
@@ -53685,245 +53926,6 @@ var Bar$2 = function Bar(_ref4) {
|
|
|
53685
53926
|
});
|
|
53686
53927
|
};
|
|
53687
53928
|
|
|
53688
|
-
function getNiceInterval$3(interval) {
|
|
53689
|
-
// Round the interval to a "nice" value (1, 2, 5, etc.)
|
|
53690
|
-
var exponent = Math.floor(Math.log10(interval));
|
|
53691
|
-
var fraction = interval / Math.pow(10, exponent);
|
|
53692
|
-
var niceFraction;
|
|
53693
|
-
if (fraction <= 1.5) niceFraction = 1;else if (fraction <= 3) niceFraction = 2;else if (fraction <= 7) niceFraction = 5;else niceFraction = 10;
|
|
53694
|
-
return niceFraction * Math.pow(10, exponent);
|
|
53695
|
-
}
|
|
53696
|
-
|
|
53697
|
-
var getYTicks = function getYTicks(_ref) {
|
|
53698
|
-
var yMinValue = _ref.yMinValue,
|
|
53699
|
-
yMaxValue = _ref.yMaxValue,
|
|
53700
|
-
approxYAxisLabelCount = _ref.approxYAxisLabelCount,
|
|
53701
|
-
formattingFunctionY = _ref.formattingFunctionY;
|
|
53702
|
-
var yTicks = [];
|
|
53703
|
-
var yTickInterval = getNiceInterval$3((yMaxValue - yMinValue) / (approxYAxisLabelCount - 1));
|
|
53704
|
-
for (var i = 0; i < approxYAxisLabelCount; i++) {
|
|
53705
|
-
var value = (yMinValue + i) * yTickInterval;
|
|
53706
|
-
var formattedValue = formattingFunctionY(value);
|
|
53707
|
-
yTicks.push({
|
|
53708
|
-
value: value,
|
|
53709
|
-
formattedValue: formattedValue,
|
|
53710
|
-
scaleValue: value
|
|
53711
|
-
});
|
|
53712
|
-
}
|
|
53713
|
-
return yTicks;
|
|
53714
|
-
};
|
|
53715
|
-
|
|
53716
|
-
var getRepresentationData = function getRepresentationData(_ref) {
|
|
53717
|
-
var content = _ref.content,
|
|
53718
|
-
xKey = _ref.xKey,
|
|
53719
|
-
yKey = _ref.yKey,
|
|
53720
|
-
approxYAxisLabelCount = _ref.approxYAxisLabelCount,
|
|
53721
|
-
showTotalBar = _ref.showTotalBar,
|
|
53722
|
-
formattingFunctionY = _ref.formattingFunctionY;
|
|
53723
|
-
var data = [];
|
|
53724
|
-
var steps = [];
|
|
53725
|
-
var xTicks = [];
|
|
53726
|
-
var yValueSum = 0;
|
|
53727
|
-
var yMinValue = 0;
|
|
53728
|
-
var yMaxValue = 0;
|
|
53729
|
-
content.forEach(function (dataItem, index) {
|
|
53730
|
-
var _data$push;
|
|
53731
|
-
var xValueIndex = 0;
|
|
53732
|
-
var yValueIndex = 1;
|
|
53733
|
-
var xValue = dataItem[xValueIndex].value;
|
|
53734
|
-
var xFormattedValue = dataItem[xValueIndex].formattedValue;
|
|
53735
|
-
var yValue = Number(dataItem[yValueIndex].value);
|
|
53736
|
-
var yValueDiff = yValue;
|
|
53737
|
-
if (index > 0) {
|
|
53738
|
-
var prevYValue = Number(content[index - 1][yValueIndex].value);
|
|
53739
|
-
yValueDiff = yValue - prevYValue;
|
|
53740
|
-
}
|
|
53741
|
-
var prevYValueSum = yValueSum;
|
|
53742
|
-
yValueSum += yValueDiff;
|
|
53743
|
-
data.push((_data$push = {}, _data$push[xKey] = {
|
|
53744
|
-
value: xValue,
|
|
53745
|
-
formattedValue: xFormattedValue
|
|
53746
|
-
}, _data$push[yKey] = {
|
|
53747
|
-
value: yValueDiff,
|
|
53748
|
-
formattedValue: formattingFunctionY(yValueDiff)
|
|
53749
|
-
}, _data$push));
|
|
53750
|
-
xTicks.push({
|
|
53751
|
-
value: xValue,
|
|
53752
|
-
formattedValue: xFormattedValue,
|
|
53753
|
-
scaleValue: xValue
|
|
53754
|
-
});
|
|
53755
|
-
steps.push({
|
|
53756
|
-
x: xValue,
|
|
53757
|
-
y: yValue,
|
|
53758
|
-
start: prevYValueSum,
|
|
53759
|
-
end: yValueSum
|
|
53760
|
-
});
|
|
53761
|
-
yMinValue = Math.floor(Math.min(yMinValue, yValue));
|
|
53762
|
-
yMaxValue = Math.ceil(Math.max(yMaxValue, yValue));
|
|
53763
|
-
});
|
|
53764
|
-
if (showTotalBar) {
|
|
53765
|
-
var _data$push2;
|
|
53766
|
-
var totalLabel = 'Total';
|
|
53767
|
-
steps.push({
|
|
53768
|
-
x: totalLabel,
|
|
53769
|
-
y: yValueSum,
|
|
53770
|
-
start: 0,
|
|
53771
|
-
end: yValueSum
|
|
53772
|
-
});
|
|
53773
|
-
data.push((_data$push2 = {}, _data$push2[xKey] = {
|
|
53774
|
-
value: totalLabel,
|
|
53775
|
-
formattedValue: totalLabel
|
|
53776
|
-
}, _data$push2[yKey] = {
|
|
53777
|
-
value: yValueSum,
|
|
53778
|
-
formattedValue: formattingFunctionY(yValueSum)
|
|
53779
|
-
}, _data$push2));
|
|
53780
|
-
xTicks.push({
|
|
53781
|
-
value: totalLabel,
|
|
53782
|
-
formattedValue: totalLabel,
|
|
53783
|
-
scaleValue: totalLabel
|
|
53784
|
-
});
|
|
53785
|
-
}
|
|
53786
|
-
var yTicks = getYTicks({
|
|
53787
|
-
yMinValue: yMinValue,
|
|
53788
|
-
yMaxValue: yMaxValue,
|
|
53789
|
-
approxYAxisLabelCount: approxYAxisLabelCount,
|
|
53790
|
-
formattingFunctionY: formattingFunctionY
|
|
53791
|
-
});
|
|
53792
|
-
return {
|
|
53793
|
-
data: data,
|
|
53794
|
-
steps: steps,
|
|
53795
|
-
xTicks: xTicks,
|
|
53796
|
-
yTicks: yTicks,
|
|
53797
|
-
yMinValue: yMinValue,
|
|
53798
|
-
yMaxValue: yMaxValue
|
|
53799
|
-
};
|
|
53800
|
-
};
|
|
53801
|
-
|
|
53802
|
-
var buildWaterfallChartRepresentation = function buildWaterfallChartRepresentation(_ref) {
|
|
53803
|
-
var _formattedResult$fiel, _formattedResult$fiel2, _axisTitles$x, _axisTitles$y;
|
|
53804
|
-
var approxYAxisLabelCount = _ref.approxYAxisLabelCount,
|
|
53805
|
-
axisTitles = _ref.axisTitles,
|
|
53806
|
-
dateTimeFormatOptions = _ref.dateTimeFormatOptions,
|
|
53807
|
-
defaultFormats = _ref.defaultFormats,
|
|
53808
|
-
nullValue = _ref.nullValue,
|
|
53809
|
-
numberFormatOptions = _ref.numberFormatOptions,
|
|
53810
|
-
pivotConfig = _ref.pivotConfig,
|
|
53811
|
-
result = _ref.result,
|
|
53812
|
-
showTotalBar = _ref.showTotalBar,
|
|
53813
|
-
_valueAlias = _ref.valueAlias,
|
|
53814
|
-
xAxisFormat = _ref.xAxisFormat,
|
|
53815
|
-
xAxisPrefix = _ref.xAxisPrefix,
|
|
53816
|
-
xAxisPostfix = _ref.xAxisPostfix,
|
|
53817
|
-
yAxisFormat = _ref.yAxisFormat,
|
|
53818
|
-
yAxisPrefix = _ref.yAxisPrefix,
|
|
53819
|
-
yAxisPostfix = _ref.yAxisPostfix;
|
|
53820
|
-
var activeDateTimeFormats = {};
|
|
53821
|
-
var _buildFieldFormatMaps = buildFieldFormatMaps(result, pivotConfig, xAxisPrefix, xAxisPostfix, xAxisFormat, yAxisPrefix, yAxisPostfix, yAxisFormat, nullValue, numberFormatOptions),
|
|
53822
|
-
allPrefixes = _buildFieldFormatMaps.allPrefixes,
|
|
53823
|
-
allPostfixes = _buildFieldFormatMaps.allPostfixes,
|
|
53824
|
-
nullValues = _buildFieldFormatMaps.nullValues,
|
|
53825
|
-
activeNumberFormats = _buildFieldFormatMaps.activeNumberFormats;
|
|
53826
|
-
var params = {
|
|
53827
|
-
defaultFormats: defaultFormats,
|
|
53828
|
-
dateTimeFormatOptions: dateTimeFormatOptions,
|
|
53829
|
-
numberFormatOptions: numberFormatOptions,
|
|
53830
|
-
valueAlias: function valueAlias(params) {
|
|
53831
|
-
if (typeof _valueAlias === 'function') {
|
|
53832
|
-
return String(_valueAlias({
|
|
53833
|
-
fieldId: id({
|
|
53834
|
-
field: params.fieldId,
|
|
53835
|
-
"function": params["function"]
|
|
53836
|
-
}),
|
|
53837
|
-
value: params.value
|
|
53838
|
-
}));
|
|
53839
|
-
}
|
|
53840
|
-
return undefined;
|
|
53841
|
-
},
|
|
53842
|
-
nullValue: nullValues,
|
|
53843
|
-
prefixes: allPrefixes,
|
|
53844
|
-
postfixes: allPostfixes,
|
|
53845
|
-
activeNumberFormats: activeNumberFormats,
|
|
53846
|
-
activeDateTimeFormats: activeDateTimeFormats
|
|
53847
|
-
};
|
|
53848
|
-
var formattedResult = formatResult(result, params);
|
|
53849
|
-
var formattingFunctionY = function formattingFunctionY(value) {
|
|
53850
|
-
// Use any y axis field as they are all formatted in the same way (for now...);
|
|
53851
|
-
var nonPivotField = formattedResult.fields.find(function (resultField) {
|
|
53852
|
-
return ![].concat(pivotConfig.x, pivotConfig.y).includes(resultField.id);
|
|
53853
|
-
});
|
|
53854
|
-
if (!nonPivotField) return '';
|
|
53855
|
-
return formattedResult.formatterFunc(value, {
|
|
53856
|
-
fieldId: nonPivotField.fieldId,
|
|
53857
|
-
"function": nonPivotField["function"],
|
|
53858
|
-
outputDataType: nonPivotField.outputDataType
|
|
53859
|
-
}).formattedValue;
|
|
53860
|
-
};
|
|
53861
|
-
var keys = formattedResult.fields.map(function (field) {
|
|
53862
|
-
var _ref2;
|
|
53863
|
-
var key = field.fieldId;
|
|
53864
|
-
var keyFormatted = field.publicName;
|
|
53865
|
-
var dataType = field.dataType;
|
|
53866
|
-
return _ref2 = {}, _ref2[key] = {
|
|
53867
|
-
key: key,
|
|
53868
|
-
keyFormatted: keyFormatted,
|
|
53869
|
-
dataType: dataType
|
|
53870
|
-
}, _ref2;
|
|
53871
|
-
});
|
|
53872
|
-
var xKey = (_formattedResult$fiel = formattedResult.fields[0]) == null ? void 0 : _formattedResult$fiel.fieldId;
|
|
53873
|
-
var yKey = (_formattedResult$fiel2 = formattedResult.fields[1]) == null ? void 0 : _formattedResult$fiel2.fieldId;
|
|
53874
|
-
var content = formattedResult.content;
|
|
53875
|
-
var _getRepresentationDat = getRepresentationData({
|
|
53876
|
-
content: content,
|
|
53877
|
-
xKey: xKey,
|
|
53878
|
-
yKey: yKey,
|
|
53879
|
-
approxYAxisLabelCount: approxYAxisLabelCount,
|
|
53880
|
-
showTotalBar: showTotalBar,
|
|
53881
|
-
formattingFunctionY: formattingFunctionY
|
|
53882
|
-
}),
|
|
53883
|
-
data = _getRepresentationDat.data,
|
|
53884
|
-
steps = _getRepresentationDat.steps,
|
|
53885
|
-
xTicks = _getRepresentationDat.xTicks,
|
|
53886
|
-
yTicks = _getRepresentationDat.yTicks,
|
|
53887
|
-
yMinValue = _getRepresentationDat.yMinValue,
|
|
53888
|
-
yMaxValue = _getRepresentationDat.yMaxValue;
|
|
53889
|
-
var chartRepresentation = {
|
|
53890
|
-
keys: _extends({}, keys[0], keys[1]),
|
|
53891
|
-
x: {
|
|
53892
|
-
title: (_axisTitles$x = axisTitles == null ? void 0 : axisTitles.x) != null ? _axisTitles$x : null,
|
|
53893
|
-
ticks: xTicks,
|
|
53894
|
-
prefix: xAxisPrefix,
|
|
53895
|
-
postfix: xAxisPostfix,
|
|
53896
|
-
key: xKey,
|
|
53897
|
-
scale: {
|
|
53898
|
-
dataType: 'string',
|
|
53899
|
-
key: xKey,
|
|
53900
|
-
ordering: null,
|
|
53901
|
-
min: null,
|
|
53902
|
-
max: null
|
|
53903
|
-
}
|
|
53904
|
-
},
|
|
53905
|
-
y: {
|
|
53906
|
-
title: (_axisTitles$y = axisTitles == null ? void 0 : axisTitles.y) != null ? _axisTitles$y : null,
|
|
53907
|
-
ticks: yTicks,
|
|
53908
|
-
key: yKey,
|
|
53909
|
-
prefix: yAxisPrefix,
|
|
53910
|
-
postfix: yAxisPostfix,
|
|
53911
|
-
scale: {
|
|
53912
|
-
dataType: 'number',
|
|
53913
|
-
key: null,
|
|
53914
|
-
ordering: 'asc',
|
|
53915
|
-
min: yMinValue,
|
|
53916
|
-
max: yMaxValue
|
|
53917
|
-
}
|
|
53918
|
-
},
|
|
53919
|
-
data: data
|
|
53920
|
-
};
|
|
53921
|
-
return {
|
|
53922
|
-
waterfallChartRepresentation: chartRepresentation,
|
|
53923
|
-
waterfallChartSteps: steps
|
|
53924
|
-
};
|
|
53925
|
-
};
|
|
53926
|
-
|
|
53927
53929
|
var WaterfallChartView = function WaterfallChartView(props) {
|
|
53928
53930
|
var approxXAxisLabelCount = props.approxXAxisLabelCount,
|
|
53929
53931
|
approxYAxisLabelCount = props.approxYAxisLabelCount,
|
|
@@ -53991,6 +53993,7 @@ var WaterfallChartView = function WaterfallChartView(props) {
|
|
|
53991
53993
|
title: "Missing parameters"
|
|
53992
53994
|
});
|
|
53993
53995
|
if (isLoading(result)) return jsx(LoadingComponent, {});
|
|
53996
|
+
if (isLoadingResult(result)) return jsx(LoadingComponent, {});
|
|
53994
53997
|
if (hasFailed(result)) return jsx(FailedToLoadDataNotice, {});
|
|
53995
53998
|
if (isEmpty(result)) return jsx(NoResultContentToShowNotice, _extends({}, headerProps));
|
|
53996
53999
|
var showHeadline = headlineAvailable(order, headline, timeDimension);
|
|
@@ -54061,6 +54064,9 @@ var WaterfallChartView = function WaterfallChartView(props) {
|
|
|
54061
54064
|
})
|
|
54062
54065
|
});
|
|
54063
54066
|
};
|
|
54067
|
+
function isLoadingResult(result) {
|
|
54068
|
+
return result != null && result.content[0].length ? (result == null ? void 0 : result.content[0].length) < 2 : false;
|
|
54069
|
+
}
|
|
54064
54070
|
var WaterfallChartView$1 = /*#__PURE__*/memo(WaterfallChartView, shouldUpdate);
|
|
54065
54071
|
|
|
54066
54072
|
var WaterfallChart$3 = function WaterfallChart(_ref) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { VizzlyComponents } from '../../types';
|
|
1
|
+
/// <reference types="react" />
|
|
3
2
|
import { Component } from '../../../../shared-logic/src/Component/types';
|
|
3
|
+
import { VizzlyComponents } from '../../types';
|
|
4
4
|
export declare type WaterfallChartViewProps = VizzlyComponents.ViewProps<Component.WaterfallChartAttributes>;
|
|
5
|
-
declare const _default:
|
|
5
|
+
declare const _default: import("react").NamedExoticComponent<VizzlyComponents.ViewProps<Component.WaterfallChartAttributes, import("../../../../shared-logic/src/Component/types").Component.Attributes>>;
|
|
6
6
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizzly/dashboard",
|
|
3
3
|
"author": "james@vizzly.co",
|
|
4
|
-
"version": "0.15.0-dev-
|
|
4
|
+
"version": "0.15.0-dev-65c3e5d7491389a56cc8409b046f92683dd4725f",
|
|
5
5
|
"source": "src/index.tsx",
|
|
6
6
|
"types": "./dist/dashboard/src/index.d.ts",
|
|
7
7
|
"module": "./dist/dashboard.esm.js",
|