Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var Index = function() { |
| 2 | |||
| 3 | var dashboardMainChart = null; |
||
| 4 | |||
| 5 | return { |
||
| 6 | |||
| 7 | //main function |
||
| 8 | init: function() { |
||
| 9 | Metronic.addResizeHandler(function() { |
||
| 10 | jQuery('.vmaps').each(function() { |
||
| 11 | var map = jQuery(this); |
||
| 12 | map.width(map.parent().width()); |
||
| 13 | }); |
||
| 14 | }); |
||
| 15 | |||
| 16 | Index.initCharts(); |
||
| 17 | Index.initMiniCharts(); |
||
| 18 | Index.initJQVMAP(); |
||
| 19 | }, |
||
| 20 | |||
| 21 | initJQVMAP: function() { |
||
| 22 | if (!jQuery().vectorMap) { |
||
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | var showMap = function(name) { |
||
| 27 | jQuery('.vmaps').hide(); |
||
| 28 | jQuery('#vmap_' + name).show(); |
||
| 29 | } |
||
| 30 | |||
| 31 | var setMap = function(name) { |
||
| 32 | var data = { |
||
| 33 | map: 'world_en', |
||
| 34 | backgroundColor: null, |
||
| 35 | borderColor: '#333333', |
||
| 36 | borderOpacity: 0.5, |
||
| 37 | borderWidth: 1, |
||
| 38 | color: '#c6c6c6', |
||
| 39 | enableZoom: true, |
||
| 40 | hoverColor: '#c9dfaf', |
||
| 41 | hoverOpacity: null, |
||
| 42 | values: sample_data, |
||
| 43 | normalizeFunction: 'linear', |
||
| 44 | scaleColors: ['#b6da93', '#909cae'], |
||
| 45 | selectedColor: '#c9dfaf', |
||
| 46 | selectedRegion: null, |
||
| 47 | showTooltip: true, |
||
| 48 | onLabelShow: function(event, label, code) { |
||
| 49 | |||
| 50 | }, |
||
| 51 | onRegionOver: function(event, code) { |
||
| 52 | if (code == 'ca') { |
||
| 53 | event.preventDefault(); |
||
| 54 | } |
||
| 55 | }, |
||
| 56 | onRegionClick: function(element, code, region) { |
||
| 57 | var message = 'You clicked "' + region + '" which has the code: ' + code.toUpperCase(); |
||
| 58 | alert(message); |
||
| 59 | } |
||
| 60 | }; |
||
| 61 | |||
| 62 | data.map = name + '_en'; |
||
| 63 | var map = jQuery('#vmap_' + name); |
||
| 64 | if (!map) { |
||
| 65 | return; |
||
| 66 | } |
||
| 67 | map.width(map.parent().parent().width()); |
||
| 68 | map.show(); |
||
| 69 | map.vectorMap(data); |
||
| 70 | map.hide(); |
||
| 71 | } |
||
| 72 | |||
| 73 | setMap("world"); |
||
| 74 | setMap("usa"); |
||
| 75 | setMap("europe"); |
||
| 76 | setMap("russia"); |
||
| 77 | setMap("germany"); |
||
| 78 | showMap("world"); |
||
| 79 | |||
| 80 | jQuery('#regional_stat_world').click(function() { |
||
| 81 | showMap("world"); |
||
| 82 | }); |
||
| 83 | |||
| 84 | jQuery('#regional_stat_usa').click(function() { |
||
| 85 | showMap("usa"); |
||
| 86 | }); |
||
| 87 | |||
| 88 | jQuery('#regional_stat_europe').click(function() { |
||
| 89 | showMap("europe"); |
||
| 90 | }); |
||
| 91 | jQuery('#regional_stat_russia').click(function() { |
||
| 92 | showMap("russia"); |
||
| 93 | }); |
||
| 94 | jQuery('#regional_stat_germany').click(function() { |
||
| 95 | showMap("germany"); |
||
| 96 | }); |
||
| 97 | |||
| 98 | $('#region_statistics_loading').hide(); |
||
| 99 | $('#region_statistics_content').show(); |
||
| 100 | }, |
||
| 101 | |||
| 102 | initCharts: function() { |
||
| 103 | if (Morris.EventEmitter) { |
||
| 104 | // Use Morris.Area instead of Morris.Line |
||
| 105 | dashboardMainChart = Morris.Area({ |
||
| 106 | element: 'sales_statistics', |
||
| 107 | padding: 0, |
||
| 108 | behaveLikeLine: false, |
||
| 109 | gridEnabled: false, |
||
| 110 | gridLineColor: false, |
||
| 111 | axes: false, |
||
| 112 | fillOpacity: 1, |
||
| 113 | data: [{ |
||
| 114 | period: '2011 Q1', |
||
| 115 | sales: 1400, |
||
| 116 | profit: 400 |
||
| 117 | }, { |
||
| 118 | period: '2011 Q2', |
||
| 119 | sales: 1100, |
||
| 120 | profit: 600 |
||
| 121 | }, { |
||
| 122 | period: '2011 Q3', |
||
| 123 | sales: 1600, |
||
| 124 | profit: 500 |
||
| 125 | }, { |
||
| 126 | period: '2011 Q4', |
||
| 127 | sales: 1200, |
||
| 128 | profit: 400 |
||
| 129 | }, { |
||
| 130 | period: '2012 Q1', |
||
| 131 | sales: 1550, |
||
| 132 | profit: 800 |
||
| 133 | }], |
||
| 134 | lineColors: ['#399a8c', '#92e9dc'], |
||
| 135 | xkey: 'period', |
||
| 136 | ykeys: ['sales', 'profit'], |
||
| 137 | labels: ['Sales', 'Profit'], |
||
| 138 | pointSize: 0, |
||
| 139 | lineWidth: 0, |
||
| 140 | hideHover: 'auto', |
||
| 141 | resize: true |
||
| 142 | }); |
||
| 143 | |||
| 144 | } |
||
| 145 | }, |
||
| 146 | |||
| 147 | redrawCharts: function() { |
||
| 148 | dashboardMainChart.resizeHandler(); |
||
| 149 | }, |
||
| 150 | |||
| 151 | initMiniCharts: function() { |
||
| 152 | |||
| 153 | // IE8 Fix: function.bind polyfill |
||
| 154 | if (Metronic.isIE8() && !Function.prototype.bind) { |
||
| 155 | Function.prototype.bind = function(oThis) { |
||
| 156 | if (typeof this !== "function") { |
||
| 157 | // closest thing possible to the ECMAScript 5 internal IsCallable function |
||
| 158 | throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); |
||
| 159 | } |
||
| 160 | |||
| 161 | var aArgs = Array.prototype.slice.call(arguments, 1), |
||
| 162 | fToBind = this, |
||
| 163 | fNOP = function() {}, |
||
| 164 | fBound = function() { |
||
| 165 | return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, |
||
| 166 | aArgs.concat(Array.prototype.slice.call(arguments))); |
||
| 167 | }; |
||
| 168 | |||
| 169 | fNOP.prototype = this.prototype; |
||
| 170 | fBound.prototype = new fNOP(); |
||
| 171 | |||
| 172 | return fBound; |
||
| 173 | }; |
||
| 174 | } |
||
| 175 | |||
| 176 | $("#sparkline_bar").sparkline([8, 9, 10, 11, 10, 10, 12, 10, 10, 11, 9, 12, 11], { |
||
| 177 | type: 'bar', |
||
| 178 | width: '100', |
||
| 179 | barWidth: 6, |
||
| 180 | height: '45', |
||
| 181 | barColor: '#F36A5B', |
||
| 182 | negBarColor: '#e02222' |
||
| 183 | }); |
||
| 184 | |||
| 185 | $("#sparkline_bar2").sparkline([9, 11, 12, 13, 12, 13, 10, 14, 13, 11, 11, 12, 11], { |
||
| 186 | type: 'bar', |
||
| 187 | width: '100', |
||
| 188 | barWidth: 6, |
||
| 189 | height: '45', |
||
| 190 | barColor: '#5C9BD1', |
||
| 191 | negBarColor: '#e02222' |
||
| 192 | }); |
||
| 193 | } |
||
| 194 | |||
| 195 | }; |
||
| 196 | |||
| 197 | }(); |