动态更新数据到DOJO中的条形图。

时间:2012-10-26 06:16:39

标签: javascript cordova dojo dojox.charting

我基本上来自'c语言'背景,并且对脚本没有合理的想法。

我想要实现的目标是:

SwapView中显示了一个条形图。现在,每当用户访问此SwapView时,我想用新的数据集重新加载Bargrap。假设我有一个全局数据,即:window.myvalues。我需要捕捉哪个事件,以及如何做到这一点?

请咨询。这是我从dojo网站使用的示例。

 <div id="barview" data-dojo-type="dojox.mobile.SwapView">



        <script>
            function mybarchartNode(){


                require([
                         // Require the basic chart class
                         "dojox/charting/Chart",

                         // Require the theme of our choosing
                         "dojox/charting/themes/MiamiNice",

                         //  We want to plot Columns
                         "dojox/charting/plot2d/Columns",

                         // Require the highlighter
                         "dojox/charting/action2d/Highlight",

                         //  We want to use Markers
                         "dojox/charting/plot2d/Markers",

                         //  We'll use default x/y axes
                         "dojox/charting/axis2d/Default",

                         // Wait until the DOM is ready
                         "dojo/domReady!"
                         ], function(Chart, theme, ColumnsPlot, Highlight) {


                        console.log ("Data set in the bar graph ");
                        console.log (window.myDatas);
                        // Define the data
                        var chartData = [10000,9200,11811,12000,7662,13887,14200,12222,12000,10009,11288,12099];

                        // Create the chart within it's "holding" node
                        var chart = new Chart("barchartNode");

                        // Set the theme
                        chart.setTheme(theme);

                        // Add the only/default plot
                        chart.addPlot("default", {
                                      type: ColumnsPlot,
                                      markers: true,
                                      gap: 5
                                      });

                        // Add axes
                        chart.addAxis("x");
                        chart.addAxis("y", { vertical: true, fixLower: "major", fixUpper: "major" });

                        // Add the series of data
                        chart.addSeries("Monthly Sales",chartData);

                        // Highlight!
                        new Highlight(chart,"default");

                        // Render the chart!
                        chart.render();
                        });




            }  /* Function End */

            </script>





        <div id="barchartNode" style="width: 250px; height: 150px;"></div>

        </div> <!- swap space end -->




<!-- configure and load dojo -->
    <script src="dojo/dojo.js" data-dojo-config="isDebug:1, async:1"></script>
    <script>

        require(["dojox/mobile/parser", "dijit/registry", "dojox/mobile",  "dojox/mobile/SwapView", "dojox/mobile/TabBar", "dojox/mobile/TreeView", "dijit/tree/TreeStoreModel","dojox/mobile/Button", "dojox/mobile/deviceTheme", "dojox/mobile/compat", "dojo/domReady!"],
                function(parser) {
                parser.parse();
                });

        mybarchartNode();
        </script>     

1 个答案:

答案 0 :(得分:0)

您可以联系onAfterTransitionIn

onBeforeTransitionIndojox/mobile/SwapView

来自Dojo参考的引用

  

要从应用程序连接的存根功能。   在到达转换发生之前/之后调用。