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

3.2.1版本渐变色解析异常 #288

Closed
HelloSoul opened this Issue Aug 29, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@HelloSoul

HelloSoul commented Aug 29, 2018

error in parsing gradient string, please check if there are any extra whitespaces.

TypeError: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite.
at i (index-769c59324d.js:3466)
at Object.parseStyle (index-769c59324d.js:3481)
at e.t.resetContext (index-769c59324d.js:2406)
at e.t.setContext (index-769c59324d.js:2400)
at e.t.draw (index-769c59324d.js:2398)
at e.drawInner (index-769c59324d.js:2564)
at e.t.draw (index-769c59324d.js:2398)
at e.drawInner (index-769c59324d.js:2564)
at e.t.draw (index-769c59324d.js:2398)
at t (index-769c59324d.js:3434)
具体现象:
折线图变换数据(坐标点个数由4个变成2个)后会抛出上面的异常,不知是否是数据改变导致的,
渐变色代码:
this.chart.line().position('id*ratio').style({
lineWidth: 3,
stroke: 'l(0) 0:#0DC2B3 0.5:#2FD2E7 1:#3DEA95'
}).shape('smooth');

@simaQ

This comment has been minimized.

Contributor

simaQ commented Aug 29, 2018

恩,这个错误提示的意思是stroke: 'l(0) 0:#0DC2B3 0.5:#2FD2E7 1:#3DEA95' 字符串中存在空格,为了提升性能,未使用正则表达式解析渐变色字符串,请严格按照要求填写,除去色值区域,其余不要留有空格。

我复制你的代码是 OK 的呢,写着也没有问题,你检查下是否有多余的空格

.style({
    lineWidth: 3,
    stroke: 'l(0) 0:#0DC2B3 0.5:#2FD2E7 1:#3DEA95'
  })

image

@HelloSoul

This comment has been minimized.

HelloSoul commented Aug 30, 2018

我这边第一次绘制render()是没有问题的,但当我改变数据的之后,坐标点个数由4个变成2个,再通过repaint()重绘时就抛出异常了,
而且只有从4个数据点变到2个数据点的时候才抛异常

@simaQ

This comment has been minimized.

Contributor

simaQ commented Aug 30, 2018

那请按照 issue 模板,提供可复现的代码吧~

@simaQ simaQ self-assigned this Sep 3, 2018

@simaQ simaQ added the bug label Sep 3, 2018

@simaQ simaQ closed this in 2e4a90b Sep 3, 2018

simaQ added a commit that referenced this issue Sep 3, 2018

Merge pull request #304 from antvis/fix-issue-288
fix: attrs should be deep clone. Closed #288.
@simaQ

This comment has been minimized.

Contributor

simaQ commented Sep 3, 2018

升级至 3.2.2-beta.4 版本尝试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment