Need example of dojo scatter or bubble chart

ぃ、小莉子 提交于 2019-12-13 19:17:03

问题


I'm having a bit of trouble understanding how to tackle the scatter and bubble chart in dojo. Does anyone have an example or good documentation I can look at to help me out?


回答1:


unlike any other chart (line,bar,area which takes two inputs per point , x and y)

bubble chart takes three inputs per point ( x, y , and size of bubble)

Bubble Chart Example:

            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();
            });

Scattered charts are similar to any other point chart except the x axis values can be in float (or double) type.

Scattered Chart Example :

            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();
            });

Hope this helps ... ..



来源:https://stackoverflow.com/questions/15571737/need-example-of-dojo-scatter-or-bubble-chart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!