1
我在varD變量格式如下一些數據:如何在函數中調用變量?
[{period: '2013', iphone: 0, ipad: 4, itouch:0},
{period: '2013', iphone: 3, ipad: 0, itouch:90},
{period: '2013', iphone: 1, ipad: 0, itouch:13}]
我想在我的jQuery圖表函數調用。
drawHeroArea : function (varD) {
!verboseBuild || console.log('proton.dashboard.drawHeroArea()');
if($('#hero-area').length)
proton.dashboard.graph.Area = Morris.Area({
element: 'hero-area',
data: varD,
xkey: 'period',
ykeys: ['iphone', 'ipad', 'itouch'],
labels: ['iPhone', 'iPad', 'iPod Touch'],
pointSize: 2,
hideHover: 'auto'
});
}
數據在警告函數中正確顯示。但是,當我添加data: varD,
那麼它不工作,請任何一個讓我知道問題的地方,或者如何可以調用data:
。
這樣功能正常
drawHeroArea : function (varD) {
!verboseBuild || console.log('proton.dashboard.drawHeroArea()');
if($('#hero-area').length)
proton.dashboard.graph.Area = Morris.Area({
element: 'hero-area',
data:
[
{period: '2013', iphone: 0, ipad: 4, itouch:0},
{period: '2013', iphone: 3, ipad: 0, itouch:90},
{period: '2013', iphone: 1, ipad: 0, itouch:13},
{period: '2013', iphone: 0, ipad: 0, itouch:7},
{period: '2013', iphone: 0, ipad: 0, itouch:13},
{period: '2013', iphone: 0, ipad: 0, itouch:9},
{period: '2013', iphone: 0, ipad: 0, itouch:9},
{period: '2013', iphone: 0, ipad: 1, itouch:20},
{period: '2013', iphone: 0, ipad: 0, itouch:11},
{period: '2013', iphone: 0, ipad: 1, itouch:20},
{period: '2014', iphone: 0, ipad: 0, itouch:19},
{period: '2014', iphone: 0, ipad: 1, itouch:24},
{period: '2014', iphone: 0, ipad: 0, itouch:26},
{period: '2014', iphone: 0, ipad: 1, itouch:14},
{period: '2014', iphone: 0, ipad: 0, itouch:2},
{period: '2014', iphone: 0, ipad: 0, itouch:3},
{period: '2014', iphone: 0, ipad: 1, itouch:3},
{period: '2014', iphone: 0, ipad: 0, itouch:2},
{period: '2015', iphone: 0, ipad: 1, itouch:16},
{period: '2015', iphone: 0, ipad: 0, itouch:3},
{period: '2015', iphone: 0, ipad: 0, itouch:25},
{period: '2015', iphone: 0, ipad: 0, itouch:14},
{period: '2015', iphone: 0, ipad: 0, itouch:1}
],
xkey: 'period',
ykeys: ['iphone', 'ipad', 'itouch'],
labels: ['iPhone', 'iPad', 'iPod Touch'],
pointSize: 2,
hideHover: 'auto'
});
}
@Mohit drawHeroArea(varD); –
@Uchiha你是什麼意思...? –
@AyazShah什麼是'sql'和'mysql'與這篇文章的關係 –