2012-03-16 129 views
0

我正尝试使用带有Dojo的StoreSeries来创建图表。但是,当我尝试通过以下方式创建阵列时:无法创建新的javascript对象

new StoreSeries(store, { query: { site: 1 } }, "value"); 

然后JavaScript停止运行,并且无法继续呈现图表。

这是我认为可能相关的所有脚本 - 询问您是否需要再看。

function setupWeekElectricBar(Chart, theme, ClusteredColumns, Columns, Tooltip, Highlight, Observable, Memory, StoreSeries) 
    { 
    var data = [ 
     { id: 1, value: 5, site: 1 }, 
     { id: 2, value: 2, site: 1 }, 
     { id: 3, value: 3, site: 1 }, 
     { id: 4, value: 1, site: 1 }, 
     { id: 5, value: 3, site: 1 }, 
     { id: 6, value: 1, site: 1 } 
    ]; 

    // Create the data store 
    // Store information in a data store on the client side 
    var store = Observable(new Memory({ 
     data: { 
      identifier: "id", 
      label: "Users Online", 
      items: data 
     } 
    })); 

    var result = new StoreSeries(store, { query: { site: 1 } }, "value"); 

    //function does not get past here (checked using alert()) 

    } 


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

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

     // Charting plugins: 

     // We want to plot Pie and ClusteredColumns charts 
     "dojox/charting/plot2d/Pie", 
     "dojox/charting/plot2d/ClusteredColumns", 
     "dojox/charting/plot2d/Columns", 
     "dojox/charting/plot2d/Grid", 


     // Retrieve the Legend, Tooltip, and MoveSlice classes 
     "dojox/charting/action2d/Tooltip", 
     "dojox/charting/action2d/MoveSlice", 
     "dojox/charting/action2d/Highlight", 

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

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

     "dojo/parser", 

     "dojo/store/Observable", 
     "dojo/store/Memory", 
     "dojox/charting/StoreSeries", 

     "dijit/dijit", // loads the optimized dijit layer 
     "dijit/Calendar", 


     // Wait until the DOM is ready 
     "dojo/domReady!" 
    ], function(Chart, theme, Pie, ClusteredColumns, Columns, Grid, Tooltip, MoveSlice, Highlight, Observable, Memory, StoreSeries) { 
     setupWeekElectricBar(Chart, theme, ClusteredColumns, Columns,Tooltip, Highlight, Observable, Memory, StoreSeries); 
     } 
}); 
+0

你的Javascript控制台说什么?如果找不到它,尝试在'try/catch'块中包装'var result = new StoreSeries(store,{query:{site:1}},“value”);''并警告'出错。 – 2012-03-16 21:04:00

回答

0

通过移动

"dojo/store/Observable", 
"dojo/store/Memory", 
"dojox/charting/StoreSeries", 

进一步向上修正。