@vizzly/dashboard 0.15.0-dev-adc0ad5ca8785acecefbc70dee9842ac6230d1c1 → 0.15.0-dev-9247c7b21e49fb5e3915574eb5264b609426a7b6

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.
@@ -14,5 +14,6 @@ export declare type AxisBottomProps = {
14
14
  xScaleDataType?: DataType;
15
15
  xScale: ScaleBand<string> | ScaleBand<Date> | ScaleBand<number> | ScaleLinear<number, number, never> | ScalePoint<string> | ScaleTime<number, number, never> | null;
16
16
  height: number;
17
+ adjustLabelPropsDueToSubgroupLabels?: boolean;
17
18
  };
18
- export declare function AxisBottom({ x, margin, themeCSS, show, removeStroke, xScaleDataType, xScale, height, baselineShift, }: AxisBottomProps): JSX.Element | null;
19
+ export declare function AxisBottom({ x, margin, themeCSS, show, removeStroke, xScaleDataType, xScale, height, baselineShift, adjustLabelPropsDueToSubgroupLabels, }: AxisBottomProps): JSX.Element | null;
@@ -12,6 +12,7 @@ export declare type BarChartProps = {
12
12
  showRoundedTotal: boolean;
13
13
  showLegend: boolean;
14
14
  showLabels: boolean;
15
+ showSublabels: boolean;
15
16
  removeStroke: boolean;
16
17
  axis: {
17
18
  showXAxisLabels: boolean;
@@ -11,6 +11,7 @@ export declare type HorizontalBarChartProps = {
11
11
  showRoundedTotal: boolean;
12
12
  showLegend: boolean;
13
13
  showLabels: boolean;
14
+ showSublabels: boolean;
14
15
  removeStroke: boolean;
15
16
  axis: {
16
17
  showXAxisLabels: boolean;
@@ -44814,7 +44814,7 @@ var buildMargin = function buildMargin(yTicks, showYAxisLabels, hasYAxisTitle, h
44814
44814
  var bottom = showDetailedSubGroupingLabels ? 90 : 40;
44815
44815
  var left = showYTicks ? _.max([maxWidth, MINIMUM_Y_AXIS_WIDTH]) : MINIMUM_Y_AXIS_WIDTH;
44816
44816
  return {
44817
- top: 15,
44817
+ top: showDetailedSubGroupingLabels ? 25 : 15,
44818
44818
  right: MINIMUM_Y_AXIS_WIDTH,
44819
44819
  bottom: 30 + xAxisTitleOffset,
44820
44820
  left: left + yAxisTitleOffset,
@@ -44893,7 +44893,9 @@ function AxisBottom(_ref) {
44893
44893
  xScaleDataType = _ref.xScaleDataType,
44894
44894
  xScale = _ref.xScale,
44895
44895
  height = _ref.height,
44896
- baselineShift = _ref.baselineShift;
44896
+ baselineShift = _ref.baselineShift,
44897
+ _ref$adjustLabelProps = _ref.adjustLabelPropsDueToSubgroupLabels,
44898
+ adjustLabelPropsDueToSubgroupLabels = _ref$adjustLabelProps === void 0 ? false : _ref$adjustLabelProps;
44897
44899
  var tickFormat = React.useCallback(function (value) {
44898
44900
  var tick = null;
44899
44901
  if (xScaleDataType === 'date_time' && value instanceof Date) {
@@ -44915,14 +44917,13 @@ function AxisBottom(_ref) {
44915
44917
  }
44916
44918
  return '';
44917
44919
  }, [x.ticks, xScaleDataType]);
44918
- if (!show) return null;
44919
- if (!xScale) return null;
44920
- return jsxRuntime.jsx(axis.AxisBottom, {
44920
+ var hasOnlyTitle = !show && x.title != null && x.title.trim() !== '';
44921
+ return xScale && jsxRuntime.jsx(axis.AxisBottom, {
44921
44922
  label: x.title || undefined,
44922
44923
  labelProps: {
44923
44924
  style: AXIS_TITLE_STYLES
44924
44925
  },
44925
- labelOffset: margin.bottomTitleOffset,
44926
+ labelOffset: margin.bottomTitleOffset - (hasOnlyTitle ? 20 : 0),
44926
44927
  hideTicks: true,
44927
44928
  top: height,
44928
44929
  scale: xScale,
@@ -44933,10 +44934,11 @@ function AxisBottom(_ref) {
44933
44934
  tickComponent: function tickComponent(_ref2) {
44934
44935
  var formattedValue = _ref2.formattedValue,
44935
44936
  tickProps = _objectWithoutPropertiesLoose(_ref2, _excluded$e);
44936
- return jsxRuntime.jsx(text$3.Text, _extends({
44937
+ return show && jsxRuntime.jsx(text$3.Text, _extends({
44937
44938
  style: themeCSS.labels
44938
44939
  }, tickProps, {
44939
44940
  baselineShift: baselineShift != null ? baselineShift : tickProps.baselineShift,
44941
+ dy: adjustLabelPropsDueToSubgroupLabels ? 60 : 0,
44940
44942
  children: formattedValue
44941
44943
  }));
44942
44944
  },
@@ -44963,7 +44965,6 @@ var AxisLeft = function AxisLeft(_ref) {
44963
44965
  }
44964
44966
  return item.formattedValue || item.value.toString();
44965
44967
  }, [y.ticks]);
44966
- if (!show) return null;
44967
44968
  return jsxRuntime.jsx(axis.AxisLeft, {
44968
44969
  labelOffset: margin.leftTitleOffset,
44969
44970
  label: y.title || undefined,
@@ -44979,7 +44980,7 @@ var AxisLeft = function AxisLeft(_ref) {
44979
44980
  tickComponent: function tickComponent(_ref2) {
44980
44981
  var formattedValue = _ref2.formattedValue,
44981
44982
  tickProps = _objectWithoutPropertiesLoose(_ref2, _excluded$f);
44982
- return jsxRuntime.jsx(text$3.Text, _extends({
44983
+ return show && jsxRuntime.jsx(text$3.Text, _extends({
44983
44984
  width: 10,
44984
44985
  style: themeCSS.labels
44985
44986
  }, tickProps, {
@@ -46107,8 +46108,8 @@ var useGroupingAxisBaseLineShift = function useGroupingAxisBaseLineShift(_ref) {
46107
46108
  };
46108
46109
  }
46109
46110
  return {
46110
- groupingAxisBaselineShift: hasBottomTitle ? -65 : -60,
46111
- bottomOffset: hasBottomTitle ? -15 : 10,
46111
+ groupingAxisBaselineShift: hasLeftTitle ? -65 : -60,
46112
+ bottomOffset: hasLeftTitle ? -15 : 10,
46112
46113
  leftOffset: hasLeftTitle ? -10 : 0
46113
46114
  };
46114
46115
  };
@@ -46169,9 +46170,11 @@ var BarChart$5 = function BarChart(_ref) {
46169
46170
  tooltipData = _useTooltip.tooltipData,
46170
46171
  hideTooltip = _useTooltip.hideTooltip,
46171
46172
  showTooltip = _useTooltip.showTooltip;
46172
- var showDetailedSubGroupingLabels = !options.stacked && numberOfDimensions === 2 && width > 450;
46173
- var hasBottomTitle = chart.x.title != null;
46174
- var hasLeftTitle = chart.y.title != null;
46173
+ var showDetailedSubGroupingLabels = !options.stacked && options.showSublabels === true && numberOfDimensions === 2 && width > 450;
46174
+ var isFirefox = typeof window !== 'undefined' && 'InstallTrigger' in window;
46175
+ var adjustAxisBottomLabelProps = isFirefox && showDetailedSubGroupingLabels;
46176
+ var hasBottomTitle = chart.x.title != null && chart.x.title.trim() !== '';
46177
+ var hasLeftTitle = chart.y.title != null && chart.y.title.trim() !== '';
46175
46178
  var isStacked100 = options.stacked === '100%';
46176
46179
  var _useGroupingAxisBaseL = useGroupingAxisBaseLineShift({
46177
46180
  hasBottomTitle: hasBottomTitle,
@@ -46349,7 +46352,8 @@ var BarChart$5 = function BarChart(_ref) {
46349
46352
  xScaleDataType: xScaleDataType,
46350
46353
  xScale: xScale,
46351
46354
  height: innerHeight,
46352
- baselineShift: groupingAxisBaselineShift
46355
+ baselineShift: groupingAxisBaselineShift,
46356
+ adjustLabelPropsDueToSubgroupLabels: adjustAxisBottomLabelProps
46353
46357
  }), jsxRuntime.jsx(AxisLeft, {
46354
46358
  show: options.axis.showYAxisLabels,
46355
46359
  y: yAxisConfig,
@@ -47270,7 +47274,7 @@ var HorizontalBarChart$3 = function HorizontalBarChart(_ref) {
47270
47274
  tooltipData = _useTooltip.tooltipData,
47271
47275
  hideTooltip = _useTooltip.hideTooltip,
47272
47276
  showTooltip = _useTooltip.showTooltip;
47273
- var showDetailedSubGroupingLabels = !options.stacked && numberOfDimensions === 2 && width > 450;
47277
+ var showDetailedSubGroupingLabels = !options.stacked && options.showSublabels === true && numberOfDimensions === 2 && width > 450;
47274
47278
  var hasBottomTitle = chart.x.title != null;
47275
47279
  var hasLeftTitle = chart.y.title != null;
47276
47280
  var _useGroupingAxisBaseL = useGroupingAxisBaseLineShift({
@@ -50846,6 +50850,7 @@ var BarChartV2View = function BarChartV2View(props) {
50846
50850
  showRoundedTotal: false,
50847
50851
  showLegend: props.attributes.legend,
50848
50852
  showLabels: (_props$attributes$lab = props.attributes.labels) != null ? _props$attributes$lab : false,
50853
+ showSublabels: props.attributes.approxXAxisLabelCount === 2,
50849
50854
  axis: {
50850
50855
  showXAxisLabels: props.attributes.approxXAxisLabelCount !== 0,
50851
50856
  showYAxisLabels: props.attributes.approxYAxisLabelCount !== 0
@@ -54624,6 +54629,7 @@ var HorizontalBarChartV2View = function HorizontalBarChartV2View(props) {
54624
54629
  showRoundedTotal: false,
54625
54630
  showLegend: props.attributes.legend,
54626
54631
  showLabels: (_props$attributes$lab = props.attributes.labels) != null ? _props$attributes$lab : false,
54632
+ showSublabels: props.attributes.approxYAxisLabelCount === 2,
54627
54633
  axis: {
54628
54634
  showXAxisLabels: props.attributes.approxXAxisLabelCount !== 0,
54629
54635
  showYAxisLabels: props.attributes.approxYAxisLabelCount !== 0
@@ -64909,11 +64915,11 @@ var SelectNumberFormat = function SelectNumberFormat(props) {
64909
64915
  };
64910
64916
 
64911
64917
  var AxisPreferenceSection = function AxisPreferenceSection(props) {
64912
- var _props$attributes, _props$attributes2, _props$attributes3, _props$attributes4, _props$section, _props$section2, _props$section$y, _props$section$y$form, _props$section$y$axis, _props$attributes$axi, _props$section$x$form, _props$section$x$form2, _props$section$x$axis, _props$attributes$axi2;
64918
+ var _props$attributes, _props$attributes2, _props$attributes3, _props$attributes4, _props$attributes5, _props$section, _props$section2, _props$section$y, _props$section$y$form, _props$section$y$axis, _props$attributes$axi, _props$section$x$form, _props$section$x$form2, _props$section$x$axis, _props$attributes$axi2;
64913
64919
  var _useDashboardBehaviou = useDashboardBehaviourContext(),
64914
64920
  textOverride = _useDashboardBehaviou.textOverride,
64915
64921
  dateTimeFormatOptions = _useDashboardBehaviou.dateTimeFormatOptions;
64916
- var axisOptions = [{
64922
+ var axisLabelCountOptionsItems = [{
64917
64923
  label: textOverride('auto', 'Auto'),
64918
64924
  value: 'auto'
64919
64925
  }, {
@@ -64923,6 +64929,16 @@ var AxisPreferenceSection = function AxisPreferenceSection(props) {
64923
64929
  label: textOverride('None', 'None'),
64924
64930
  value: 0
64925
64931
  }];
64932
+ var axisLabelSettingsOptionsItems = [{
64933
+ label: textOverride('hideAllLabels', 'Hide All Labels'),
64934
+ value: 0
64935
+ }, {
64936
+ label: textOverride('hideSublabels', 'Hide Sublabels'),
64937
+ value: 'auto'
64938
+ }, {
64939
+ label: textOverride('showEverything', 'Show Everything'),
64940
+ value: 2
64941
+ }];
64926
64942
  var dateTimeFormatOptionsItems = Object.keys(dateTimeFormatOptions).map(function (key) {
64927
64943
  var option = dateTimeFormatOptions[key];
64928
64944
  return {
@@ -64930,10 +64946,12 @@ var AxisPreferenceSection = function AxisPreferenceSection(props) {
64930
64946
  value: key
64931
64947
  };
64932
64948
  });
64933
- var horizontal = props.attributes.type == 'horizontalBarChart' || props.attributes.type == 'horizontalBarChartV2';
64949
+ var isBarChartV2 = props.attributes.type == 'barChartV2' || props.attributes.type == 'horizontalBarChartV2';
64950
+ var isHorizontalBarChart = props.attributes.type == 'horizontalBarChart' || props.attributes.type == 'horizontalBarChartV2';
64934
64951
  var showXAxisNumberFormatter = ((_props$attributes = props.attributes) == null || (_props$attributes = _props$attributes.dimension) == null ? void 0 : _props$attributes.length) > 0 && findField(props.dataSet, (_props$attributes2 = props.attributes) == null || (_props$attributes2 = _props$attributes2.dimension[0]) == null ? void 0 : _props$attributes2.field).dataType === 'number' && !((_props$attributes3 = props.attributes) != null && _props$attributes3.timeDimension);
64935
64952
  var showXAxisDateFormatOptions = !!((_props$attributes4 = props.attributes) != null && _props$attributes4.timeDimension);
64936
- var _ref = horizontal ? {
64953
+ var showXAxisLabelSettings = isBarChartV2 && ((_props$attributes5 = props.attributes) == null || (_props$attributes5 = _props$attributes5.dimension) == null ? void 0 : _props$attributes5.length) > 1;
64954
+ var _ref = isHorizontalBarChart ? {
64937
64955
  x: 'y',
64938
64956
  y: 'x'
64939
64957
  } : {
@@ -64942,8 +64960,37 @@ var AxisPreferenceSection = function AxisPreferenceSection(props) {
64942
64960
  },
64943
64961
  x = _ref.x,
64944
64962
  y = _ref.y;
64945
- var labelCount = horizontal ? 'approxYAxisLabelCount' : 'approxXAxisLabelCount';
64946
- var metricAxisLabelCount = horizontal ? 'approxXAxisLabelCount' : 'approxYAxisLabelCount';
64963
+ var labelCount = isHorizontalBarChart ? 'approxYAxisLabelCount' : 'approxXAxisLabelCount';
64964
+ var metricAxisLabelCount = isHorizontalBarChart ? 'approxXAxisLabelCount' : 'approxYAxisLabelCount';
64965
+ var xAxisLabelSettingsSelectInput = jsxRuntime.jsx(FormatSelectInput, {
64966
+ id: "axis-" + x + "-label-settings",
64967
+ label: "Label Settings",
64968
+ currentValue: props.attributes[labelCount],
64969
+ onSelect: function onSelect(value) {
64970
+ var _props$setAttributes;
64971
+ return props.setAttributes((_props$setAttributes = {}, _props$setAttributes[labelCount] = value, _props$setAttributes));
64972
+ },
64973
+ options: axisLabelSettingsOptionsItems
64974
+ });
64975
+ var xAxisDateFormatLabelSelectInput = showXAxisLabelSettings ? xAxisLabelSettingsSelectInput : jsxRuntime.jsx(FormatSelectInput, {
64976
+ id: "axis-" + x + "-label-count",
64977
+ label: props.section[x].count.title,
64978
+ currentValue: props.attributes[labelCount],
64979
+ onSelect: function onSelect(value) {
64980
+ var _props$setAttributes2;
64981
+ return props.setAttributes((_props$setAttributes2 = {}, _props$setAttributes2[labelCount] = value, _props$setAttributes2));
64982
+ },
64983
+ options: axisLabelCountOptionsItems
64984
+ });
64985
+ var xAxisOtherFormatsLabelSelectInput = showXAxisLabelSettings ? xAxisLabelSettingsSelectInput : jsxRuntime.jsx(Checkbox, {
64986
+ label: textOverride('hide_labels', 'Hide Labels'),
64987
+ onChange: function onChange(event) {
64988
+ var _props$setAttributes3;
64989
+ return props.setAttributes((_props$setAttributes3 = {}, _props$setAttributes3[labelCount] = event ? 0 : 'auto', _props$setAttributes3));
64990
+ },
64991
+ id: "hide-labels",
64992
+ currentValue: props.attributes[labelCount] === 0 ? true : false
64993
+ });
64947
64994
  return jsxRuntime.jsx(Section, {
64948
64995
  title: (_props$section = props.section) == null ? void 0 : _props$section.title,
64949
64996
  tooltip: (_props$section2 = props.section) == null ? void 0 : _props$section2.description,
@@ -64992,10 +65039,10 @@ var AxisPreferenceSection = function AxisPreferenceSection(props) {
64992
65039
  label: props.section[y].count.title,
64993
65040
  currentValue: props.attributes[metricAxisLabelCount],
64994
65041
  onSelect: function onSelect(value) {
64995
- var _props$setAttributes;
64996
- return props.setAttributes((_props$setAttributes = {}, _props$setAttributes[metricAxisLabelCount] = value, _props$setAttributes));
65042
+ var _props$setAttributes4;
65043
+ return props.setAttributes((_props$setAttributes4 = {}, _props$setAttributes4[metricAxisLabelCount] = value, _props$setAttributes4));
64997
65044
  },
64998
- options: axisOptions
65045
+ options: axisLabelCountOptionsItems
64999
65046
  })]
65000
65047
  }), jsxRuntime.jsx(Section.Grid, {
65001
65048
  children: props.section[y].axisTitle && jsxRuntime.jsx(TextInput, {
@@ -65059,25 +65106,8 @@ var AxisPreferenceSection = function AxisPreferenceSection(props) {
65059
65106
  });
65060
65107
  },
65061
65108
  options: dateTimeFormatOptionsItems
65062
- }), jsxRuntime.jsx(FormatSelectInput, {
65063
- id: "axis-" + x + "-label-count",
65064
- label: props.section[x].count.title,
65065
- currentValue: props.attributes[labelCount],
65066
- onSelect: function onSelect(value) {
65067
- var _props$setAttributes2;
65068
- return props.setAttributes((_props$setAttributes2 = {}, _props$setAttributes2[labelCount] = value, _props$setAttributes2));
65069
- },
65070
- options: axisOptions
65071
- })]
65072
- }) : jsxRuntime.jsx(Checkbox, {
65073
- label: textOverride('hide_labels', 'Hide Labels'),
65074
- onChange: function onChange(event) {
65075
- var _props$setAttributes3;
65076
- return props.setAttributes((_props$setAttributes3 = {}, _props$setAttributes3[labelCount] = event ? 0 : 'auto', _props$setAttributes3));
65077
- },
65078
- id: "hide-labels",
65079
- currentValue: props.attributes[labelCount] === 0 ? true : false
65080
- })]
65109
+ }), xAxisDateFormatLabelSelectInput]
65110
+ }) : xAxisOtherFormatsLabelSelectInput]
65081
65111
  })
65082
65112
  }), jsxRuntime.jsx(Section.Grid, {
65083
65113
  children: props.section[x].axisTitle && jsxRuntime.jsx(TextInput, {