@@ -22,122 +22,124 @@ $(function() {
2222 switchHistoryCharts ( item ) ;
2323 } ) ;
2424
25- } ) ;
26-
27- function switchHistoryCharts ( item ) {
28- var chartSelector = "#dashboard-" + item + "-chart" ;
25+ function switchHistoryCharts ( item ) {
26+ var chartSelector = "#dashboard-" + item + "-chart" ;
27+
28+ if ( $ ( chartSelector ) . has ( 'svg' ) . length ) {
29+ $ ( chartSelector ) . empty ( ) ;
30+ }
31+
32+ switch ( item ) {
33+ case 'visits' :
34+ drawVisitsChart ( ) ;
35+ break ;
36+ case 'downloads' :
37+ drawDownloadsChart ( ) ;
38+ break ;
39+ }
40+ }
2941
30- if ( $ ( chartSelector ) . has ( 'svg' ) . length ) {
31- $ ( chartSelector ) . empty ( ) ;
42+ function drawVisitsChart ( ) {
43+ var dataVisits = [
44+ { x : '2015-09-01' , y : 70 } ,
45+ { x : '2015-09-02' , y : 75 } ,
46+ { x : '2015-09-03' , y : 50 } ,
47+ { x : '2015-09-04' , y : 75 } ,
48+ { x : '2015-09-05' , y : 50 } ,
49+ { x : '2015-09-06' , y : 75 } ,
50+ { x : '2015-09-07' , y : 86 }
51+ ] ;
52+
53+
54+ Morris . Line ( {
55+ element : 'dashboard-visits-chart' ,
56+ data : dataVisits ,
57+ xkey : 'x' ,
58+ ykeys : [ 'y' ] ,
59+ ymin : 'auto 40' ,
60+ labels : [ 'Visits' ] ,
61+ xLabels : "day" ,
62+ hideHover : 'auto' ,
63+ yLabelFormat : function ( y ) {
64+ // Only integers
65+ if ( y === parseInt ( y , 10 ) ) {
66+ return y ;
67+ }
68+ else {
69+ return '' ;
70+ }
71+ } ,
72+ resize : true ,
73+ lineColors : [
74+ config . chart . colorSecondary . toString ( ) ,
75+ ] ,
76+ pointFillColors : [
77+ config . chart . colorPrimary . toString ( ) ,
78+ ]
79+ } ) ;
3280 }
3381
34- switch ( item ) {
35- case 'visits' :
36- drawVisitsChart ( ) ;
37- break ;
38- case 'downloads' :
39- drawDownloadsChart ( ) ;
40- break ;
82+ function drawDownloadsChart ( ) {
83+
84+ var dataDownloads = [
85+ {
86+ year : '2006' ,
87+ downloads : 1300
88+ } ,
89+ {
90+ year : '2007' ,
91+ downloads : 1526
92+ } ,
93+ {
94+ year : '2008' ,
95+ downloads : 2000
96+ } ,
97+ {
98+ year : '2009' ,
99+ downloads : 1800
100+ } ,
101+ {
102+ year : '2010' ,
103+ downloads : 1650
104+ } ,
105+ {
106+ year : '2011' ,
107+ downloads : 620
108+ } ,
109+ {
110+ year : '2012' ,
111+ downloads : 1000
112+ } ,
113+ {
114+ year : '2013' ,
115+ downloads : 1896
116+ } ,
117+ {
118+ year : '2014' ,
119+ downloads : 850
120+ } ,
121+ {
122+ year : '2015' ,
123+ downloads : 1500
124+ }
125+ ] ;
126+
127+
128+ Morris . Bar ( {
129+ element : 'dashboard-downloads-chart' ,
130+ data : dataDownloads ,
131+ xkey : 'year' ,
132+ ykeys : [ 'downloads' ] ,
133+ labels : [ 'Downloads' ] ,
134+ hideHover : 'auto' ,
135+ resize : true ,
136+ barColors : [
137+ config . chart . colorPrimary . toString ( ) ,
138+ tinycolor ( config . chart . colorPrimary . toString ( ) ) . darken ( 10 ) . toString ( )
139+ ] ,
140+ } ) ;
41141 }
42- }
43-
44- function drawVisitsChart ( ) {
45- var dataVisits = [
46- { x : '2015-09-01' , y : 70 } ,
47- { x : '2015-09-02' , y : 75 } ,
48- { x : '2015-09-03' , y : 50 } ,
49- { x : '2015-09-04' , y : 75 } ,
50- { x : '2015-09-05' , y : 50 } ,
51- { x : '2015-09-06' , y : 75 } ,
52- { x : '2015-09-07' , y : 86 }
53- ] ;
54-
55-
56- Morris . Line ( {
57- element : 'dashboard-visits-chart' ,
58- data : dataVisits ,
59- xkey : 'x' ,
60- ykeys : [ 'y' ] ,
61- ymin : 'auto 40' ,
62- labels : [ 'Visits' ] ,
63- xLabels : "day" ,
64- hideHover : 'auto' ,
65- yLabelFormat : function ( y ) {
66- // Only integers
67- if ( y === parseInt ( y , 10 ) ) {
68- return y ;
69- }
70- else {
71- return '' ;
72- }
73- } ,
74- resize : true ,
75- lineColors : [
76- config . chart . colorSecondary . toString ( ) ,
77- ] ,
78- pointFillColors : [
79- config . chart . colorPrimary . toString ( ) ,
80- ]
81- } ) ;
82- }
83-
84- function drawDownloadsChart ( ) {
85-
86- var dataDownloads = [
87- {
88- year : '2006' ,
89- downloads : 1300
90- } ,
91- {
92- year : '2007' ,
93- downloads : 1526
94- } ,
95- {
96- year : '2008' ,
97- downloads : 2000
98- } ,
99- {
100- year : '2009' ,
101- downloads : 1800
102- } ,
103- {
104- year : '2010' ,
105- downloads : 1650
106- } ,
107- {
108- year : '2011' ,
109- downloads : 620
110- } ,
111- {
112- year : '2012' ,
113- downloads : 1000
114- } ,
115- {
116- year : '2013' ,
117- downloads : 1896
118- } ,
119- {
120- year : '2014' ,
121- downloads : 850
122- } ,
123- {
124- year : '2015' ,
125- downloads : 1500
126- }
127- ] ;
128-
129-
130- Morris . Bar ( {
131- element : 'dashboard-downloads-chart' ,
132- data : dataDownloads ,
133- xkey : 'year' ,
134- ykeys : [ 'downloads' ] ,
135- labels : [ 'Downloads' ] ,
136- hideHover : 'auto' ,
137- resize : true ,
138- barColors : [
139- config . chart . colorPrimary . toString ( ) ,
140- tinycolor ( config . chart . colorPrimary . toString ( ) ) . darken ( 10 ) . toString ( )
141- ] ,
142- } ) ;
143- }
142+ } ) ;
143+
144+
145+
0 commit comments