Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the error that when the grid is a function and specify the t… #332

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chart/controller/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class AxisController {
});
axis.gridPoints = gridPoints;

if (coord.isPolar && grid.type === 'arc') {
if (coord.isPolar) {
axis.center = coord.center;
axis.startAngle = coord.startAngle;
axis.endAngle = coord.endAngle;
Expand Down
75 changes: 75 additions & 0 deletions test/bug/issue-331-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const expect = require('chai').expect;
const F2 = require('../../src/core');
require('../../src/geom/line');
require('../../src/coord/polar');
require('../../src/component/axis/circle');

const canvas = document.createElement('canvas');
canvas.width = 375;
canvas.height = 260;
canvas.id = 'issue331';
document.body.appendChild(canvas);

describe('Issue 331', () => {
it('Issue 331', () => {
const recentOneMonth = [
{ name: '超大盘能力', value: 6.5 },
{ name: '抗跌能力', value: 9.5 },
{ name: '稳定能力', value: 9 },
{ name: '绝对收益能力', value: 10 },
{ name: '选证择时能力', value: 4 },
{ name: '风险回报能力', value: 8 }
];
const chart = new F2.Chart({
id: 'issue331',
pixelRatio: window.devicePixelRatio
});

chart.source(recentOneMonth, {
value: {
min: 0,
max: 10,
tickCount: 10
}
});
chart.coord('polar');
chart.axis('value', {
grid: () => {
return {
lineWidth: 1,
type: 'arc',
lineDash: null
};
},
label: null,
line: null
});
chart.axis('name', {
grid: {
lineDash: null
},
label: {
opacity: 0.4,
stroke: 'white'
}
});

chart
.line()
.position('name*value')
.color('#FE5C5B')
.size(2)
.shape('smooth');

chart.render();

const axisController = chart.get('axisController');
const axes = axisController.axes;
const radiusAxis = axes.radius;
const coord = chart.get('coord');
expect(radiusAxis.grid).to.be.an.instanceof(Function);
expect(radiusAxis.center).to.eql(coord.center);
expect(radiusAxis.startAngle).to.eql(coord.startAngle);
expect(radiusAxis.endAngle).to.eql(coord.endAngle);
});
});