@vizzly/dashboard 0.14.4-dev-a92622560305a2aadfb851574db2d2f43a80cb14 → 0.14.4-dev-8beb4cd0b38350abdd05b93b66f2523ced40aa15

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.
@@ -57,7 +57,6 @@ var windowSize = require('@react-hook/window-size');
57
57
  var copy = _interopDefault(require('copy-to-clipboard'));
58
58
  var html2canvas = _interopDefault(require('html2canvas'));
59
59
  var jsPDF = _interopDefault(require('jspdf'));
60
- var BubbleChart$3 = require('./charts/src/BubbleChart');
61
60
  var clipPath = require('@visx/clip-path');
62
61
  var event = require('@visx/event');
63
62
  var d3Array = require('@visx/vendor/d3-array');
@@ -9340,7 +9339,7 @@ var BubbleChart = function BubbleChart(config) {
9340
9339
 
9341
9340
  var attributesSchema$f = function attributesSchema(config) {
9342
9341
  return Joi.object(_extends({}, baseAttributesSchema(config.attributesSchemaOptions), timeDimensionQuerySchema(config.queryEngineConfig, config.attributesSchemaOptions), {
9343
- stacked: Joi.valid(true, false, '100%'),
9342
+ stacked: Joi.valid(true, false),
9344
9343
  legend: Joi.valid(true, false),
9345
9344
  type: Joi.valid('barChartV2').required(),
9346
9345
  parameters: parametersSchema(config.queryEngineConfig, config.attributesSchemaOptions),
@@ -40747,6 +40746,259 @@ var IconText = function IconText(props) {
40747
40746
  });
40748
40747
  };
40749
40748
 
40749
+ var accessors$1 = function accessors(xAxisIsTime, xKey, yKey, horizontal) {
40750
+ return {
40751
+ xAccessor: function xAccessor(d) {
40752
+ return d ? horizontal ? d[yKey] : xAxisIsTime ? new Date(d[xKey]) : d[xKey] : undefined;
40753
+ },
40754
+ yAccessor: function yAccessor(d) {
40755
+ return d ? horizontal ? xAxisIsTime ? new Date(d[xKey]) : d[xKey] : d[yKey] : undefined;
40756
+ }
40757
+ };
40758
+ };
40759
+ var DEFAULT_Y_AXIS_LABEL_COUNT$1 = 5;
40760
+ var VizzlyBubbleChart = function VizzlyBubbleChart(props) {
40761
+ var _props$height, _theme$axis$stroke, _theme$axis, _ref, _props$lines$data$len, _props$lines, _props$areas, _props$bars, _props$forceXAxisAsTi, _props$bars2, _props$lines2, _theme$grid$stroke, _theme$grid, _props$axisTitles, _props$axisTitles2, _props$axisTitles3, _props$axisTitles4, _props$bars3, _props$bars4, _props$bars5;
40762
+ var height = adjustHeight((_props$height = props == null ? void 0 : props.height) != null ? _props$height : 300, props == null ? void 0 : props.legend);
40763
+ var _props$approxYAxisLab = props.approxYAxisLabelCount,
40764
+ approxYAxisLabelCount = _props$approxYAxisLab === void 0 ? 'auto' : _props$approxYAxisLab,
40765
+ _props$approxXAxisLab = props.approxXAxisLabelCount,
40766
+ approxXAxisLabelCount = _props$approxXAxisLab === void 0 ? 'auto' : _props$approxXAxisLab,
40767
+ _props$removeStroke = props.removeStroke,
40768
+ removeStroke = _props$removeStroke === void 0 ? false : _props$removeStroke,
40769
+ _props$horizontal = props.horizontal,
40770
+ horizontal = _props$horizontal === void 0 ? false : _props$horizontal,
40771
+ theme = props.theme,
40772
+ x = props.x;
40773
+ var xAxisIsTime = isXAxisTime(props.x, props.forceXAxisAsTime, props.bars, props.lines, props.areas);
40774
+ var axisLabelStyles = function axisLabelStyles(horizontal, labelTheme) {
40775
+ var _labelTheme$color, _labelTheme$fontSize, _labelTheme$fontWeigh, _labelTheme$fontFamil;
40776
+ return {
40777
+ fill: (_labelTheme$color = labelTheme == null ? void 0 : labelTheme.color) != null ? _labelTheme$color : 'rgba(0, 0, 0, 0.6)',
40778
+ fontSize: (_labelTheme$fontSize = labelTheme == null ? void 0 : labelTheme.fontSize) != null ? _labelTheme$fontSize : 9,
40779
+ fontWeight: (_labelTheme$fontWeigh = labelTheme == null ? void 0 : labelTheme.fontWeight) != null ? _labelTheme$fontWeigh : 700,
40780
+ fontFamily: (_labelTheme$fontFamil = labelTheme == null ? void 0 : labelTheme.fontFamily) != null ? _labelTheme$fontFamil : DEFAULT_CHART_FONT,
40781
+ textAnchor: horizontal ? 'end' : 'middle',
40782
+ scaleToFit: 'shrink-only'
40783
+ };
40784
+ };
40785
+ var _useXAxisLabelCount = useXAxisLabelCount(approxXAxisLabelCount, !(props != null && props.horizontal) && (props == null ? void 0 : props.forceXAxisAsTime)),
40786
+ widthRef = _useXAxisLabelCount[0],
40787
+ approximateXTickCount = _useXAxisLabelCount[1];
40788
+ var _useState = React.useState(undefined),
40789
+ nearestDatum = _useState[0];
40790
+ var _useState2 = React.useState(undefined),
40791
+ nearestTooltipDatums = _useState2[0];
40792
+ var colors = getConcatenatedProperties(props, 'colors');
40793
+ var customTheme = xychart.buildChartTheme(_extends({}, xychart.lightTheme, {
40794
+ colors: colors,
40795
+ tickLength: 0,
40796
+ gridColor: '',
40797
+ gridColorDark: ''
40798
+ }));
40799
+ var chartData = getConcatenatedProperties(props, 'data');
40800
+ var axisStrokeColor = (_theme$axis$stroke = theme == null || (_theme$axis = theme.axis) == null ? void 0 : _theme$axis.stroke) != null ? _theme$axis$stroke : '#eaeaea';
40801
+ var _getAxisType = getAxisType(approxXAxisLabelCount, approxYAxisLabelCount),
40802
+ xAxisType = _getAxisType.xAxisType,
40803
+ xAxisAttributes = _getAxisType.xAxisAttributes,
40804
+ yAxisType = _getAxisType.yAxisType;
40805
+ var numberOfXAxisPoints = (_ref = (_props$lines$data$len = props == null || (_props$lines = props.lines) == null ? void 0 : _props$lines.data.length) != null ? _props$lines$data$len : props == null || (_props$areas = props.areas) == null || (_props$areas = _props$areas.data) == null ? void 0 : _props$areas.length) != null ? _ref : (_props$bars = props.bars) == null ? void 0 : _props$bars.data.length;
40806
+ var _useMinMaxValue = useMinMaxValue(props),
40807
+ maxValue = _useMinMaxValue.maxValue,
40808
+ minValue = _useMinMaxValue.minValue;
40809
+ var leftWidth = getYAxisWidth(horizontal, (_props$forceXAxisAsTi = props.forceXAxisAsTime) != null ? _props$forceXAxisAsTi : false, props, theme, getConcatenatedProperties(props, 'data'), props.x);
40810
+ var margin = props.sparkline ? NO_MARGIN(props.yAxisOrientation !== 'right') : getDefaultMargins(horizontal, props.yAxisOrientation !== 'right', xAxisType, props == null ? void 0 : props.axisTitles, leftWidth);
40811
+ var getTrendLineStyle = function getTrendLineStyle(datumKey) {
40812
+ if (props.trends) {
40813
+ var _props$trends, _strokeDasharrayToBor, _indicatorProperties$, _indicatorProperties$2, _indicatorProperties$3, _indicatorProperties$4, _indicatorProperties$5, _indicatorProperties$6, _indicatorProperties$7, _indicatorProperties$8, _indicatorProperties$9;
40814
+ var indicatorKeyIndex = (_props$trends = props.trends) == null ? void 0 : _props$trends.keys.indexOf(datumKey);
40815
+ var indicatorProperties = props.trends;
40816
+ return {
40817
+ borderStyle: (_strokeDasharrayToBor = strokeDasharrayToBorderStyle((_indicatorProperties$ = indicatorProperties.strokeDasharray) == null ? void 0 : _indicatorProperties$[indicatorKeyIndex])) != null ? _strokeDasharrayToBor : 'dotted',
40818
+ borderWidth: 0,
40819
+ marginTop: (_indicatorProperties$2 = (_indicatorProperties$3 = indicatorProperties.strokeWidth) == null ? void 0 : _indicatorProperties$3[indicatorKeyIndex]) != null ? _indicatorProperties$2 : 2,
40820
+ borderTopWidth: (_indicatorProperties$4 = (_indicatorProperties$5 = indicatorProperties.strokeWidth) == null ? void 0 : _indicatorProperties$5[indicatorKeyIndex]) != null ? _indicatorProperties$4 : 2,
40821
+ borderColor: (_indicatorProperties$6 = (_indicatorProperties$7 = indicatorProperties.colors) == null ? void 0 : _indicatorProperties$7[indicatorKeyIndex]) != null ? _indicatorProperties$6 : '#1E1D2D',
40822
+ opacity: (_indicatorProperties$8 = (_indicatorProperties$9 = indicatorProperties.opacity) == null ? void 0 : _indicatorProperties$9[indicatorKeyIndex]) != null ? _indicatorProperties$8 : 1
40823
+ };
40824
+ }
40825
+ return undefined;
40826
+ };
40827
+ return jsxRuntime.jsxs("div", {
40828
+ ref: widthRef,
40829
+ style: {
40830
+ position: 'relative',
40831
+ height: height
40832
+ },
40833
+ className: "vizzly-xy-chart" + (props != null && (_props$bars2 = props.bars) != null && _props$bars2.funnelChart ? ' vizzly-xy-chart-funnel' : ''),
40834
+ "data-testid": "vizzly-" + (props == null ? void 0 : props.uniqueId) + "-chart",
40835
+ children: [jsxRuntime.jsxs(xychart.XYChart, {
40836
+ theme: customTheme,
40837
+ margin: margin,
40838
+ height: height,
40839
+ xScale: getScale('x', horizontal, xAxisIsTime, props == null || (_props$lines2 = props.lines) == null ? void 0 : _props$lines2.scatter, !!(props != null && props.lines) || !!(props != null && props.areas)),
40840
+ yScale: getYScale(props == null ? void 0 : props.goalLine, maxValue, minValue, horizontal, xAxisIsTime),
40841
+ horizontal: horizontal,
40842
+ onPointerUp: function onPointerUp(params) {
40843
+ return props == null ? void 0 : props.onClick(nearestDatum, nearestTooltipDatums, params);
40844
+ },
40845
+ children: [jsxRuntime.jsx(xychart.Grid, {
40846
+ columns: horizontal,
40847
+ rows: !horizontal,
40848
+ stroke: "black",
40849
+ strokeDasharray: "0.5 5",
40850
+ strokeWidth: removeStroke ? 0 : 2,
40851
+ lineStyle: {
40852
+ strokeLinecap: 'round',
40853
+ stroke: (_theme$grid$stroke = theme == null || (_theme$grid = theme.grid) == null ? void 0 : _theme$grid.stroke) != null ? _theme$grid$stroke : 'rgba(200, 200, 200, 0.2)'
40854
+ }
40855
+ }), !(props != null && props.sparkline) && jsxRuntime.jsxs(jsxRuntime.Fragment, {
40856
+ children: [xAxisType !== 'none' && jsxRuntime.jsx(xychart.Axis, _extends({}, xAxisAttributes, {
40857
+ tickLabelProps: function tickLabelProps() {
40858
+ var tickLabelProps = _extends({}, axisLabelStyles(horizontal, theme == null ? void 0 : theme.labels));
40859
+ if (!horizontal) {
40860
+ tickLabelProps['y'] = 15;
40861
+ }
40862
+ return tickLabelProps;
40863
+ },
40864
+ numTicks: xAxisType === 'end2end' ? numberOfXAxisPoints : approximateXTickCount,
40865
+ strokeWidth: removeStroke ? 0 : 1,
40866
+ tickStroke: "#eaeaea",
40867
+ stroke: horizontal ? 'transparent' : axisStrokeColor,
40868
+ orientation: horizontal ? 'left' : 'bottom',
40869
+ tickFormat: handleFormatXAxisLabel(props.formatXAxisLabel, props.forceXAxisAsTime || xAxisIsTime, chartData),
40870
+ label: horizontal ? props == null || (_props$axisTitles = props.axisTitles) == null ? void 0 : _props$axisTitles.y : props == null || (_props$axisTitles2 = props.axisTitles) == null ? void 0 : _props$axisTitles2.x,
40871
+ children: function children(axisProps) {
40872
+ return jsxRuntime.jsx(XAxis, _extends({}, axisProps, {
40873
+ theme: theme,
40874
+ type: xAxisType,
40875
+ uniqueId: props == null ? void 0 : props.uniqueId,
40876
+ chartWidth: props == null ? void 0 : props.width,
40877
+ xAxisIsTime: !!props.forceXAxisAsTime,
40878
+ leftPanelWidth: leftWidth,
40879
+ axisHorizontal: props == null ? void 0 : props.horizontal
40880
+ }));
40881
+ }
40882
+ })), jsxRuntime.jsx(xychart.Axis, {
40883
+ labelOffset: 50,
40884
+ tickLabelProps: function tickLabelProps() {
40885
+ var tickLabelProps = _extends({}, axisLabelStyles(horizontal, theme == null ? void 0 : theme.labels));
40886
+ if (!horizontal && props.yAxisOrientation !== 'right') {
40887
+ tickLabelProps['width'] = LEFT_PANEL_WIDTH;
40888
+ tickLabelProps['textAnchor'] = 'middle';
40889
+ }
40890
+ return tickLabelProps;
40891
+ },
40892
+ hideAxisLine: true,
40893
+ numTicks: approxYAxisLabelCount === 'auto' ? DEFAULT_Y_AXIS_LABEL_COUNT$1 : approxYAxisLabelCount,
40894
+ strokeWidth: removeStroke ? 0 : 1,
40895
+ hideTicks: true,
40896
+ tickLength: !props.horizontal && props.yAxisOrientation !== 'right' ? LEFT_PANEL_WIDTH / 2 : 10,
40897
+ stroke: axisStrokeColor,
40898
+ orientation: horizontal ? 'bottom' : props.yAxisOrientation || 'left',
40899
+ tickFormat: formatYAxisLabel$1(props),
40900
+ label: horizontal ? props == null || (_props$axisTitles3 = props.axisTitles) == null ? void 0 : _props$axisTitles3.x : props == null || (_props$axisTitles4 = props.axisTitles) == null ? void 0 : _props$axisTitles4.y,
40901
+ children: function children(axisProps) {
40902
+ return jsxRuntime.jsx(YAxis, _extends({}, axisProps, {
40903
+ theme: theme,
40904
+ type: yAxisType,
40905
+ horizontal: horizontal,
40906
+ maxValueOfYAxis: props != null && props.formatYAxisLabel ? props == null ? void 0 : props.formatYAxisLabel(maxValue) : maxValue,
40907
+ uniqueId: props == null ? void 0 : props.uniqueId
40908
+ }));
40909
+ }
40910
+ })]
40911
+ }), jsxRuntime.jsx("style", {
40912
+ children: "\n .visx-bar-stack .visx-bar {\n stroke: #fff;\n stroke-width: 2px;\n }\n .vizzly-xy-chart-funnel .visx-bar-stack .visx-bar {\n stroke-width: 0;\n }\n .visx-tooltip-glyph svg {\n max-width: 10px\n height: 10px;\n }\n " + TOOLTIP_ZINDEX + "\n "
40913
+ }), props.lines && props.lines.keys.map(function (key, keyIndex) {
40914
+ var _props$lines3, _props$lines4;
40915
+ return jsxRuntime.jsx(xychart.GlyphSeries, _extends({
40916
+ size: function size(datum) {
40917
+ if (!datum || !datum.bubbleSize) return 5;
40918
+ return datum.bubbleSize;
40919
+ },
40920
+ dataKey: key,
40921
+ data: (_props$lines3 = props.lines) == null ? void 0 : _props$lines3.data
40922
+ }, accessors$1(xAxisIsTime, x, key, horizontal), {
40923
+ colorAccessor: (props == null || (_props$lines4 = props.lines) == null ? void 0 : _props$lines4.formatter) && getColorFromDatum(key, props == null ? void 0 : props.lines.formatter, colors, keyIndex)
40924
+ }), "scatter_chart_" + props.uniqueId + "_" + keyIndex);
40925
+ })]
40926
+ }), (props == null ? void 0 : props.legend) && jsxRuntime.jsx(Legend, {
40927
+ funnelChart: props == null || (_props$bars3 = props.bars) == null ? void 0 : _props$bars3.funnelChart
40928
+ // groupingCount={props}
40929
+ ,
40930
+ keys: getConcatenatedProperties(props, 'keys'),
40931
+ colors: colors,
40932
+ typeIndex: getTypeIndex(props),
40933
+ formatSeriesName: props == null ? void 0 : props.formatSeriesName,
40934
+ formatter: props == null || (_props$bars4 = props.bars) == null ? void 0 : _props$bars4.formatter,
40935
+ data: (_props$bars5 = props.bars) == null ? void 0 : _props$bars5.data,
40936
+ conditionalFormattingPossibilities: props.conditionalFormattingPossibilities,
40937
+ getIndicatorStyles: getTrendLineStyle
40938
+ })]
40939
+ });
40940
+ };
40941
+
40942
+ var BubbleChart$2 = /*#__PURE__*/React.forwardRef(function (props, ref) {
40943
+ var zValues = props.z ? props.data.map(function (d) {
40944
+ return d[props.z];
40945
+ }) : [];
40946
+ var normaliseArray = function normaliseArray(array, min, max) {
40947
+ var arrayMin = Math.min.apply(Math, array);
40948
+ var arrayMax = Math.max.apply(Math, array);
40949
+ return array.map(function (value) {
40950
+ return (value - arrayMin) / (arrayMax - arrayMin) * (max - min) + min;
40951
+ });
40952
+ };
40953
+ var scaledSizeValues = normaliseArray(zValues, 1, 30);
40954
+ var data = props.data.map(function (d, i) {
40955
+ return _extends({}, d, {
40956
+ bubbleSize: scaledSizeValues[i]
40957
+ });
40958
+ });
40959
+ var forceRerender = useChartForceRerender(ref);
40960
+ if (forceRerender) return null;
40961
+ return jsxRuntime.jsx(responsive.ParentSize, {
40962
+ children: function children(parent) {
40963
+ var _props$height, _props$width;
40964
+ return jsxRuntime.jsx(VizzlyBubbleChart, {
40965
+ isBubble: true,
40966
+ approxXAxisLabelCount: props.approxXAxisLabelCount,
40967
+ approxYAxisLabelCount: props.approxYAxisLabelCount,
40968
+ uniqueId: props.uniqueId,
40969
+ formatSeriesName: props.formatSeriesName,
40970
+ forceXAxisAsTime: props.forceXAxisAsTime,
40971
+ sparkline: props.sparkline,
40972
+ lines: {
40973
+ annotate: props.annotate || [],
40974
+ data: data,
40975
+ keys: props.keys,
40976
+ colors: props.colors,
40977
+ scatter: true
40978
+ },
40979
+ x: props.x,
40980
+ z: props.z,
40981
+ sharedTooltip: true,
40982
+ legend: props.legend,
40983
+ removeStroke: props == null ? void 0 : props.removeStroke,
40984
+ formatXAxisLabel: props == null ? void 0 : props.formatXAxisLabel,
40985
+ formatYAxisLabel: props == null ? void 0 : props.formatYAxisLabel,
40986
+ horizontal: props == null ? void 0 : props.horizontal,
40987
+ height: (_props$height = props == null ? void 0 : props.height) != null ? _props$height : parent == null ? void 0 : parent.height,
40988
+ width: (_props$width = props == null ? void 0 : props.width) != null ? _props$width : parent == null ? void 0 : parent.width,
40989
+ theme: props == null ? void 0 : props.theme,
40990
+ onClick: function onClick(datum) {
40991
+ return (props == null ? void 0 : props.onClick) && (props == null ? void 0 : props.onClick(datum));
40992
+ },
40993
+ goalLine: props == null ? void 0 : props.goalLine,
40994
+ axisTitles: props == null ? void 0 : props.axisTitles,
40995
+ idPrefix: props == null ? void 0 : props.idPrefix,
40996
+ popOverMenuStyles: props.popOverMenuStyles
40997
+ });
40998
+ }
40999
+ });
41000
+ });
41001
+
40750
41002
  var defaultProps$6 = {
40751
41003
  type: 'bubbleChart',
40752
41004
  xMeasure: null,
@@ -40834,7 +41086,7 @@ var BubbleChartView = function BubbleChartView(props) {
40834
41086
  queriesAreChanging: props.queriesAreChanging,
40835
41087
  children: [jsxRuntime.jsx(ViewHeader, _extends({}, headerProps)), jsxRuntime.jsx(ChartWrapper, {
40836
41088
  disabledFeatures: (_props$library2 = props.library) != null ? _props$library2 : false,
40837
- children: jsxRuntime.jsx(BubbleChart$3.BubbleChart, {
41089
+ children: jsxRuntime.jsx(BubbleChart$2, {
40838
41090
  ref: ref,
40839
41091
  approxXAxisLabelCount: props.approxXAxisLabelCount,
40840
41092
  approxYAxisLabelCount: props.approxYAxisLabelCount,
@@ -40879,7 +41131,7 @@ var BubbleChartView = function BubbleChartView(props) {
40879
41131
  BubbleChartView.defaultProps = defaultProps$6;
40880
41132
  var memoized$4 = /*#__PURE__*/React.memo(BubbleChartView, shouldUpdate);
40881
41133
 
40882
- var BubbleChart$2 = function BubbleChart(props) {
41134
+ var BubbleChart$3 = function BubbleChart(props) {
40883
41135
  var _props$dashboardBehav;
40884
41136
  var _props$component = props.component,
40885
41137
  results = _props$component.results,
@@ -48528,7 +48780,7 @@ var Component = function Component(props) {
48528
48780
  });
48529
48781
  },
48530
48782
  onError: dashboardBehaviour.onError,
48531
- children: jsxRuntime.jsx(BubbleChart$2, {
48783
+ children: jsxRuntime.jsx(BubbleChart$3, {
48532
48784
  id: props.id,
48533
48785
  setLocalFilters: props.setLocalFilters,
48534
48786
  dataSet: dataSet,
@@ -56991,6 +57243,22 @@ var ChartSettingsSection = function ChartSettingsSection(_ref) {
56991
57243
  }
56992
57244
  return options;
56993
57245
  }();
57246
+ var layoutOptions = function () {
57247
+ var options = [{
57248
+ label: textOverride('grouped', 'Grouped'),
57249
+ value: false
57250
+ }, {
57251
+ label: textOverride('stacked', 'Stacked'),
57252
+ value: true
57253
+ }];
57254
+ if (attributes.type === 'barChart' || attributes.type === 'areaChart') {
57255
+ options.push({
57256
+ label: textOverride('stacked_100prc', 'Stacked (100%)'),
57257
+ value: '100%'
57258
+ });
57259
+ }
57260
+ return options;
57261
+ }();
56994
57262
  return jsxRuntime.jsx(Section, {
56995
57263
  title: section.title,
56996
57264
  tooltip: section == null ? void 0 : section.description,
@@ -57010,16 +57278,7 @@ var ChartSettingsSection = function ChartSettingsSection(_ref) {
57010
57278
  stacked: stacked
57011
57279
  });
57012
57280
  },
57013
- options: [{
57014
- label: textOverride('grouped', 'Grouped'),
57015
- value: false
57016
- }, {
57017
- label: textOverride('stacked', 'Stacked'),
57018
- value: true
57019
- }, {
57020
- label: textOverride('stacked_100prc', 'Stacked (100%)'),
57021
- value: '100%'
57022
- }]
57281
+ options: layoutOptions
57023
57282
  }), section.type === 'curve' && jsxRuntime.jsx(FormatSelectInput, {
57024
57283
  label: section.title,
57025
57284
  id: "format-layout-curve",