Tanimodori
Tanimodori
除了没加载完就绘制以外,还有一个可能的原因: 太长不看的解决方案:使用前景色为白色(`#ffffffff`),背景色为透明(`#xxxxxx00`)的`maskImage`(实测`svg`格式可行) 原因分析: 1. `registerLayout`中当`maskImage`存在时调用`updateCanvasMask`更新`canvas`。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/wordCloud.js#L75-L85 2.`updateCanvasMask`中创建了一份`ImageData`副本`newImageData`。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/wordCloud.js#L13-L18 3. `toneSum`计算所有像素点上RGB值的和,`toneCnt`计算像素点数。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/wordCloud.js#L20-L31 4. 每个像素点上RGB的平均值即为RGB阈值`threshold`。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/wordCloud.js#L32 5.由于`backgroundColor`规定是`#ffffffff`,所以应绘制区域上的像素点上的`Alpha`必须小于128,`RGB`必须小于`threshold`。坑点来了:假设传入图像是纯色块,由于传入图像在`getImageData`中经历了**栅格化操作**以及**浮点误差**的存在,导致图像有一些像素点因为略微小于`threshold`而被错误归入非绘制区域。最后更新`canvas`。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/wordCloud.js#L34-L58 6. `start`中根据`gridSize`将全图划分`ngx * ngy`个区域存放在数组`grid`中,网格`grid[gx][gy]`是可绘制的(`grid[gx][gy]===true`),当且仅当`imageData[gx*g .. (gx+1)*g-1][gy*g .. (gy+1)*g-1]`里的像素**全部**都位于可绘制的区域内(`!==backgroundColor`),但是由于第5点中有一些像素点被错误分类了,所以很可能导致没有区域满足这个条件(因为要求**全部**像素点可绘制),于是你就得到了一个全为`false`的`grid`。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/layout.js#L1035-L1065 7. 然后你调用`putWord->tryToPutWordAtPoint->canFitText`就会提前返回而不绘制,最后得到一片空白。 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/layout.js#L896-L906 https://github.com/ecomfe/echarts-wordcloud/blob/52ce56c5a939e9ccbc6045ce79ceeb2073de8394/src/layout.js#L658-L679 8....
> 新增一个参数 新增到哪里了 这只是提供一个可能的改进方案,显然官方并没有修这个bug的想法。
It's a bug in `echarts-for-react`. Applying this PR patch https://github.com/hustcc/echarts-for-react/pull/307 will fix the problem.
I understand how much work has to be done to support i18n, but it does not mean that you have to do it at once. You can do it step...
This is caused by electron trying to download its binary. Setup a mirror may help: ```cmd npm config set electron_mirror https://npmmirror.com/mirrors/electron/ ```
Of course you can search `#foo` in this example, but some libraries may rely on this feature (e.g. `document.querySelector` should return `null` when `tagName` does not match)
According to [this W3C selector document](https://drafts.csswg.org/selectors-4/#overview), `E#myid` is a valid selector and considered as "an `E` element with ID equal to `myid`."
fix issue #576, all tests passed (include the addition one)
I found that the data is set to `undefined` when the request fails instead of retaining last results. If this is the expected behaviour never mind what I said.
#82 如果出错也不会重置的话,还是加上去比较好。