11$ ( function ( ) {
2- $ ( ".dashboard-page .items .sparkline" ) . each ( function ( ) {
3- var type = $ ( this ) . data ( 'type' ) ;
2+
43
5- // There is predefined data
6- if ( $ ( this ) . data ( 'data' ) ) {
7- var data = $ ( this ) . data ( 'data' ) . split ( ',' ) . map ( function ( item ) {
8- if ( item . indexOf ( ":" ) > 0 ) {
9- return item . split ( ":" ) ;
10- }
11- else {
12- return item ;
4+ function drawDashboardItemsListSparklines ( ) {
5+ $ ( ".dashboard-page .items .sparkline" ) . each ( function ( ) {
6+ var type = $ ( this ) . data ( 'type' ) ;
7+
8+ // There is predefined data
9+ if ( $ ( this ) . data ( 'data' ) ) {
10+ var data = $ ( this ) . data ( 'data' ) . split ( ',' ) . map ( function ( item ) {
11+ if ( item . indexOf ( ":" ) > 0 ) {
12+ return item . split ( ":" ) ;
13+ }
14+ else {
15+ return item ;
16+ }
17+ } ) ;
18+ }
19+ // Generate random data
20+ else {
21+ var data = [ ] ;
22+ for ( var i = 0 ; i < 17 ; i ++ ) {
23+ data . push ( Math . round ( 100 * Math . random ( ) ) ) ;
1324 }
14- } ) ;
15- }
16- // Generate random data
17- else {
18- var data = [ ] ;
19- for ( var i = 0 ; i < 17 ; i ++ ) {
20- data . push ( Math . round ( 100 * Math . random ( ) ) ) ;
2125 }
22- }
2326
2427
25- $ ( this ) . sparkline ( data , {
26- barColor : config . colorPrimary . toString ( ) ,
27- height : $ ( this ) . height ( ) ,
28- type : type
28+ $ ( this ) . sparkline ( data , {
29+ barColor : config . colorPrimary . toString ( ) ,
30+ height : $ ( this ) . height ( ) ,
31+ type : type
32+ } ) ;
2933 } ) ;
30- } ) ;
34+ }
35+
36+ drawDashboardItemsListSparklines ( ) ;
37+
38+ watch ( config , "colorPrimary" , function ( ) {
39+ drawDashboardItemsListSparklines ( ) ;
40+ } ) ;
3141} ) ;
0 commit comments