1

I have some data in varD variable following format:

[{period: '2013', iphone: 0, ipad: 4, itouch:0},
 {period: '2013', iphone: 3, ipad: 0, itouch:90},
 {period: '2013', iphone: 1, ipad: 0, itouch:13}]

I want to call in my jquery chart function.

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 is showing properly in alert in function. But when i add data: varD, then it is not working please any one let me know where the issue, or how can call against data:.

This way function working properly

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'
 });
 }
John Saunders
162k26 gold badges252 silver badges403 bronze badges
asked May 30, 2015 at 12:59
7
  • @Mohit drawHeroArea(varD); Commented May 30, 2015 at 13:03
  • 1
    @Uchiha what do you mean...? Commented May 30, 2015 at 13:05
  • @AyazShah Whats the relation of sql and mysql with this post Commented May 30, 2015 at 13:07
  • Uchiha No relation ... Commented May 30, 2015 at 13:08
  • 1
    here its wroking fine jsbin.com/waxumuraca/1/edit?html,js,output Commented May 30, 2015 at 13:12

1 Answer 1

1

This should work:

 proton.dashboard.graph.Area.data=varD;

The object being already defined should make it work

answered May 30, 2015 at 15:01
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.