@gravity-ui/charts 1.27.3 → 1.27.5

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.
@@ -89,7 +89,7 @@ export async function prepareSvgYAxisTitle({ axis, axisTop, axisHeight, axisWidt
89
89
  : Math.min(0, calculateCos(rotateAngle) * originalTextSize.width);
90
90
  const x = axis.position === 'left'
91
91
  ? -left - axisLabelsWidth - axis.labels.margin - axis.title.margin
92
- : -left + axisWidth + axisLabelsWidth + axis.labels.margin + axis.title.margin;
92
+ : axisWidth + axisLabelsWidth + axis.labels.margin + axis.title.margin;
93
93
  return {
94
94
  html: false,
95
95
  content: titleContent,
@@ -60,12 +60,13 @@ function getMaxPaddingBySeries({ series }) {
60
60
  return 0.01;
61
61
  }
62
62
  export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth, }) => {
63
- var _a, _b, _c, _d, _e, _f, _g, _h;
63
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
64
64
  const hasAxisRelatedSeries = seriesData.some(isAxisRelatedSeries);
65
65
  if (!hasAxisRelatedSeries) {
66
66
  return Promise.resolve(null);
67
67
  }
68
- const titleText = get(xAxis, 'title.text', '');
68
+ const isAxisVisible = (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.visible) !== null && _a !== void 0 ? _a : true;
69
+ const titleText = isAxisVisible ? get(xAxis, 'title.text', '') : '';
69
70
  const titleStyle = Object.assign(Object.assign({}, xAxisTitleDefaults.style), get(xAxis, 'title.style'));
70
71
  const titleMaxRowsCount = get(xAxis, 'title.maxRowCount', xAxisTitleDefaults.maxRowCount);
71
72
  const estimatedTitleRows = (await wrapText({
@@ -77,18 +78,18 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
77
78
  labels: [titleText],
78
79
  style: titleStyle,
79
80
  });
80
- const isLabelsEnabled = (_b = (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true;
81
+ const isLabelsEnabled = isAxisVisible && ((_c = (_b = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : true);
81
82
  const labelsStyle = {
82
83
  fontSize: get(xAxis, 'labels.style.fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE),
83
84
  };
84
- const labelsHtml = (_d = (_c = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _c === void 0 ? void 0 : _c.html) !== null && _d !== void 0 ? _d : false;
85
+ const labelsHtml = (_e = (_d = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _d === void 0 ? void 0 : _d.html) !== null && _e !== void 0 ? _e : false;
85
86
  let labelsLineHeight = 0;
86
87
  if (isLabelsEnabled) {
87
88
  labelsLineHeight = labelsHtml
88
89
  ? getHorizontalHtmlTextHeight({ text: 'Tmp', style: labelsStyle })
89
90
  : getHorizontalSvgTextHeight({ text: 'Tmp', style: labelsStyle });
90
91
  }
91
- const shouldHideGrid = seriesData.some((s) => s.type === SERIES_TYPE.Heatmap);
92
+ const shouldHideGrid = isAxisVisible === false || seriesData.some((s) => s.type === SERIES_TYPE.Heatmap);
92
93
  const preparedRangeSlider = getPreparedRangeSlider({ xAxis });
93
94
  const maxPadding = preparedRangeSlider.enabled
94
95
  ? 0
@@ -106,7 +107,7 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
106
107
  width: 0,
107
108
  height: 0,
108
109
  lineHeight: labelsLineHeight,
109
- maxWidth: (_f = calculateNumericProperty({ base: width, value: (_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _e === void 0 ? void 0 : _e.maxWidth })) !== null && _f !== void 0 ? _f : axisLabelsDefaults.maxWidth,
110
+ maxWidth: (_g = calculateNumericProperty({ base: width, value: (_f = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _f === void 0 ? void 0 : _f.maxWidth })) !== null && _g !== void 0 ? _g : axisLabelsDefaults.maxWidth,
110
111
  html: labelsHtml,
111
112
  },
112
113
  lineColor: get(xAxis, 'lineColor'),
@@ -131,12 +132,12 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
131
132
  enabled: shouldHideGrid ? false : get(xAxis, 'grid.enabled', true),
132
133
  },
133
134
  ticks: {
134
- pixelInterval: ((_g = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _g === void 0 ? void 0 : _g.interval)
135
+ pixelInterval: ((_h = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _h === void 0 ? void 0 : _h.interval)
135
136
  ? calculateNumericProperty({
136
137
  base: width,
137
138
  value: xAxis.ticks.interval,
138
139
  })
139
- : (_h = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _h === void 0 ? void 0 : _h.pixelInterval,
140
+ : (_j = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _j === void 0 ? void 0 : _j.pixelInterval,
140
141
  },
141
142
  position: 'bottom',
142
143
  plotIndex: 0,
@@ -166,7 +167,7 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
166
167
  width: get(xAxis, 'crosshair.width', axisCrosshairDefaults.width),
167
168
  opacity: get(xAxis, 'crosshair.opacity', axisCrosshairDefaults.opacity),
168
169
  },
169
- visible: get(xAxis, 'visible', true),
170
+ visible: isAxisVisible,
170
171
  order: xAxis === null || xAxis === void 0 ? void 0 : xAxis.order,
171
172
  rangeSlider: preparedRangeSlider,
172
173
  };
@@ -89,7 +89,7 @@ export async function prepareSvgYAxisTitle({ axis, axisTop, axisHeight, axisWidt
89
89
  : Math.min(0, calculateCos(rotateAngle) * originalTextSize.width);
90
90
  const x = axis.position === 'left'
91
91
  ? -left - axisLabelsWidth - axis.labels.margin - axis.title.margin
92
- : -left + axisWidth + axisLabelsWidth + axis.labels.margin + axis.title.margin;
92
+ : axisWidth + axisLabelsWidth + axis.labels.margin + axis.title.margin;
93
93
  return {
94
94
  html: false,
95
95
  content: titleContent,
@@ -60,12 +60,13 @@ function getMaxPaddingBySeries({ series }) {
60
60
  return 0.01;
61
61
  }
62
62
  export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth, }) => {
63
- var _a, _b, _c, _d, _e, _f, _g, _h;
63
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
64
64
  const hasAxisRelatedSeries = seriesData.some(isAxisRelatedSeries);
65
65
  if (!hasAxisRelatedSeries) {
66
66
  return Promise.resolve(null);
67
67
  }
68
- const titleText = get(xAxis, 'title.text', '');
68
+ const isAxisVisible = (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.visible) !== null && _a !== void 0 ? _a : true;
69
+ const titleText = isAxisVisible ? get(xAxis, 'title.text', '') : '';
69
70
  const titleStyle = Object.assign(Object.assign({}, xAxisTitleDefaults.style), get(xAxis, 'title.style'));
70
71
  const titleMaxRowsCount = get(xAxis, 'title.maxRowCount', xAxisTitleDefaults.maxRowCount);
71
72
  const estimatedTitleRows = (await wrapText({
@@ -77,18 +78,18 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
77
78
  labels: [titleText],
78
79
  style: titleStyle,
79
80
  });
80
- const isLabelsEnabled = (_b = (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true;
81
+ const isLabelsEnabled = isAxisVisible && ((_c = (_b = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _b === void 0 ? void 0 : _b.enabled) !== null && _c !== void 0 ? _c : true);
81
82
  const labelsStyle = {
82
83
  fontSize: get(xAxis, 'labels.style.fontSize', DEFAULT_AXIS_LABEL_FONT_SIZE),
83
84
  };
84
- const labelsHtml = (_d = (_c = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _c === void 0 ? void 0 : _c.html) !== null && _d !== void 0 ? _d : false;
85
+ const labelsHtml = (_e = (_d = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _d === void 0 ? void 0 : _d.html) !== null && _e !== void 0 ? _e : false;
85
86
  let labelsLineHeight = 0;
86
87
  if (isLabelsEnabled) {
87
88
  labelsLineHeight = labelsHtml
88
89
  ? getHorizontalHtmlTextHeight({ text: 'Tmp', style: labelsStyle })
89
90
  : getHorizontalSvgTextHeight({ text: 'Tmp', style: labelsStyle });
90
91
  }
91
- const shouldHideGrid = seriesData.some((s) => s.type === SERIES_TYPE.Heatmap);
92
+ const shouldHideGrid = isAxisVisible === false || seriesData.some((s) => s.type === SERIES_TYPE.Heatmap);
92
93
  const preparedRangeSlider = getPreparedRangeSlider({ xAxis });
93
94
  const maxPadding = preparedRangeSlider.enabled
94
95
  ? 0
@@ -106,7 +107,7 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
106
107
  width: 0,
107
108
  height: 0,
108
109
  lineHeight: labelsLineHeight,
109
- maxWidth: (_f = calculateNumericProperty({ base: width, value: (_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _e === void 0 ? void 0 : _e.maxWidth })) !== null && _f !== void 0 ? _f : axisLabelsDefaults.maxWidth,
110
+ maxWidth: (_g = calculateNumericProperty({ base: width, value: (_f = xAxis === null || xAxis === void 0 ? void 0 : xAxis.labels) === null || _f === void 0 ? void 0 : _f.maxWidth })) !== null && _g !== void 0 ? _g : axisLabelsDefaults.maxWidth,
110
111
  html: labelsHtml,
111
112
  },
112
113
  lineColor: get(xAxis, 'lineColor'),
@@ -131,12 +132,12 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
131
132
  enabled: shouldHideGrid ? false : get(xAxis, 'grid.enabled', true),
132
133
  },
133
134
  ticks: {
134
- pixelInterval: ((_g = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _g === void 0 ? void 0 : _g.interval)
135
+ pixelInterval: ((_h = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _h === void 0 ? void 0 : _h.interval)
135
136
  ? calculateNumericProperty({
136
137
  base: width,
137
138
  value: xAxis.ticks.interval,
138
139
  })
139
- : (_h = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _h === void 0 ? void 0 : _h.pixelInterval,
140
+ : (_j = xAxis === null || xAxis === void 0 ? void 0 : xAxis.ticks) === null || _j === void 0 ? void 0 : _j.pixelInterval,
140
141
  },
141
142
  position: 'bottom',
142
143
  plotIndex: 0,
@@ -166,7 +167,7 @@ export const getPreparedXAxis = async ({ xAxis, seriesData, width, boundsWidth,
166
167
  width: get(xAxis, 'crosshair.width', axisCrosshairDefaults.width),
167
168
  opacity: get(xAxis, 'crosshair.opacity', axisCrosshairDefaults.opacity),
168
169
  },
169
- visible: get(xAxis, 'visible', true),
170
+ visible: isAxisVisible,
170
171
  order: xAxis === null || xAxis === void 0 ? void 0 : xAxis.order,
171
172
  rangeSlider: preparedRangeSlider,
172
173
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/charts",
3
- "version": "1.27.3",
3
+ "version": "1.27.5",
4
4
  "description": "React component used to render charts",
5
5
  "license": "MIT",
6
6
  "main": "dist/cjs/index.js",