Skip to content

Commit

Permalink
fix: Guide 的 position 百分比解析需要考虑原始数据中本身包含 '%' 的情况.Closed #590.
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Aug 31, 2019
1 parent 98b9f94 commit b299390
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/component/guide/base.js
Expand Up @@ -48,7 +48,8 @@ class GuideBase {
}

// 如果数据格式是 ['50%', '50%'] 的格式
if (Util.isString(position[0]) && position[0].indexOf('%') !== -1) {
// fix: 原始数据中可能会包含 'xxx5%xxx' 这样的数据,需要判断下 https://github.com/antvis/f2/issues/590
if (Util.isString(position[0]) && position[0].indexOf('%') !== -1 && !isNaN(position[0].slice(0, -1))) {
return this.parsePercentPoint(coord, position);
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit/component/guide/base-spec.js
Expand Up @@ -15,7 +15,7 @@ describe('Guide Base', function() {
}
});
const xScale = new Scale.Cat({
values: [ '一月', '二月', '三月', '四月', '五月' ]
values: [ '一月', '二月', '45%三月', '四月', '五月' ]
});

const yScale = new Scale.Linear({
Expand All @@ -24,7 +24,7 @@ describe('Guide Base', function() {
});

it('Base class method: parsePoint(coord, point)', function() {
const point = [ '三月', 600 ];
const point = [ '45%三月', 600 ];
const cfg = {
xScale,
yScales: [ yScale ]
Expand Down

0 comments on commit b299390

Please sign in to comment.