Skip to content

Commit

Permalink
fix: 修复hollowCircle报错和多geom时,crosshairs不显示的问题。Fixed #1140
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed Feb 26, 2021
1 parent 268f5b4 commit c1b5c85
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/graphic/engine/element.js
Expand Up @@ -172,7 +172,7 @@ class Element {
for (const k in elAttrs) {
if (SHAPE_ATTRS.indexOf(k) > -1) {
let v = elAttrs[k];
if (k === 'fillStyle' || k === 'strokeStyle') {
if ((k === 'fillStyle' || k === 'strokeStyle') && v) {
v = parseStyle(v, this, context);
}
if (k === 'lineDash' && context.setLineDash && isArray(v)) {
Expand Down
131 changes: 131 additions & 0 deletions test/bug/issue-1140-spec.js
@@ -0,0 +1,131 @@
import F2 from '../../src/index';

const canvas = document.createElement('canvas');
canvas.style.width = '350px';
canvas.style.height = '300px';
document.body.appendChild(canvas);

describe('issue 1140', () => {
it('hollowCircle 和 tooltip crosshairs 都正常显示', () => {
const data = [{
time: '2016-08-08 00:00:00',
value: 10,
type: '预期收益率'
}, {
time: '2016-08-08 00:10:00',
value: 22,
type: '预期收益率'
}, {
time: '2016-08-08 00:30:00',
value: 16,
type: '预期收益率'
}, {
time: '2016-08-09 00:35:00',
value: 26,
type: '预期收益率'
}, {
time: '2016-08-09 01:00:00',
value: 12,
type: '预期收益率'
}, {
time: '2016-08-09 01:20:00',
value: 26,
type: '预期收益率'
}, {
time: '2016-08-10 01:40:00',
value: 18,
type: '预期收益率'
}, {
time: '2016-08-10 02:00:00',
value: 26,
type: '预期收益率'
}, {
time: '2016-08-10 02:20:00',
value: 12,
type: '预期收益率'
}, {
time: '2016-08-08 00:00:00',
value: 4,
type: '实际收益率'
}, {
time: '2016-08-08 00:10:00',
value: 3,
type: '实际收益率'
}, {
time: '2016-08-08 00:30:00',
value: 6,
type: '实际收益率'
}, {
time: '2016-08-09 00:35:00',
value: -12,
type: '实际收益率'
}, {
time: '2016-08-09 01:00:00',
value: 1,
type: '实际收益率1'
}, {
time: '2016-08-09 01:20:00',
value: 9,
type: '实际收益率1'
}, {
time: '2016-08-10 01:40:00',
value: 13,
type: '实际收益率1'
}, {
time: '2016-08-10 02:00:00',
value: -3,
type: '实际收益率1'
}, {
time: '2016-08-10 02:20:00',
value: 11,
type: '实际收益率1'
}];

const chart = new F2.Chart({
el: canvas,
pixelRatio: window.devicePixelRatio
});

chart.source(data, {
time: {
type: 'timeCat',
tickCount: 3,
mask: 'hh:mm',
range: [ 0, 1 ]
},
value: {
tickCount: 3,
formatter: function formatter(ivalue) {
return ivalue + '%';
}
}
});

chart.tooltip({
showCrosshairs: true
});

chart.line()
.position('time*value')
.color('type');

chart.point()
.position('time*value')
.color('type')
.shape('type', [ 'circle', 'hollowCircle', 'rect' ]);

chart.render();

const point = chart.getPosition({
time: '2016-08-09 01:00:00',
value: 1,
type: '实际收益率1'
});
chart.showTooltip(point);

const tooltipController = chart.get('tooltipController');
const tooltip = tooltipController.tooltip;

expect(tooltip.showCrosshairs).toBe(true);
});
});

0 comments on commit c1b5c85

Please sign in to comment.