echarts icon indicating copy to clipboard operation
echarts copied to clipboard

I'm hitting an infinite loop error inside of Animator.js

Open cosmicscr opened this issue 10 years ago • 2 comments

问题简述 (One-line summary)

Animator.js:56 Uncaught TypeError: Cannot read property 'length' of undefinedinterpolateArray 
@ Animator.js:56onframe 
@ Animator.js:390Animator.start.lastClip.onframe 
@ Animator.js:564fire 
@ Clip.js:100step 
@ Clip.js:70_update 
@ Animation.js:126step 
@ Animation.js:173

screen shot 2016-11-09 at 1 30 19 pm

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version):
  • 浏览器类型和版本 (Browser version):
  • 操作系统类型和版本 (OS Version):

重现步骤 (Steps to reproduce)

After instantiating my chart with setOption I'm getting an infinite loop inside Animator.js.

  1. I instantiate my chart successfully
  2. Then I call setOption again with some new options and get the error.

The chart options are too complicated to send right now.

I'm having a hard time understanding why this might be getting called.

What is p0 parameter? It is not described... it is an array of what? Why does Animator.js expect this p0 to never be empty, should there be a safety check here to check the length of p0 before proceeding with the logic?

期望结果 (Expected behaviour)

可能哪里有问题 (What went wrong)

ECharts配置项 (ECharts option)

option = {

}

其他信息 (Other comments)

cosmicscr avatar Nov 09 '16 20:11 cosmicscr

这个问题解决了吗? 我这里也遇到了

zhanglina1990 avatar Mar 10 '22 07:03 zhanglina1990

这个问题我发现大都是有关颜色的配置出现问题。 例如:rgb(255, 255, 255)当成rgba写了(多一个参数),或者rgba当成rgb写,诸如此类。 但是我这里出现问题之后,我仔细检查了这里(当然,确定了就是颜色这里出现问题),并没有以上所述的错误用法(错误用法是一定会触发这个报错的,但是我这里也莫名报错了)

所以我的最终解决办法是避开诸如rgb、rgba的写法,而是使用hex的颜色色值


以下提供一个rgb、rgba的颜色传参转hex颜色传参的封装函数

function opacityToHex(opacity: number) {
    const alpha = Math.round(opacity * 255);
    return alpha.toString(16).padStart(2, '0');
}

function colorItemToHex(color: string) {
    return parseInt(color).toString(16).padStart(2, '0')
}

/**
 * 将 RGBA 颜色转换为哈希色值
 * @param rgbaColor 包含分割的rgb或者rgba的字符串:rgb(255,255,255)、甚至是"255,255,255,0.25"
 * @returns 颜色hex值
 */
export function rgbaColorToHash(rgbaColor: string): string {
    const rgba = rgbaColor.match(/\d+/g)!;
    const alpha = +(rgba.slice(3, 5).join(".") + rgba.slice(5).join(""));
    const hexColor = `#${colorItemToHex(rgba[0])}${colorItemToHex(rgba[1])}${colorItemToHex(rgba[2])}`;
    return alpha ? `${hexColor}${opacityToHex(alpha)}` : hexColor;
}

Vanisper avatar Jun 28 '23 07:06 Vanisper