From c1b5c85b4ef68b85cda7a67340c5dda49c7501cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=A2=E4=B8=98?= Date: Fri, 26 Feb 2021 12:13:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DhollowCircle=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E5=92=8C=E5=A4=9Ageom=E6=97=B6=EF=BC=8Ccrosshairs?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= =?UTF-8?q?Fixed=20#1140?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphic/engine/element.js | 2 +- test/bug/issue-1140-spec.js | 131 ++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 test/bug/issue-1140-spec.js diff --git a/src/graphic/engine/element.js b/src/graphic/engine/element.js index f7f0ac6e0..ea97eb4ed 100644 --- a/src/graphic/engine/element.js +++ b/src/graphic/engine/element.js @@ -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)) { diff --git a/test/bug/issue-1140-spec.js b/test/bug/issue-1140-spec.js new file mode 100644 index 000000000..1b77658cd --- /dev/null +++ b/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); + }); +});