Skip to content

Commit

Permalink
fix(slider,scrollbar): 修复slider 、scrollbar values 排序错误的问题 (#3773)
Browse files Browse the repository at this point in the history
Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
  • Loading branch information
ai-qing-hai and ai-qing-hai committed Jan 6, 2022
1 parent c799546 commit 6e84c44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/chart/controller/scrollbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class Scrollbar extends Controller<ScrollbarOption> {
const values = valuesOfKey(this.data, this.xScaleCfg.field);

// 如果是 xScale 数值类型,则进行排序
const xScaleValues = this.view.getXScale().isLinear ? values.sort() : values;
const xScaleValues = this.view.getXScale().isLinear ? values.sort((a, b) => Number(a) - Number(b)) : values;

const xValues = isHorizontal ? xScaleValues : xScaleValues.reverse();
this.yScalesCfg.forEach((cfg) => {
Expand Down
6 changes: 3 additions & 3 deletions src/chart/controller/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default class Slider extends Controller<SliderOption> {
const xScale = this.view.getXScale();
const isHorizontal = true;
let values = valuesOfKey(data, xScale.field);

// 如果是 xScale 数值类型,则进行排序
if (xScale.isLinear) {
values = values.sort();
Expand Down Expand Up @@ -322,8 +322,8 @@ export default class Slider extends Controller<SliderOption> {
const values = valuesOfKey(data, xScale.field);

// 如果是 xScale 数值类型,则进行排序
const xScaleValues = this.view.getXScale().isLinear ? values.sort() : values;
const xScaleValues = this.view.getXScale().isLinear ? values.sort((a, b) => Number(a) - Number(b)) : values;

const xValues = isHorizontal ? xScaleValues : xScaleValues.reverse();
const xTickCount = size(xValues);

Expand Down

0 comments on commit 6e84c44

Please sign in to comment.