我想在我的Durandal視圖上使用ComponentOne的Wijmo圖表控件。Durandal Wijmo問題
我想加載模塊js中'附加'事件的圖表控件。看來,圖表控件是不是渲染,而是下面的錯誤被拋出:
Uncaught TypeError: Cannot read property 'startX' of undefined jquery.wijmo-pro.all.3.20132.9.min.js:26
(anonymous function)jquery.wijmo-pro.all.3.20132.9.min.js:26
jQuery.event.dispatchjquery-1.9.1.js:3074
elemData.handlejquery-1.9.1.js:2750
即使錯誤顯然似乎是從Wijmo控件的腳本拋出,最有可能迪朗達爾是前提高附加事件正在顯示視圖。換句話說,在初始化過程中,DOM中沒有佈局。
下面是我的香草迪朗達爾入門套件的Flickr模塊上運行的代碼:
attached: function() {
$(document).ready(function() {
$("#wijpiechart").wijpiechart({
radius: 140,
hint: {
content: function() {
return this.data.label + " : " + Globalize.format(this.value/this.total, "p2");
}
},
header: {
text: "Steam Mac Hardware Survey"
},
seriesList: [{
label: "MacBook Pro",
data: 46.78,
offset: 15
}, {
label: "iMac",
data: 23.18,
offset: 0
}, {
label: "MacBook",
data: 20.25,
offset: 0
}, {
label: "Mac Pro",
data: 5.41,
offset: 0
}, {
label: "Mac Mini",
data: 3.44,
offset: 0
}],
seriesStyles: [{
fill: "180-rgb(195,255,0)-rgb(175,229,0)",
stroke: "rgb(175,229,0)",
"stroke-width": 1.5
}, {
fill: "90-rgb(142,222,67)-rgb(127,199,60)",
stroke: "rgb(127,199,60)",
"stroke-width": 1.5
}, {
fill: "90-rgb(106,171,167)-rgb(95,153,150)",
stroke: "rgb(95,153,150)",
"stroke-width": 1.5
}, {
fill: "90-rgb(70,106,133)-rgb(62,95,119)",
stroke: "rgb(62,95,119)",
"stroke-width": 1.5
}, {
fill: "90-rgb(166,166,166)-rgb(149,149,149)",
stroke: "rgb(149,149,149)",
"stroke-width": 1.5
}]
});
});
}
一個簡單的修正將與延遲上面的代碼後,重新繪製控件:
setTimeout(function() {
$("#wijpiechart").wijpiechart("redraw");
}, 100);
但這可能不是一個優雅的解決方案。
Durandal在視圖顯示後是否有任何其他事件處理這種控件繪圖?