水箱的javascript动画

水箱的javascript动画,javascript,rgraph,Javascript,Rgraph,我试图使用RGraph库来操纵垂直进度条,但我被卡住了,因为创建进度条后,我无法操纵其属性,下面是我一直使用的代码: window.onload = function () { // Create the object. The arguments are: The canvas ID, the indicated value and the maximum value. var myProgress = new RGraph.VProgress('myProgress', 6

我试图使用RGraph库来操纵垂直进度条,但我被卡住了,因为创建进度条后,我无法操纵其属性,下面是我一直使用的代码:

 window.onload = function ()
{
    // Create the object. The arguments are: The canvas ID, the indicated value and the maximum value.
    var myProgress = new RGraph.VProgress('myProgress', 60, 100)

        // Configure the chart to look as you want.
        .Set('chart.colors', ['blue'])

        .Set('chart.tickmarks',['true'])

        .Set('chart.tickmarks.color',['white'])

        .Set('chart.title',"Nivel")

        // Now call the .Draw() method to draw the chart.
        .Draw();




}
之后,我尝试通过单击按钮来读取value属性,但它显示undefined:

function myFunction()
{
   var valor= myProgress.value;
   alert(valor);


}
如何访问在另一个函数中创建的对象的属性?我的想法是根据网页中的控件更改进度条的级别


提前感谢您提供的帮助。

myProgress
在您的
onload
处理程序中有作用域,因此该作用域之外的其他函数无法看到它

var myProgress;
window.onload = function() {
    myProgress = new RGraph.VProgress('myProgress', 60, 100)
    // ...
};

更改值后还需要重新绘制画布:RGraph.redraw();感谢您的回答,我这样做了,为了更改值,我这样做了:函数ChangeLevel(value){Tank.value=value;Tank.Draw();}