@antv/g2 4.1.36 → 4.1.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2",
3
- "version": "4.1.36",
3
+ "version": "4.1.37",
4
4
  "description": "the Grammar of Graphics in Javascript",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -55,7 +55,7 @@ export default class Scrollbar extends Controller<ScrollbarOption> {
55
55
  this.view.off(VIEW_LIFE_CIRCLE.BEFORE_CHANGE_SIZE, this.resetMeasure);
56
56
  }
57
57
 
58
- public init() {}
58
+ public init() { }
59
59
 
60
60
  /**
61
61
  * 渲染
@@ -240,7 +240,11 @@ export default class Scrollbar extends Controller<ScrollbarOption> {
240
240
  const { type } = this.getValidScrollbarCfg();
241
241
  const isHorizontal = type !== 'vertical';
242
242
  const values = valuesOfKey(this.data, this.xScaleCfg.field);
243
- const xValues = isHorizontal ? values : values.reverse();
243
+
244
+ // 如果是 xScale 数值类型,则进行排序
245
+ const xScaleValues = this.view.getXScale().isLinear ? values.sort() : values;
246
+
247
+ const xValues = isHorizontal ? xScaleValues : xScaleValues.reverse();
244
248
  this.yScalesCfg.forEach((cfg) => {
245
249
  this.view.scale(cfg.field, {
246
250
  formatter: cfg.formatter,
@@ -281,11 +285,11 @@ export default class Scrollbar extends Controller<ScrollbarOption> {
281
285
  const config = this.getScrollbarComponentCfg();
282
286
  const realConfig = this.trackLen
283
287
  ? {
284
- ...config,
285
- trackLen: this.trackLen,
286
- thumbLen: this.thumbLen,
287
- thumbOffset: (this.trackLen - this.thumbLen) * this.ratio,
288
- }
288
+ ...config,
289
+ trackLen: this.trackLen,
290
+ thumbLen: this.thumbLen,
291
+ thumbOffset: (this.trackLen - this.thumbLen) * this.ratio,
292
+ }
289
293
  : { ...config };
290
294
  this.scrollbar.component.update(realConfig);
291
295
 
@@ -320,13 +324,13 @@ export default class Scrollbar extends Controller<ScrollbarOption> {
320
324
  const [paddingTop, paddingRight, paddingBottom, paddingLeft] = padding;
321
325
  const position = isHorizontal
322
326
  ? {
323
- x: coordinateBBox.minX + paddingLeft,
324
- y: viewBBox.maxY - height - paddingBottom,
325
- }
327
+ x: coordinateBBox.minX + paddingLeft,
328
+ y: viewBBox.maxY - height - paddingBottom,
329
+ }
326
330
  : {
327
- x: viewBBox.maxX - width - paddingRight,
328
- y: coordinateBBox.minY + paddingTop,
329
- };
331
+ x: viewBBox.maxX - width - paddingRight,
332
+ y: coordinateBBox.minY + paddingTop,
333
+ };
330
334
  const step = this.getStep();
331
335
  const cnt = this.getCnt();
332
336
  const trackLen = isHorizontal
@@ -272,7 +272,13 @@ export default class Slider extends Controller<SliderOption> {
272
272
  const data = this.view.getOptions().data;
273
273
  const xScale = this.view.getXScale();
274
274
  const isHorizontal = true;
275
- const values = valuesOfKey(data, xScale.field);
275
+ let values = valuesOfKey(data, xScale.field);
276
+
277
+ // 如果是 xScale 数值类型,则进行排序
278
+ if (xScale.isLinear) {
279
+ values = values.sort();
280
+ }
281
+
276
282
  const xValues = isHorizontal ? values : values.reverse();
277
283
  const dataSize = size(data);
278
284
 
@@ -314,7 +320,11 @@ export default class Slider extends Controller<SliderOption> {
314
320
  }
315
321
  const isHorizontal = true;
316
322
  const values = valuesOfKey(data, xScale.field);
317
- const xValues = isHorizontal ? values : values.reverse();
323
+
324
+ // 如果是 xScale 数值类型,则进行排序
325
+ const xScaleValues = this.view.getXScale().isLinear ? values.sort() : values;
326
+
327
+ const xValues = isHorizontal ? xScaleValues : xScaleValues.reverse();
318
328
  const xTickCount = size(xValues);
319
329
 
320
330
  const minIndex = Math.floor(min * (xTickCount - 1));
package/src/core.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /* G2 的一个壳子,不包含 Geometry,由开发者自己定义和引入 */
2
2
 
3
- export const VERSION = '4.1.36';
3
+ export const VERSION = '4.1.37';
4
4
 
5
5
  // 核心基类导出
6
6
  export { Chart, View, Event } from './chart'; // Chart, View 类