需要dojo散射或气泡图的示例

时间:2013-03-22 13:36:41

标签: dojo

我在理解如何处理dojo中的散点图和气泡图时遇到了一些麻烦。有没有人有一个例子或好的文件我可以看看帮助我?

1 个答案:

答案 0 :(得分:2)

不同于任何其他图表(线,条,每个点需要两个输入的区域,x和y)

气泡图每个点需要三个输入(x,y和气泡大小)

气泡图示例:

            require([
              "dojox/charting/Chart",
              "dojox/charting/themes/MiamiNice",
              "dojox/charting/plot2d/Bubble",
              "dojox/charting/plot2d/Markers",
              "dojox/charting/axis2d/Default",
              "dojo/domReady!"
            ],function(Chart,theme){
             var d1 = [];
             for (var i = 0; i <= 10; i += 1){
                d1.push({x: i, y: parseInt(Math.random() * 30), size: parseInt(Math.random() * 10)});
                 // or you can put "size:1" for simplicity
             }
             var chart = new Chart("container");
             chart.addPlot("default", {
                 type:"Bubble"
             });
             chart.addAxis("x");
             chart.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"});

             // Add the series of data
             chart.addSeries("Demo", d1);
             chart.render();
            });

散乱图表与任何其他点图表类似,但x轴值可以是浮点(或双精度)类型。

分散图表示例:

            require([
              "dojox/charting/Chart",
              "dojox/charting/themes/MiamiNice",
              "dojox/charting/plot2d/Scatter",
              "dojox/charting/plot2d/Markers",
              "dojox/charting/axis2d/Default",
              "dojo/domReady!"
            ],function(Chart,theme){
              var d1 = [];
              for (var i = 0; i <= 4; i += 0.1){
                  d1.push({x: i, y: parseInt(Math.random() * 30)});
              }
              var chart = new Chart("container");
              chart.addPlot("default", {
                 type:"Scatter"
              });
              chart.addAxis("x");
              chart.addAxis("y", {vertical: true, fixLower: "major", fixUpper: "major"});

              // Add the series of data
              chart.addSeries("Demo", d1);
              chart.render();
            });

希望这有助于...... ..