@vizzly/dashboard 0.14.4-dev-28ace990f8935dcd353f0b09527a2a1b32940e13 → 0.14.4-dev-dacb7b6ee19300aa636d654c99f13d6ac43da830
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/dashboard.esm.js
CHANGED
|
@@ -28,7 +28,7 @@ import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/elemen
|
|
|
28
28
|
import { dropTargetForExternal } from '@atlaskit/pragmatic-drag-and-drop/external/adapter';
|
|
29
29
|
import { DropIndicator } from '@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box';
|
|
30
30
|
import { ParentSize } from '@visx/responsive';
|
|
31
|
-
import { Annotation, AnnotationConnector, AnnotationLabel, DataContext, buildChartTheme, lightTheme, XYChart, Grid as Grid$1, Axis, AreaSeries, AreaStack, BarGroup, BarSeries, BarStack, GlyphSeries, LineSeries, Tooltip as Tooltip$
|
|
31
|
+
import { Annotation, AnnotationConnector, AnnotationLabel, DataContext, buildChartTheme, lightTheme, XYChart, Grid as Grid$1, Axis, AreaSeries, AreaStack, BarGroup, BarSeries, BarStack, GlyphSeries, LineSeries, Tooltip as Tooltip$3 } from '@visx/xychart';
|
|
32
32
|
import { LinearGradient } from '@visx/gradient';
|
|
33
33
|
import { LegendItem as LegendItem$1, LegendLabel } from '@visx/legend';
|
|
34
34
|
import { scaleOrdinal, scaleQuantize, scalePoint, scaleTime, scaleLinear, scaleBand } from '@visx/scale';
|
|
@@ -55,7 +55,6 @@ import { AxisBottom as AxisBottom$1, AxisLeft as AxisLeft$1 } from '@visx/axis';
|
|
|
55
55
|
import { Text } from '@visx/text';
|
|
56
56
|
import { GridRows as GridRows$1 } from '@visx/grid';
|
|
57
57
|
import '@visx/point';
|
|
58
|
-
import { WaterfallChart as WaterfallChart$4 } from './charts/src/v2/components/WaterfallChart';
|
|
59
58
|
import VisibilitySensor from 'react-visibility-sensor';
|
|
60
59
|
import ExcelJS from 'exceljs';
|
|
61
60
|
import { saveAs } from 'file-saver';
|
|
@@ -32144,7 +32143,7 @@ var VizzlyXYChart = function VizzlyXYChart(props) {
|
|
|
32144
32143
|
}, "area_lines_" + props.uniqueId + "_" + indexOne + "_" + indexTwo);
|
|
32145
32144
|
})
|
|
32146
32145
|
}, "area_lines_" + props.uniqueId + "_" + indexOne);
|
|
32147
|
-
}), props != null && (_props$bars14 = props.bars) != null && _props$bars14.funnelChart ? jsx(Tooltip$
|
|
32146
|
+
}), props != null && (_props$bars14 = props.bars) != null && _props$bars14.funnelChart ? jsx(Tooltip$3, {
|
|
32148
32147
|
showVerticalCrosshair: true,
|
|
32149
32148
|
showSeriesGlyphs: true,
|
|
32150
32149
|
style: tooltipStyles,
|
|
@@ -32175,7 +32174,7 @@ var VizzlyXYChart = function VizzlyXYChart(props) {
|
|
|
32175
32174
|
formatValue: formatYAxisLabel$1(props)
|
|
32176
32175
|
});
|
|
32177
32176
|
}
|
|
32178
|
-
}) : jsx(Tooltip$
|
|
32177
|
+
}) : jsx(Tooltip$3, {
|
|
32179
32178
|
showVerticalCrosshair: true,
|
|
32180
32179
|
style: tooltipStyles,
|
|
32181
32180
|
showSeriesGlyphs: props.bars == undefined,
|
|
@@ -46860,6 +46859,608 @@ var BarChartV2 = function BarChartV2(props) {
|
|
|
46860
46859
|
});
|
|
46861
46860
|
};
|
|
46862
46861
|
|
|
46862
|
+
function getBarFill$1(bars, conditionalFormattingRules, barKey, barValues) {
|
|
46863
|
+
var _bars$find;
|
|
46864
|
+
// Default fill color from the corresponding bar
|
|
46865
|
+
var fill = (_bars$find = bars.find(function (chartBar) {
|
|
46866
|
+
return chartBar.yKey === barKey;
|
|
46867
|
+
})) == null ? void 0 : _bars$find.color;
|
|
46868
|
+
|
|
46869
|
+
// Determine the value based on barValues type
|
|
46870
|
+
var value = typeof barValues === 'number' ? barValues : barValues == null ? void 0 : barValues[barKey];
|
|
46871
|
+
if (typeof value === 'number') {
|
|
46872
|
+
for (var _iterator = _createForOfIteratorHelperLoose(conditionalFormattingRules), _step; !(_step = _iterator()).done;) {
|
|
46873
|
+
var rule = _step.value;
|
|
46874
|
+
if (compare({
|
|
46875
|
+
op: rule.operator,
|
|
46876
|
+
value: rule.value
|
|
46877
|
+
}, value)) {
|
|
46878
|
+
fill = rule.color;
|
|
46879
|
+
break;
|
|
46880
|
+
}
|
|
46881
|
+
}
|
|
46882
|
+
}
|
|
46883
|
+
return fill;
|
|
46884
|
+
}
|
|
46885
|
+
|
|
46886
|
+
var ASSUMED_AVERAGE_CHAR_WIDTH$2 = 8.8;
|
|
46887
|
+
function calculateWordWidth$2(word, avgCharWidth) {
|
|
46888
|
+
if (avgCharWidth === void 0) {
|
|
46889
|
+
avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH$2;
|
|
46890
|
+
}
|
|
46891
|
+
return word.length * avgCharWidth;
|
|
46892
|
+
}
|
|
46893
|
+
|
|
46894
|
+
/** Reduce width proportionally to simulate spacing / padding between ticks. */
|
|
46895
|
+
var widthWithSpacing$2 = function widthWithSpacing(width) {
|
|
46896
|
+
var THIRTY_PERCENT = 0.3;
|
|
46897
|
+
return width - width * THIRTY_PERCENT;
|
|
46898
|
+
};
|
|
46899
|
+
function howManyTicksFitInWidth$2(ticks, maxWidth, avgCharWidth) {
|
|
46900
|
+
if (avgCharWidth === void 0) {
|
|
46901
|
+
avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH$2;
|
|
46902
|
+
}
|
|
46903
|
+
var fittedTicks = [];
|
|
46904
|
+
var currentWidth = 0;
|
|
46905
|
+
for (var _iterator = _createForOfIteratorHelperLoose(ticks), _step; !(_step = _iterator()).done;) {
|
|
46906
|
+
var tick = _step.value;
|
|
46907
|
+
var word = (tick == null ? void 0 : tick.formattedValue) || '';
|
|
46908
|
+
var wordWidth = calculateWordWidth$2(word, avgCharWidth);
|
|
46909
|
+
if (currentWidth + wordWidth <= widthWithSpacing$2(maxWidth)) {
|
|
46910
|
+
fittedTicks.push(tick);
|
|
46911
|
+
currentWidth += wordWidth + avgCharWidth; // Add space between words
|
|
46912
|
+
} else {
|
|
46913
|
+
break; // Stop if adding the word exceeds maxWidth
|
|
46914
|
+
}
|
|
46915
|
+
}
|
|
46916
|
+
return fittedTicks.length;
|
|
46917
|
+
}
|
|
46918
|
+
function pickEquallySpaced$2(arr, numPicks) {
|
|
46919
|
+
if (numPicks >= arr.length) {
|
|
46920
|
+
return arr; // If numPicks is greater than or equal to the array length, return the whole array
|
|
46921
|
+
}
|
|
46922
|
+
var result = [];
|
|
46923
|
+
var interval = (arr.length - 1) / (numPicks - 1);
|
|
46924
|
+
for (var i = 0; i < numPicks; i++) {
|
|
46925
|
+
var index = Math.round(i * interval); // Calculate index and round it
|
|
46926
|
+
result.push(arr[index]);
|
|
46927
|
+
}
|
|
46928
|
+
return result;
|
|
46929
|
+
}
|
|
46930
|
+
var adjustTicks$2 = function adjustTicks(waterfallChartRepresentation, width) {
|
|
46931
|
+
waterfallChartRepresentation = cloneDeep(waterfallChartRepresentation);
|
|
46932
|
+
|
|
46933
|
+
// TODO; take this from the theme override...
|
|
46934
|
+
var averageCharacterWidth = ASSUMED_AVERAGE_CHAR_WIDTH$2;
|
|
46935
|
+
var numberOfTicksFittingIntoSpace = howManyTicksFitInWidth$2(waterfallChartRepresentation.x.ticks || [], width, averageCharacterWidth);
|
|
46936
|
+
var MINIMUM_NUMBER_OF_TICKS = 2;
|
|
46937
|
+
if (numberOfTicksFittingIntoSpace < MINIMUM_NUMBER_OF_TICKS) {
|
|
46938
|
+
numberOfTicksFittingIntoSpace = MINIMUM_NUMBER_OF_TICKS;
|
|
46939
|
+
}
|
|
46940
|
+
|
|
46941
|
+
// @ts-ignore
|
|
46942
|
+
waterfallChartRepresentation.x.ticks = pickEquallySpaced$2(waterfallChartRepresentation.x.ticks, numberOfTicksFittingIntoSpace);
|
|
46943
|
+
return waterfallChartRepresentation;
|
|
46944
|
+
};
|
|
46945
|
+
|
|
46946
|
+
var Tooltip$2 = function Tooltip(_ref) {
|
|
46947
|
+
var _tooltipData$xKey$for, _tooltipData$yKey$for;
|
|
46948
|
+
var showTooltip = _ref.showTooltip,
|
|
46949
|
+
tooltipData = _ref.tooltipData,
|
|
46950
|
+
tooltipLeft = _ref.tooltipLeft,
|
|
46951
|
+
tooltipTop = _ref.tooltipTop,
|
|
46952
|
+
xKey = _ref.xKey,
|
|
46953
|
+
yKey = _ref.yKey,
|
|
46954
|
+
theme = _ref.theme;
|
|
46955
|
+
var tooltipRowContainerClasses = buildStyleOverrides({
|
|
46956
|
+
display: 'grid',
|
|
46957
|
+
gridTemplateColumns: 'auto 1fr',
|
|
46958
|
+
gap: 12,
|
|
46959
|
+
fontWeight: 500,
|
|
46960
|
+
color: 'inherit',
|
|
46961
|
+
alignItems: 'center'
|
|
46962
|
+
});
|
|
46963
|
+
var rowClasses = buildStyleOverrides({
|
|
46964
|
+
borderBottom: '1px dotted rgba(0,0,0,0.025)'
|
|
46965
|
+
});
|
|
46966
|
+
var rowLabelClasses = buildStyleOverrides({
|
|
46967
|
+
alignItems: 'center',
|
|
46968
|
+
display: 'flex',
|
|
46969
|
+
fontFamily: 'inherit',
|
|
46970
|
+
letterSpacing: 'inherit',
|
|
46971
|
+
gap: 6
|
|
46972
|
+
});
|
|
46973
|
+
var rowValueClasses = buildStyleOverrides({
|
|
46974
|
+
display: 'block',
|
|
46975
|
+
fontFamily: 'inherit',
|
|
46976
|
+
letterSpacing: 'inherit',
|
|
46977
|
+
margin: 0,
|
|
46978
|
+
padding: 0,
|
|
46979
|
+
textAlign: 'right'
|
|
46980
|
+
});
|
|
46981
|
+
var highlightedClasses = buildStyleOverrides({
|
|
46982
|
+
wordBreak: 'break-all'
|
|
46983
|
+
});
|
|
46984
|
+
if (!showTooltip || !tooltipData) return null;
|
|
46985
|
+
var value = tooltipData[yKey].value;
|
|
46986
|
+
var isPositiveValue = Number(value) > 0;
|
|
46987
|
+
return jsx(TooltipWithBounds, {
|
|
46988
|
+
left: tooltipLeft,
|
|
46989
|
+
top: tooltipTop,
|
|
46990
|
+
style: theme,
|
|
46991
|
+
children: jsxs("div", {
|
|
46992
|
+
style: {
|
|
46993
|
+
wordBreak: 'break-all'
|
|
46994
|
+
},
|
|
46995
|
+
children: [jsx("div", {
|
|
46996
|
+
style: {
|
|
46997
|
+
fontFamily: 'inherit',
|
|
46998
|
+
lineHeight: 'inherit',
|
|
46999
|
+
letterSpacing: 'inherit',
|
|
47000
|
+
fontWeight: 'bold',
|
|
47001
|
+
fontSize: '15px',
|
|
47002
|
+
width: '100%'
|
|
47003
|
+
},
|
|
47004
|
+
children: (_tooltipData$xKey$for = tooltipData[xKey].formattedValue) != null ? _tooltipData$xKey$for : tooltipData[xKey].value
|
|
47005
|
+
}), jsxs("div", {
|
|
47006
|
+
style: {
|
|
47007
|
+
fontWeight: 700
|
|
47008
|
+
},
|
|
47009
|
+
className: "" + tooltipRowContainerClasses,
|
|
47010
|
+
children: [jsx("span", {
|
|
47011
|
+
className: rowClasses + " " + rowLabelClasses,
|
|
47012
|
+
children: jsx("span", {
|
|
47013
|
+
className: "" + highlightedClasses,
|
|
47014
|
+
children: isPositiveValue ? jsx(IconNarrowRight$1, {}) : jsx(IconTrendingDown$1, {})
|
|
47015
|
+
})
|
|
47016
|
+
}), jsx("p", {
|
|
47017
|
+
className: rowClasses + " " + rowValueClasses,
|
|
47018
|
+
children: (_tooltipData$yKey$for = tooltipData[yKey].formattedValue) != null ? _tooltipData$yKey$for : tooltipData[yKey].value
|
|
47019
|
+
})]
|
|
47020
|
+
})]
|
|
47021
|
+
})
|
|
47022
|
+
}, Math.random());
|
|
47023
|
+
};
|
|
47024
|
+
var IconNarrowRight$1 = function IconNarrowRight() {
|
|
47025
|
+
var style = {
|
|
47026
|
+
width: 20,
|
|
47027
|
+
height: 20,
|
|
47028
|
+
display: 'block'
|
|
47029
|
+
};
|
|
47030
|
+
var fill = "#12B76A";
|
|
47031
|
+
return jsx("svg", {
|
|
47032
|
+
fill: "none",
|
|
47033
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
47034
|
+
viewBox: "0 0 256 256",
|
|
47035
|
+
style: style,
|
|
47036
|
+
children: jsx("path", {
|
|
47037
|
+
fillRule: "evenodd",
|
|
47038
|
+
clipRule: "evenodd",
|
|
47039
|
+
d: "M244 56v64a12 12 0 0 1-24 0V85l-75.51 75.52a12 12 0 0 1-17 0L96 129l-63.51 63.49a12 12 0 0 1-17-17l72-72a12 12 0 0 1 17 0L136 135l67-67h-35a12 12 0 0 1 0-24h64a12 12 0 0 1 12 12",
|
|
47040
|
+
fill: fill
|
|
47041
|
+
})
|
|
47042
|
+
});
|
|
47043
|
+
};
|
|
47044
|
+
var IconTrendingDown$1 = function IconTrendingDown() {
|
|
47045
|
+
var style = {
|
|
47046
|
+
width: 20,
|
|
47047
|
+
height: 20,
|
|
47048
|
+
display: 'block'
|
|
47049
|
+
};
|
|
47050
|
+
var fill = "#F04438";
|
|
47051
|
+
return jsx("svg", {
|
|
47052
|
+
fill: "none",
|
|
47053
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
47054
|
+
viewBox: "0 0 20 20",
|
|
47055
|
+
style: style,
|
|
47056
|
+
children: jsx("path", {
|
|
47057
|
+
fillRule: "evenodd",
|
|
47058
|
+
clipRule: "evenodd",
|
|
47059
|
+
d: "M12 13a1 1 0 1 0 0 2h5a1 1 0 0 0 1-1V9a1 1 0 1 0-2 0v2.586l-4.293-4.293a1 1 0 0 0-1.414 0L8 9.586 3.707 5.293a1 1 0 0 0-1.414 1.414l5 5a1 1 0 0 0 1.414 0L11 9.414 14.586 13H12Z",
|
|
47060
|
+
fill: fill
|
|
47061
|
+
})
|
|
47062
|
+
});
|
|
47063
|
+
};
|
|
47064
|
+
|
|
47065
|
+
var Legend$2 = function Legend(_ref) {
|
|
47066
|
+
var showLegend = _ref.showLegend,
|
|
47067
|
+
margin = _ref.margin;
|
|
47068
|
+
var items = [{
|
|
47069
|
+
color: 'green',
|
|
47070
|
+
yKey: 'increase',
|
|
47071
|
+
style: {
|
|
47072
|
+
type: 'line',
|
|
47073
|
+
strokeDasharray: null,
|
|
47074
|
+
strokeWidth: 2
|
|
47075
|
+
}
|
|
47076
|
+
}, {
|
|
47077
|
+
color: 'red',
|
|
47078
|
+
yKey: 'decrease',
|
|
47079
|
+
style: {
|
|
47080
|
+
type: 'line',
|
|
47081
|
+
strokeDasharray: null,
|
|
47082
|
+
strokeWidth: 2
|
|
47083
|
+
}
|
|
47084
|
+
}];
|
|
47085
|
+
var keys = {
|
|
47086
|
+
increase: {
|
|
47087
|
+
key: 'increase',
|
|
47088
|
+
keyFormatted: 'Increase',
|
|
47089
|
+
dataType: 'string'
|
|
47090
|
+
},
|
|
47091
|
+
decrease: {
|
|
47092
|
+
key: 'decrease',
|
|
47093
|
+
keyFormatted: 'Decrease',
|
|
47094
|
+
dataType: 'string'
|
|
47095
|
+
}
|
|
47096
|
+
};
|
|
47097
|
+
if (!showLegend) return null;
|
|
47098
|
+
return jsx(Legend$1, {
|
|
47099
|
+
legendItems: items,
|
|
47100
|
+
visibleYKeys: ['increase', 'decrease'],
|
|
47101
|
+
keys: keys,
|
|
47102
|
+
marginLeft: margin.left - margin.leftTitleOffset,
|
|
47103
|
+
conditionalFormattingRules: [],
|
|
47104
|
+
setVisibleYKeys: function setVisibleYKeys() {}
|
|
47105
|
+
});
|
|
47106
|
+
};
|
|
47107
|
+
|
|
47108
|
+
var _excluded$g = ["formattedValue"],
|
|
47109
|
+
_excluded2$4 = ["formattedValue"];
|
|
47110
|
+
var AXIS_TITLE_STYLES$1 = {
|
|
47111
|
+
opacity: '0.75',
|
|
47112
|
+
fontWeight: 'bold'
|
|
47113
|
+
};
|
|
47114
|
+
var WaterfallChart$2 = function WaterfallChart(_ref) {
|
|
47115
|
+
var _theme$axis$stroke, _theme$axis;
|
|
47116
|
+
var height = _ref.height,
|
|
47117
|
+
width = _ref.width,
|
|
47118
|
+
options = _ref.options,
|
|
47119
|
+
chart = _ref.chart,
|
|
47120
|
+
theme = _ref.theme;
|
|
47121
|
+
//Waterfall TODO: fix chart for other x types
|
|
47122
|
+
if (chart.x.scale.dataType === 'date_time' || chart.x.scale.dataType === 'number') {
|
|
47123
|
+
return null;
|
|
47124
|
+
}
|
|
47125
|
+
var _useTooltip = useTooltip$1(),
|
|
47126
|
+
tooltipOpen = _useTooltip.tooltipOpen,
|
|
47127
|
+
_useTooltip$tooltipLe = _useTooltip.tooltipLeft,
|
|
47128
|
+
tooltipLeft = _useTooltip$tooltipLe === void 0 ? 0 : _useTooltip$tooltipLe,
|
|
47129
|
+
_useTooltip$tooltipTo = _useTooltip.tooltipTop,
|
|
47130
|
+
tooltipTop = _useTooltip$tooltipTo === void 0 ? 0 : _useTooltip$tooltipTo,
|
|
47131
|
+
tooltipData = _useTooltip.tooltipData,
|
|
47132
|
+
hideTooltip = _useTooltip.hideTooltip,
|
|
47133
|
+
showTooltip = _useTooltip.showTooltip;
|
|
47134
|
+
var chartCopy = cloneDeep(chart);
|
|
47135
|
+
var data = chartCopy.data,
|
|
47136
|
+
x = chartCopy.x,
|
|
47137
|
+
y = chartCopy.y;
|
|
47138
|
+
var showTotalBar = options.showTotalBar;
|
|
47139
|
+
var conditionalFormattingRules = [{
|
|
47140
|
+
yKey: y.key,
|
|
47141
|
+
operator: '>',
|
|
47142
|
+
value: 0,
|
|
47143
|
+
color: 'green'
|
|
47144
|
+
}, {
|
|
47145
|
+
yKey: y.key,
|
|
47146
|
+
operator: '<',
|
|
47147
|
+
value: 0,
|
|
47148
|
+
color: 'red'
|
|
47149
|
+
}];
|
|
47150
|
+
var xKey = x.key;
|
|
47151
|
+
var yKey = y.key;
|
|
47152
|
+
var cumulativeTotal = 0;
|
|
47153
|
+
var steps = data.map(function (item) {
|
|
47154
|
+
var xValue = item[xKey].value;
|
|
47155
|
+
var yValue = Number(item[yKey].value);
|
|
47156
|
+
var prevTotal = cumulativeTotal;
|
|
47157
|
+
cumulativeTotal += yValue;
|
|
47158
|
+
return {
|
|
47159
|
+
x: xValue,
|
|
47160
|
+
y: yValue,
|
|
47161
|
+
start: prevTotal,
|
|
47162
|
+
end: cumulativeTotal
|
|
47163
|
+
};
|
|
47164
|
+
});
|
|
47165
|
+
if (showTotalBar) {
|
|
47166
|
+
var _data$push;
|
|
47167
|
+
steps.push({
|
|
47168
|
+
x: "Total",
|
|
47169
|
+
y: cumulativeTotal,
|
|
47170
|
+
start: 0,
|
|
47171
|
+
end: cumulativeTotal
|
|
47172
|
+
});
|
|
47173
|
+
data.push((_data$push = {}, _data$push[x.key] = {
|
|
47174
|
+
value: "Total",
|
|
47175
|
+
formattedValue: "Total"
|
|
47176
|
+
}, _data$push[y.key] = {
|
|
47177
|
+
value: cumulativeTotal,
|
|
47178
|
+
formattedValue: null
|
|
47179
|
+
}, _data$push));
|
|
47180
|
+
x.ticks.push({
|
|
47181
|
+
value: "Total",
|
|
47182
|
+
formattedValue: "Total",
|
|
47183
|
+
scaleValue: "Total"
|
|
47184
|
+
});
|
|
47185
|
+
}
|
|
47186
|
+
var formattedYAxisForBarChart = _extends({}, y, {
|
|
47187
|
+
keys: [y.key]
|
|
47188
|
+
});
|
|
47189
|
+
var adjustedChartRepresentation = useMemo(function () {
|
|
47190
|
+
return adjustTicks$2(_extends({}, chartCopy), width);
|
|
47191
|
+
}, [chartCopy, width]);
|
|
47192
|
+
var formattedChartDataForBarChart = _extends({}, adjustedChartRepresentation, {
|
|
47193
|
+
y: formattedYAxisForBarChart,
|
|
47194
|
+
steps: steps,
|
|
47195
|
+
conditionalFormattingRules: conditionalFormattingRules,
|
|
47196
|
+
bars: []
|
|
47197
|
+
});
|
|
47198
|
+
var margin = useMemo(function () {
|
|
47199
|
+
return buildMargin(formattedChartDataForBarChart.y.ticks, options.axis.showYAxisLabels, formattedChartDataForBarChart.y.title != null, formattedChartDataForBarChart.x.title != null);
|
|
47200
|
+
}, [formattedChartDataForBarChart.y.ticks, options.axis.showYAxisLabels, formattedChartDataForBarChart.y.title, formattedChartDataForBarChart.x.title]);
|
|
47201
|
+
var innerWidth = width - margin.left - margin.right;
|
|
47202
|
+
var innerHeight = height - margin.top - margin.bottom - (options.showLegend ? 40 : 0);
|
|
47203
|
+
var xScaleKey = formattedChartDataForBarChart.x.scale.key;
|
|
47204
|
+
var yScaleKeys = formattedChartDataForBarChart.y.keys;
|
|
47205
|
+
var xScaleDataType = formattedChartDataForBarChart.x.scale.dataType;
|
|
47206
|
+
var xScale = useMemo(function () {
|
|
47207
|
+
return scaleBand({
|
|
47208
|
+
range: [0, innerWidth],
|
|
47209
|
+
domain: xScaleKey ? [].concat(formattedChartDataForBarChart.data.map(function (d) {
|
|
47210
|
+
return d[xScaleKey] && d[xScaleKey].value !== null ? String(d[xScaleKey].value) : '';
|
|
47211
|
+
})) : [],
|
|
47212
|
+
paddingOuter: 0,
|
|
47213
|
+
paddingInner: 0
|
|
47214
|
+
});
|
|
47215
|
+
}, [innerWidth, formattedChartDataForBarChart.x, formattedChartDataForBarChart.data]);
|
|
47216
|
+
var yScale = useMemo(function () {
|
|
47217
|
+
return scaleLinear({
|
|
47218
|
+
range: [innerHeight, 0],
|
|
47219
|
+
domain: formattedChartDataForBarChart.y.scale.ordering === 'asc' ? [formattedChartDataForBarChart.y.scale.min, formattedChartDataForBarChart.y.scale.max] : [formattedChartDataForBarChart.y.scale.max, formattedChartDataForBarChart.y.scale.min],
|
|
47220
|
+
nice: true
|
|
47221
|
+
});
|
|
47222
|
+
}, [innerHeight, formattedChartDataForBarChart.y]);
|
|
47223
|
+
var xBandwidth = xScale.bandwidth();
|
|
47224
|
+
var innerXScale = useMemo(function () {
|
|
47225
|
+
return scaleBand({
|
|
47226
|
+
range: [0, xBandwidth],
|
|
47227
|
+
domain: yScaleKeys,
|
|
47228
|
+
padding: 0.1
|
|
47229
|
+
});
|
|
47230
|
+
}, [xScale, yScaleKeys, xScaleDataType]);
|
|
47231
|
+
var dataFlattened = useMemo(function () {
|
|
47232
|
+
if (xScaleKey) {
|
|
47233
|
+
return flattenData({
|
|
47234
|
+
data: formattedChartDataForBarChart.data,
|
|
47235
|
+
xScaleKey: xScaleKey,
|
|
47236
|
+
xScaleDataType: xScaleDataType,
|
|
47237
|
+
yKeys: formattedChartDataForBarChart.y.keys
|
|
47238
|
+
});
|
|
47239
|
+
}
|
|
47240
|
+
return [];
|
|
47241
|
+
}, [formattedChartDataForBarChart.data, xScaleKey, xScaleDataType, formattedChartDataForBarChart.y.keys]);
|
|
47242
|
+
var themeCSS = useMemo(function () {
|
|
47243
|
+
return getChartThemeCSS(theme);
|
|
47244
|
+
}, [theme]);
|
|
47245
|
+
var yTickValues = formattedChartDataForBarChart.y.ticks.map(function (tick) {
|
|
47246
|
+
return Number(tick.value);
|
|
47247
|
+
});
|
|
47248
|
+
var xTickValues = formattedChartDataForBarChart.x.ticks.length > 0 ? formattedChartDataForBarChart.x.ticks.map(function (tick) {
|
|
47249
|
+
var _tick$scaleValue;
|
|
47250
|
+
return (_tick$scaleValue = tick.scaleValue) != null ? _tick$scaleValue : 0;
|
|
47251
|
+
}) : undefined;
|
|
47252
|
+
var handleMouseMove = useCallback(function (event) {
|
|
47253
|
+
if (!xKey || !xScaleKey || xScale === null) return;
|
|
47254
|
+
var tooltipData = getTooltipData({
|
|
47255
|
+
data: formattedChartDataForBarChart.data,
|
|
47256
|
+
event: event,
|
|
47257
|
+
margin: margin,
|
|
47258
|
+
xScaleKey: xScaleKey,
|
|
47259
|
+
xScaleDataType: xScaleDataType,
|
|
47260
|
+
xOrdering: formattedChartDataForBarChart.x.scale.ordering,
|
|
47261
|
+
xScale: xScale,
|
|
47262
|
+
chartType: 'bar'
|
|
47263
|
+
});
|
|
47264
|
+
showTooltip({
|
|
47265
|
+
tooltipLeft: tooltipData == null ? void 0 : tooltipData.tooltipLeft,
|
|
47266
|
+
tooltipTop: tooltipData == null ? void 0 : tooltipData.tooltipTop,
|
|
47267
|
+
tooltipData: tooltipData == null ? void 0 : tooltipData.tooltipData
|
|
47268
|
+
});
|
|
47269
|
+
}, [showTooltip, xScale, margin, xKey, xScaleKey, xScaleDataType, formattedChartDataForBarChart.x.scale.ordering, formattedChartDataForBarChart.data]);
|
|
47270
|
+
var handleMouseLeave = useCallback(function () {
|
|
47271
|
+
hideTooltip();
|
|
47272
|
+
}, [hideTooltip]);
|
|
47273
|
+
var getXTickFormat = useCallback(function (value) {
|
|
47274
|
+
var tick = null;
|
|
47275
|
+
if (xScaleDataType === 'date_time' && value instanceof Date) {
|
|
47276
|
+
var matchingTickValue = formattedChartDataForBarChart.x.ticks.find(function (tickValue) {
|
|
47277
|
+
return tickValue.scaleValue && new Date(tickValue.scaleValue).valueOf() === value.valueOf();
|
|
47278
|
+
});
|
|
47279
|
+
tick = matchingTickValue || null;
|
|
47280
|
+
} else {
|
|
47281
|
+
var _matchingTickValue = formattedChartDataForBarChart.x.ticks.find(function (tickValue) {
|
|
47282
|
+
return tickValue.scaleValue === value;
|
|
47283
|
+
});
|
|
47284
|
+
tick = _matchingTickValue || null;
|
|
47285
|
+
}
|
|
47286
|
+
if (tick) {
|
|
47287
|
+
if (tick.formattedValue) {
|
|
47288
|
+
return tick.formattedValue;
|
|
47289
|
+
}
|
|
47290
|
+
return tick.value.toString();
|
|
47291
|
+
}
|
|
47292
|
+
return '';
|
|
47293
|
+
}, [formattedChartDataForBarChart.x.ticks, xScaleDataType]);
|
|
47294
|
+
var getYTickFormat = useCallback(function (value) {
|
|
47295
|
+
var item = formattedChartDataForBarChart.y.ticks.filter(function (tick) {
|
|
47296
|
+
return tick.value === value;
|
|
47297
|
+
})[0];
|
|
47298
|
+
if (item) {
|
|
47299
|
+
if (item.formattedValue) {
|
|
47300
|
+
return item.formattedValue;
|
|
47301
|
+
}
|
|
47302
|
+
return item.value.toString();
|
|
47303
|
+
}
|
|
47304
|
+
return '';
|
|
47305
|
+
}, [formattedChartDataForBarChart.y.ticks]);
|
|
47306
|
+
var getBarGroupPosition = useCallback(function (d) {
|
|
47307
|
+
if (xScaleKey == null || d == null) return;
|
|
47308
|
+
var xValue = d[xScaleKey];
|
|
47309
|
+
if (xScaleDataType === 'string') return xValue;
|
|
47310
|
+
return;
|
|
47311
|
+
}, [xScaleKey, xScaleDataType]);
|
|
47312
|
+
return jsxs(Fragment$1, {
|
|
47313
|
+
children: [jsxs("svg", {
|
|
47314
|
+
width: width,
|
|
47315
|
+
height: height - (options.showLegend ? 40 : 0),
|
|
47316
|
+
onMouseMove: handleMouseMove,
|
|
47317
|
+
onMouseLeave: handleMouseLeave,
|
|
47318
|
+
style: {
|
|
47319
|
+
display: 'block'
|
|
47320
|
+
},
|
|
47321
|
+
children: [jsxs(Group$2, {
|
|
47322
|
+
left: margin.left,
|
|
47323
|
+
top: margin.top,
|
|
47324
|
+
children: [jsx(GridRows$1, {
|
|
47325
|
+
tickValues: yTickValues.length > 0 ? yTickValues : undefined,
|
|
47326
|
+
scale: yScale,
|
|
47327
|
+
width: innerWidth,
|
|
47328
|
+
height: innerHeight,
|
|
47329
|
+
pointerEvents: "none",
|
|
47330
|
+
strokeDasharray: "0.5 5",
|
|
47331
|
+
strokeWidth: options.removeStroke ? 0 : 2,
|
|
47332
|
+
lineStyle: {
|
|
47333
|
+
strokeLinecap: 'round',
|
|
47334
|
+
stroke: themeCSS.grid.stroke
|
|
47335
|
+
}
|
|
47336
|
+
}), options.axis.showXAxisLabels && jsx(AxisBottom$1, {
|
|
47337
|
+
label: formattedChartDataForBarChart.x.title || undefined,
|
|
47338
|
+
labelProps: {
|
|
47339
|
+
style: AXIS_TITLE_STYLES$1
|
|
47340
|
+
},
|
|
47341
|
+
labelOffset: margin.bottomTitleOffset,
|
|
47342
|
+
hideTicks: true,
|
|
47343
|
+
top: innerHeight,
|
|
47344
|
+
scale: xScale,
|
|
47345
|
+
tickFormat: getXTickFormat,
|
|
47346
|
+
tickValues: xTickValues,
|
|
47347
|
+
tickComponent: function tickComponent(_ref2) {
|
|
47348
|
+
var formattedValue = _ref2.formattedValue,
|
|
47349
|
+
tickProps = _objectWithoutPropertiesLoose(_ref2, _excluded$g);
|
|
47350
|
+
return jsx(Text, _extends({
|
|
47351
|
+
style: themeCSS.labels
|
|
47352
|
+
}, tickProps, {
|
|
47353
|
+
children: formattedValue
|
|
47354
|
+
}));
|
|
47355
|
+
},
|
|
47356
|
+
stroke: themeCSS.axis.stroke,
|
|
47357
|
+
strokeWidth: options.removeStroke ? 0 : 1
|
|
47358
|
+
}), options.axis.showYAxisLabels && jsx(AxisLeft$1, {
|
|
47359
|
+
labelOffset: margin.leftTitleOffset,
|
|
47360
|
+
label: formattedChartDataForBarChart.y.title || undefined,
|
|
47361
|
+
labelProps: {
|
|
47362
|
+
style: AXIS_TITLE_STYLES$1
|
|
47363
|
+
},
|
|
47364
|
+
hideTicks: true,
|
|
47365
|
+
left: 0,
|
|
47366
|
+
top: 0,
|
|
47367
|
+
scale: yScale,
|
|
47368
|
+
tickFormat: getYTickFormat,
|
|
47369
|
+
tickValues: yTickValues,
|
|
47370
|
+
tickComponent: function tickComponent(_ref3) {
|
|
47371
|
+
var formattedValue = _ref3.formattedValue,
|
|
47372
|
+
tickProps = _objectWithoutPropertiesLoose(_ref3, _excluded2$4);
|
|
47373
|
+
return jsx(Text, _extends({
|
|
47374
|
+
width: 10,
|
|
47375
|
+
style: themeCSS.labels
|
|
47376
|
+
}, tickProps, {
|
|
47377
|
+
children: formattedValue
|
|
47378
|
+
}));
|
|
47379
|
+
},
|
|
47380
|
+
stroke: (_theme$axis$stroke = theme == null || (_theme$axis = theme.axis) == null ? void 0 : _theme$axis.stroke) != null ? _theme$axis$stroke : 'transparent'
|
|
47381
|
+
}), jsx(Group$2, {
|
|
47382
|
+
children: jsx(BarGroup$1, {
|
|
47383
|
+
data: dataFlattened,
|
|
47384
|
+
keys: yScaleKeys,
|
|
47385
|
+
height: innerHeight,
|
|
47386
|
+
x0: getBarGroupPosition
|
|
47387
|
+
// @ts-ignore
|
|
47388
|
+
,
|
|
47389
|
+
x0Scale: xScale
|
|
47390
|
+
// @ts-ignore
|
|
47391
|
+
,
|
|
47392
|
+
x1Scale: innerXScale,
|
|
47393
|
+
yScale: yScale,
|
|
47394
|
+
color: function color() {
|
|
47395
|
+
return '';
|
|
47396
|
+
},
|
|
47397
|
+
children: function children(barGroups) {
|
|
47398
|
+
return barGroups.map(function (barGroup) {
|
|
47399
|
+
return jsx(Group$2, {
|
|
47400
|
+
left: barGroup.x0,
|
|
47401
|
+
children: barGroup.bars.map(function (bar) {
|
|
47402
|
+
return jsx(Bar$1, {
|
|
47403
|
+
bar: bar,
|
|
47404
|
+
barGroup: barGroup,
|
|
47405
|
+
yScale: yScale,
|
|
47406
|
+
formattedChartDataForBarChart: formattedChartDataForBarChart
|
|
47407
|
+
});
|
|
47408
|
+
})
|
|
47409
|
+
}, "bar-group-" + barGroup.index + "-" + barGroup.x0);
|
|
47410
|
+
});
|
|
47411
|
+
}
|
|
47412
|
+
})
|
|
47413
|
+
})]
|
|
47414
|
+
}), tooltipData && jsx("g", {
|
|
47415
|
+
children: jsx(Line, {
|
|
47416
|
+
from: {
|
|
47417
|
+
x: tooltipLeft,
|
|
47418
|
+
y: margin.top
|
|
47419
|
+
},
|
|
47420
|
+
to: {
|
|
47421
|
+
x: tooltipLeft,
|
|
47422
|
+
y: innerHeight + margin.top
|
|
47423
|
+
},
|
|
47424
|
+
stroke: '#aaa',
|
|
47425
|
+
strokeWidth: 2,
|
|
47426
|
+
pointerEvents: "none",
|
|
47427
|
+
opacity: 0.8
|
|
47428
|
+
})
|
|
47429
|
+
})]
|
|
47430
|
+
}), jsx(Legend$2, {
|
|
47431
|
+
showLegend: options.showLegend,
|
|
47432
|
+
margin: margin
|
|
47433
|
+
}), jsx(Tooltip$2, {
|
|
47434
|
+
showTooltip: tooltipOpen,
|
|
47435
|
+
tooltipData: tooltipData,
|
|
47436
|
+
tooltipLeft: tooltipLeft,
|
|
47437
|
+
tooltipTop: tooltipTop,
|
|
47438
|
+
xKey: xKey,
|
|
47439
|
+
yKey: yKey,
|
|
47440
|
+
theme: themeCSS.popoverMenus
|
|
47441
|
+
})]
|
|
47442
|
+
});
|
|
47443
|
+
};
|
|
47444
|
+
var Bar$1 = function Bar(_ref4) {
|
|
47445
|
+
var bar = _ref4.bar,
|
|
47446
|
+
barGroup = _ref4.barGroup,
|
|
47447
|
+
yScale = _ref4.yScale,
|
|
47448
|
+
formattedChartDataForBarChart = _ref4.formattedChartDataForBarChart;
|
|
47449
|
+
var step = formattedChartDataForBarChart.steps[barGroup.index];
|
|
47450
|
+
var y = yScale(Math.max(step.start, step.end));
|
|
47451
|
+
var barHeight = Math.abs(yScale(step.start) - yScale(step.end));
|
|
47452
|
+
return jsx(Fragment$1, {
|
|
47453
|
+
children: jsx("rect", {
|
|
47454
|
+
x: bar.x,
|
|
47455
|
+
y: y,
|
|
47456
|
+
width: bar.width,
|
|
47457
|
+
height: barHeight,
|
|
47458
|
+
fill: getBarFill$1(formattedChartDataForBarChart.bars, formattedChartDataForBarChart.conditionalFormattingRules, bar.key, bar.value),
|
|
47459
|
+
rx: 4
|
|
47460
|
+
}, "bar-group-bar-" + barGroup.index + "-" + bar.index + "-" + bar.value + "-" + bar.key)
|
|
47461
|
+
});
|
|
47462
|
+
};
|
|
47463
|
+
|
|
46863
47464
|
function getNiceInterval$2(interval) {
|
|
46864
47465
|
// Round the interval to a "nice" value (1, 2, 5, etc.)
|
|
46865
47466
|
var exponent = Math.floor(Math.log10(interval));
|
|
@@ -47144,7 +47745,7 @@ var WaterfallChartView = function WaterfallChartView(props) {
|
|
|
47144
47745
|
overflowX: 'hidden'
|
|
47145
47746
|
},
|
|
47146
47747
|
children: function children(parent) {
|
|
47147
|
-
return jsx(WaterfallChart$
|
|
47748
|
+
return jsx(WaterfallChart$2, {
|
|
47148
47749
|
width: parent.width,
|
|
47149
47750
|
height: parent.height,
|
|
47150
47751
|
options: {
|
|
@@ -47169,7 +47770,7 @@ var WaterfallChartView = function WaterfallChartView(props) {
|
|
|
47169
47770
|
};
|
|
47170
47771
|
var WaterfallChartView$1 = /*#__PURE__*/memo(WaterfallChartView, shouldUpdate);
|
|
47171
47772
|
|
|
47172
|
-
var WaterfallChart$
|
|
47773
|
+
var WaterfallChart$3 = function WaterfallChart(_ref) {
|
|
47173
47774
|
var component = _ref.component,
|
|
47174
47775
|
dataSet = _ref.dataSet,
|
|
47175
47776
|
dashboardBehaviour = _ref.dashboardBehaviour,
|
|
@@ -47666,7 +48267,7 @@ var Component = function Component(props) {
|
|
|
47666
48267
|
});
|
|
47667
48268
|
},
|
|
47668
48269
|
onError: dashboardBehaviour.onError,
|
|
47669
|
-
children: jsx(WaterfallChart$
|
|
48270
|
+
children: jsx(WaterfallChart$3, {
|
|
47670
48271
|
id: props.id,
|
|
47671
48272
|
dataSet: dataSet,
|
|
47672
48273
|
setLocalFilters: props.setLocalFilters,
|
|
@@ -63982,7 +64583,7 @@ var Progress$3 = /*#__PURE__*/function (_View13) {
|
|
|
63982
64583
|
};
|
|
63983
64584
|
return Progress;
|
|
63984
64585
|
}(View$3);
|
|
63985
|
-
var WaterfallChart$
|
|
64586
|
+
var WaterfallChart$4 = /*#__PURE__*/function (_View15) {
|
|
63986
64587
|
function WaterfallChart(attributes) {
|
|
63987
64588
|
return _View15.call(this, _extends({}, attributes, {
|
|
63988
64589
|
type: 'waterfallChart'
|
|
@@ -65911,7 +66512,7 @@ VizzlyServices.HorizontalBarChart = HorizontalBarChart$2;
|
|
|
65911
66512
|
VizzlyServices.MercatorMap = MercatorMap$4;
|
|
65912
66513
|
VizzlyServices.SingleStat = SingleStat$3;
|
|
65913
66514
|
VizzlyServices.Progress = Progress$3;
|
|
65914
|
-
VizzlyServices.WaterfallChart = WaterfallChart$
|
|
66515
|
+
VizzlyServices.WaterfallChart = WaterfallChart$4;
|
|
65915
66516
|
// @ts-ignore
|
|
65916
66517
|
if (typeof window !== 'undefined' && !window.Vizzly) {
|
|
65917
66518
|
// @ts-ignore
|
|
@@ -68737,7 +69338,7 @@ var GlobalProviderContents = function GlobalProviderContents(props) {
|
|
|
68737
69338
|
});
|
|
68738
69339
|
};
|
|
68739
69340
|
|
|
68740
|
-
var _excluded$
|
|
69341
|
+
var _excluded$h = ["view"];
|
|
68741
69342
|
var Dashboard$2 = function Dashboard(props) {
|
|
68742
69343
|
var handleOnError = function handleOnError(error, errorInfo) {
|
|
68743
69344
|
return (props == null ? void 0 : props.onError) && (props == null ? void 0 : props.onError(error, errorInfo));
|
|
@@ -68758,7 +69359,7 @@ var Editor$1 = function Editor(props) {
|
|
|
68758
69359
|
var handleOnError = function handleOnError(error, errorInfo) {
|
|
68759
69360
|
return (props == null ? void 0 : props.onError) && (props == null ? void 0 : props.onError(error, errorInfo));
|
|
68760
69361
|
};
|
|
68761
|
-
var resetProps = _objectWithoutPropertiesLoose(props, _excluded$
|
|
69362
|
+
var resetProps = _objectWithoutPropertiesLoose(props, _excluded$h);
|
|
68762
69363
|
return jsxs(ErrorBoundary, {
|
|
68763
69364
|
renderOnError: function renderOnError() {
|
|
68764
69365
|
return jsx("p", {
|