@gitlab/ui 86.13.0 → 86.13.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [86.13.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v86.13.0...v86.13.1) (2024-07-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **GlSparklineChart:** Render flat lines with gradient enabled ([a8ad20f](https://gitlab.com/gitlab-org/gitlab-ui/commit/a8ad20f3ffa3efeb7cc545a0e7183b54434a97d2))
7
+
1
8
  # [86.13.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v86.12.1...v86.13.0) (2024-07-17)
2
9
 
3
10
 
@@ -134,15 +134,18 @@ var script = {
134
134
  const mergedOptions = merge({}, defaultChartOptions, sparkLineChartOptions);
135
135
  return mergeSeriesToOptions(mergedOptions, this.series);
136
136
  },
137
+ willShowLastYValue() {
138
+ return this.showLastYValue && this.data.length;
139
+ },
137
140
  series() {
138
141
  const {
139
142
  data,
140
143
  smooth,
141
144
  itemStyle,
142
- showLastYValue,
145
+ willShowLastYValue,
143
146
  connectNulls
144
147
  } = this;
145
- const markPoint = showLastYValue ? {
148
+ const markPoint = willShowLastYValue ? {
146
149
  symbol: 'circle',
147
150
  cursor: 'auto',
148
151
  animation: false,
@@ -170,14 +173,34 @@ var script = {
170
173
  };
171
174
  },
172
175
  itemStyle() {
173
- if (this.gradient.length) {
176
+ if (this.applyGradient) {
174
177
  return {
175
178
  color: generateGradient(this.gradient)
176
179
  };
177
180
  }
181
+ if (this.gradient.length) {
182
+ // If the gradient cannot be used, then apply
183
+ // the first colour to the entire line.
184
+ return {
185
+ color: this.gradient[0]
186
+ };
187
+ }
178
188
  return {};
179
189
  },
190
+ applyGradient() {
191
+ if (this.gradient.length && this.data.length) {
192
+ // Applying a gradient a constant line will cause it to not render,
193
+ // so skip the gradient if all values are equal.
194
+ const [, firstValue] = this.data[0];
195
+ return this.data.some(_ref => {
196
+ let [, value] = _ref;
197
+ return firstValue !== value;
198
+ });
199
+ }
200
+ return false;
201
+ },
180
202
  lastYValue() {
203
+ if (!this.willShowLastYValue) return undefined;
181
204
  const latestEntry = this.data.slice(-1)[0];
182
205
  return latestEntry[1];
183
206
  },
@@ -214,10 +237,10 @@ var script = {
214
237
  // This function is called any time the axis pointer is changed (the black bubble showing which
215
238
  // point on the line is selected). Note that it will not trigger if the axis pointer is removed,
216
239
  // only when it changes from one point to another or is shown for the first time.
217
- generateTooltip(_ref) {
240
+ generateTooltip(_ref2) {
218
241
  let {
219
242
  seriesData = []
220
- } = _ref;
243
+ } = _ref2;
221
244
  this.tooltip.show = false;
222
245
 
223
246
  // seriesData is an array of nearby data point coordinates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "86.13.0",
3
+ "version": "86.13.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -111,7 +111,7 @@
111
111
  "@babel/preset-env": "^7.24.8",
112
112
  "@babel/preset-react": "^7.24.7",
113
113
  "@cypress/grep": "^4.0.1",
114
- "@gitlab/eslint-plugin": "19.5.0",
114
+ "@gitlab/eslint-plugin": "19.6.0",
115
115
  "@gitlab/fonts": "^1.3.0",
116
116
  "@gitlab/stylelint-config": "6.1.0",
117
117
  "@gitlab/svgs": "3.105.0",
@@ -139,9 +139,12 @@ export default {
139
139
  const mergedOptions = merge({}, defaultChartOptions, sparkLineChartOptions);
140
140
  return mergeSeriesToOptions(mergedOptions, this.series);
141
141
  },
142
+ willShowLastYValue() {
143
+ return this.showLastYValue && this.data.length;
144
+ },
142
145
  series() {
143
- const { data, smooth, itemStyle, showLastYValue, connectNulls } = this;
144
- const markPoint = showLastYValue
146
+ const { data, smooth, itemStyle, willShowLastYValue, connectNulls } = this;
147
+ const markPoint = willShowLastYValue
145
148
  ? {
146
149
  symbol: 'circle',
147
150
  cursor: 'auto',
@@ -171,12 +174,29 @@ export default {
171
174
  };
172
175
  },
173
176
  itemStyle() {
174
- if (this.gradient.length) {
177
+ if (this.applyGradient) {
175
178
  return { color: generateGradient(this.gradient) };
176
179
  }
180
+ if (this.gradient.length) {
181
+ // If the gradient cannot be used, then apply
182
+ // the first colour to the entire line.
183
+ return { color: this.gradient[0] };
184
+ }
177
185
  return {};
178
186
  },
187
+ applyGradient() {
188
+ if (this.gradient.length && this.data.length) {
189
+ // Applying a gradient a constant line will cause it to not render,
190
+ // so skip the gradient if all values are equal.
191
+ const [, firstValue] = this.data[0];
192
+ return this.data.some(([, value]) => firstValue !== value);
193
+ }
194
+
195
+ return false;
196
+ },
179
197
  lastYValue() {
198
+ if (!this.willShowLastYValue) return undefined;
199
+
180
200
  const latestEntry = this.data.slice(-1)[0];
181
201
 
182
202
  return latestEntry[1];