File tree 2 files changed +11
-7
lines changed 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,16 @@ var Fruit = require('../models/Fruit.js');
6
6
router . get ( '/' , function ( req , res , next ) {
7
7
Fruit . find ( { } ) . select ( 'name value -_id' ) . sort ( { 'value' : - 1 } ) . limit ( 5 ) . exec ( function ( err , fruits ) {
8
8
if ( err ) return next ( err ) ;
9
- res . render ( 'index' , { title : 'Anychart NodeJS demo' ,
10
- chartTitle : "Top 5 fruits" ,
11
- chartData : JSON . stringify ( fruits )
12
- } ) ;
9
+ // chart JSON data
10
+ var json = {
11
+ chart : {
12
+ type : "pie" ,
13
+ title : 'Top 5 Fruits' ,
14
+ data : fruits ,
15
+ container : "container"
16
+ }
17
+ } ;
18
+ res . render ( 'index' , { title : 'Anychart NodeJS demo' , chartData : JSON . stringify ( json ) } ) ;
13
19
} ) ;
14
20
} ) ;
15
21
Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ block content
4
4
div( id ="container" )
5
5
script .
6
6
anychart .onDocumentReady (function () {
7
- var chart = anychart .pie (! {chartData});
8
- chart .title (" #{chartTitle}" );
9
- chart .container (" container" );
7
+ var chart = anychart .fromJson (! {chartData});
10
8
chart .draw ();
11
9
});
You can’t perform that action at this time.
0 commit comments