如何将静态值设置为动态值

时间:2013-09-17 09:48:55

标签: dynamic static dojo

在addSeries方法中有一些声明为静态的值我想动态地给它。请任何人都可以为我做这个/ ................这是dojo代码

require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/StackedAreas", "dojox/charting/themes/Wetland" , "dojo/ready"],
              function(Chart, Default, StackedAreas, Wetland, ready){
                ready(function(){
                  var c = new Chart("chartOne");
                  c.addPlot("default", {type: StackedAreas, tension:3})
                    .addAxis("x", {fixLower: "major", fixUpper: "major"})
                    .addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0})
                    .setTheme(Wetland)
                    .addSeries("Series B", [1, 2, 0.5, 1.5, 1, 2.8, 0.4])
                    .addSeries("Series C", [2.6, 1.8, 2, 1, 1.4, 0.7, 2])
                    .addSeries("Series D", [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2])

                .render();
            });
        });

1 个答案:

答案 0 :(得分:0)

您可以这样更改:

var arraySer1 = [1, 2, 0.5, 1.5, 1, 2.8, 0.4];
var arraySer2 = [2.6, 1.8, 2, 1, 1.4, 0.7, 2];
var arraySer3 = [6.3, 1.8, 3, 0.5, 4.4, 2.7, 2];

 require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/StackedAreas", "dojox/charting/themes/Wetland" , "dojo/ready"],
          function(Chart, Default, StackedAreas, Wetland, ready){
            ready(function(){
              var c = new Chart("chartOne");
              c.addPlot("default", {type: StackedAreas, tension:3})
                .addAxis("x", {fixLower: "major", fixUpper: "major"})
                .addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major", min: 0})
                .setTheme(Wetland)
                .addSeries("Series B", arraySer1)
                .addSeries("Series C", arraySer2)
                .addSeries("Series D", arraySer3)

            .render();
        });
    });

这是小提琴:http://jsfiddle.net/WdDxM/

首先定义所需的数组,然后填写数据。 数组可以使用商店中的数据填充,也可以填充数据。

此致