Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var EcommerceIndex = function () { |
| 2 | |||
| 3 | function showTooltip(x, y, labelX, labelY) { |
||
| 4 | $('<div id="tooltip" class="chart-tooltip">' + (labelY.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')) + 'USD<\/div>').css({ |
||
| 5 | position: 'absolute', |
||
| 6 | display: 'none', |
||
| 7 | top: y - 40, |
||
| 8 | left: x - 60, |
||
| 9 | border: '0px solid #ccc', |
||
| 10 | padding: '2px 6px', |
||
| 11 | 'background-color': '#fff' |
||
| 12 | }).appendTo("body").fadeIn(200); |
||
| 13 | } |
||
| 14 | |||
| 15 | var initChart1 = function () { |
||
| 16 | |||
| 17 | var data = [ |
||
| 18 | ['01/2013', 4], |
||
| 19 | ['02/2013', 8], |
||
| 20 | ['03/2013', 10], |
||
| 21 | ['04/2013', 12], |
||
| 22 | ['05/2013', 2125], |
||
| 23 | ['06/2013', 324], |
||
| 24 | ['07/2013', 1223], |
||
| 25 | ['08/2013', 1365], |
||
| 26 | ['09/2013', 250], |
||
| 27 | ['10/2013', 999], |
||
| 28 | ['11/2013', 390] |
||
| 29 | ]; |
||
| 30 | |||
| 31 | var plot_statistics = $.plot( |
||
| 32 | $("#statistics_1"), |
||
| 33 | [ |
||
| 34 | { |
||
| 35 | data:data, |
||
| 36 | lines: { |
||
| 37 | fill: 0.6, |
||
| 38 | lineWidth: 0 |
||
| 39 | }, |
||
| 40 | color: ['#f89f9f'] |
||
| 41 | }, |
||
| 42 | { |
||
| 43 | data: data, |
||
| 44 | points: { |
||
| 45 | show: true, |
||
| 46 | fill: true, |
||
| 47 | radius: 5, |
||
| 48 | fillColor: "#f89f9f", |
||
| 49 | lineWidth: 3 |
||
| 50 | }, |
||
| 51 | color: '#fff', |
||
| 52 | shadowSize: 0 |
||
| 53 | } |
||
| 54 | ], |
||
| 55 | { |
||
| 56 | |||
| 57 | xaxis: { |
||
| 58 | tickLength: 0, |
||
| 59 | tickDecimals: 0, |
||
| 60 | mode: "categories", |
||
| 61 | min: 2, |
||
| 62 | font: { |
||
| 63 | lineHeight: 15, |
||
| 64 | style: "normal", |
||
| 65 | variant: "small-caps", |
||
| 66 | color: "#6F7B8A" |
||
| 67 | } |
||
| 68 | }, |
||
| 69 | yaxis: { |
||
| 70 | ticks: 3, |
||
| 71 | tickDecimals: 0, |
||
| 72 | tickColor: "#f0f0f0", |
||
| 73 | font: { |
||
| 74 | lineHeight: 15, |
||
| 75 | style: "normal", |
||
| 76 | variant: "small-caps", |
||
| 77 | color: "#6F7B8A" |
||
| 78 | } |
||
| 79 | }, |
||
| 80 | grid: { |
||
| 81 | backgroundColor: { |
||
| 82 | colors: ["#fff", "#fff"] |
||
| 83 | }, |
||
| 84 | borderWidth: 1, |
||
| 85 | borderColor: "#f0f0f0", |
||
| 86 | margin: 0, |
||
| 87 | minBorderMargin: 0, |
||
| 88 | labelMargin: 20, |
||
| 89 | hoverable: true, |
||
| 90 | clickable: true, |
||
| 91 | mouseActiveRadius: 6 |
||
| 92 | }, |
||
| 93 | legend: { |
||
| 94 | show: false |
||
| 95 | } |
||
| 96 | } |
||
| 97 | ); |
||
| 98 | |||
| 99 | var previousPoint = null; |
||
| 100 | |||
| 101 | $("#statistics_1").bind("plothover", function (event, pos, item) { |
||
| 102 | $("#x").text(pos.x.toFixed(2)); |
||
| 103 | $("#y").text(pos.y.toFixed(2)); |
||
| 104 | if (item) { |
||
| 105 | if (previousPoint != item.dataIndex) { |
||
| 106 | previousPoint = item.dataIndex; |
||
| 107 | |||
| 108 | $("#tooltip").remove(); |
||
| 109 | var x = item.datapoint[0].toFixed(2), |
||
| 110 | y = item.datapoint[1].toFixed(2); |
||
| 111 | |||
| 112 | showTooltip(item.pageX, item.pageY, item.datapoint[0], item.datapoint[1]); |
||
| 113 | } |
||
| 114 | } else { |
||
| 115 | $("#tooltip").remove(); |
||
| 116 | previousPoint = null; |
||
| 117 | } |
||
| 118 | }); |
||
| 119 | |||
| 120 | } |
||
| 121 | |||
| 122 | var initChart2 = function() { |
||
| 123 | |||
| 124 | var data = [ |
||
| 125 | ['01/2013', 10], |
||
| 126 | ['02/2013', 0], |
||
| 127 | ['03/2013', 10], |
||
| 128 | ['04/2013', 12], |
||
| 129 | ['05/2013', 212], |
||
| 130 | ['06/2013', 324], |
||
| 131 | ['07/2013', 122], |
||
| 132 | ['08/2013', 136], |
||
| 133 | ['09/2013', 250], |
||
| 134 | ['10/2013', 99], |
||
| 135 | ['11/2013', 190] |
||
| 136 | ]; |
||
| 137 | |||
| 138 | var plot_statistics = $.plot( |
||
| 139 | $("#statistics_2"), |
||
| 140 | [ |
||
| 141 | { |
||
| 142 | data:data, |
||
| 143 | lines: { |
||
| 144 | fill: 0.6, |
||
| 145 | lineWidth: 0 |
||
| 146 | }, |
||
| 147 | color: ['#BAD9F5'] |
||
| 148 | }, |
||
| 149 | { |
||
| 150 | data: data, |
||
| 151 | points: { |
||
| 152 | show: true, |
||
| 153 | fill: true, |
||
| 154 | radius: 5, |
||
| 155 | fillColor: "#BAD9F5", |
||
| 156 | lineWidth: 3 |
||
| 157 | }, |
||
| 158 | color: '#fff', |
||
| 159 | shadowSize: 0 |
||
| 160 | } |
||
| 161 | ], |
||
| 162 | { |
||
| 163 | |||
| 164 | xaxis: { |
||
| 165 | tickLength: 0, |
||
| 166 | tickDecimals: 0, |
||
| 167 | mode: "categories", |
||
| 168 | min: 2, |
||
| 169 | font: { |
||
| 170 | lineHeight: 14, |
||
| 171 | style: "normal", |
||
| 172 | variant: "small-caps", |
||
| 173 | color: "#6F7B8A" |
||
| 174 | } |
||
| 175 | }, |
||
| 176 | yaxis: { |
||
| 177 | ticks: 3, |
||
| 178 | tickDecimals: 0, |
||
| 179 | tickColor: "#f0f0f0", |
||
| 180 | font: { |
||
| 181 | lineHeight: 14, |
||
| 182 | style: "normal", |
||
| 183 | variant: "small-caps", |
||
| 184 | color: "#6F7B8A" |
||
| 185 | } |
||
| 186 | }, |
||
| 187 | grid: { |
||
| 188 | backgroundColor: { |
||
| 189 | colors: ["#fff", "#fff"] |
||
| 190 | }, |
||
| 191 | borderWidth: 1, |
||
| 192 | borderColor: "#f0f0f0", |
||
| 193 | margin: 0, |
||
| 194 | minBorderMargin: 0, |
||
| 195 | labelMargin: 20, |
||
| 196 | hoverable: true, |
||
| 197 | clickable: true, |
||
| 198 | mouseActiveRadius: 6 |
||
| 199 | }, |
||
| 200 | legend: { |
||
| 201 | show: false |
||
| 202 | } |
||
| 203 | } |
||
| 204 | ); |
||
| 205 | |||
| 206 | var previousPoint = null; |
||
| 207 | |||
| 208 | $("#statistics_2").bind("plothover", function (event, pos, item) { |
||
| 209 | $("#x").text(pos.x.toFixed(2)); |
||
| 210 | $("#y").text(pos.y.toFixed(2)); |
||
| 211 | if (item) { |
||
| 212 | if (previousPoint != item.dataIndex) { |
||
| 213 | previousPoint = item.dataIndex; |
||
| 214 | |||
| 215 | $("#tooltip").remove(); |
||
| 216 | var x = item.datapoint[0].toFixed(2), |
||
| 217 | y = item.datapoint[1].toFixed(2); |
||
| 218 | |||
| 219 | showTooltip(item.pageX, item.pageY, item.datapoint[0], item.datapoint[1]); |
||
| 220 | } |
||
| 221 | } else { |
||
| 222 | $("#tooltip").remove(); |
||
| 223 | previousPoint = null; |
||
| 224 | } |
||
| 225 | }); |
||
| 226 | |||
| 227 | } |
||
| 228 | |||
| 229 | return { |
||
| 230 | |||
| 231 | //main function |
||
| 232 | init: function () { |
||
| 233 | initChart1(); |
||
| 234 | |||
| 235 | $('#statistics_amounts_tab').on('shown.bs.tab', function (e) { |
||
| 236 | initChart2(); |
||
| 237 | }); |
||
| 238 | } |
||
| 239 | |||
| 240 | }; |
||
| 241 | |||
| 242 | }(); |