开发者

Cannot call method 'instance' of undefined

开发者 https://www.devze.com 2023-02-09 09:49 出处:网络
When using the following code; var pvChart = new pv.Panel(); pvChart.width(200); pvChart.height(200); var pvBar = pvChart.add开发者_StackOverflow社区(pv.Bar);

When using the following code;

var pvChart = new pv.Panel();
pvChart.width(200);
pvChart.height(200); 

var pvBar = pvChart.add开发者_StackOverflow社区(pv.Bar);
pvBar.data([1,2,3]);

console.log(pvBar.fillStyle());

I get the error;

Cannot call method 'instance' of undefined

It refers to the pvBar.fillStyle(). Using this I want to retrieve the bars fillStyle for later use. Can anyone tell me the reason of this error and how to solve this?


SOLVED

it was because I was requesting the fillStyle before the bar has been drawn..

Correct code;

var pvChart = new pv.Panel();
pvChart.width(200);
pvChart.height(200); 

var pvBar = pvChart.add(pv.Bar);
pvBar.data([1,2,3]);

pvChart.render();
console.log(pvBar.fillStyle());
0

精彩评论

暂无评论...
验证码 换一张
取 消