我基本上来自'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>