Procházet zdrojové kódy

Add markings on the border of each year

master
Chris Smith před 13 roky
rodič
revize
3e76f2be91
1 změnil soubory, kde provedl 24 přidání a 10 odebrání
  1. 24
    10
      analyser.js

+ 24
- 10
analyser.js Zobrazit soubor

@@ -197,31 +197,45 @@ $(function() {
197 197
   catData.push(series);
198 198
  });
199 199
 
200
+ var markings = [];
201
+
202
+ var year = new Date(new Date(max).getFullYear(), 0);
203
+ while (year.getTime() > min) {
204
+  markings.push({ color: '#000', lineWidth: 1, xaxis: { from: year.getTime(), to: year.getTime() } });
205
+  year.setFullYear(year.getFullYear() - 1);
206
+ }
207
+
200 208
  catData.sort(function(a, b) { return a.total - b.total; });
201 209
 
210
+ plots.cathistory = $.plot($('#cathistory'), catData, {
211
+   xaxis: { mode: 'time', timeformat: '%y/%m' },
212
+   legend: { noColumns: 2 },
213
+   series: {
214
+     stack: true,
215
+     lines: { show: true, fill: true }
216
+   },
217
+   grid: {
218
+    markings: markings
219
+   }
220
+ });
221
+
222
+ markings.push({ color: '#000', lineWidth: 1, yaxis: { from: 0, to: 0 } });
223
+
202 224
  plots.history = $.plot($('#history'), transData, {
203 225
    xaxis: { mode: 'time', timeformat: '%y/%m' },
204 226
    series: {
205 227
      lines: { show: true, fill: true },
206 228
      points: { show: true }
207 229
    },
230
+   legend: { noColumns: 3, position: 'nw' },
208 231
    grid: {
209 232
      hoverable: true,
210 233
      clickable: true,
211
-     markings: [{ color: '#000', lineWidth: 1, xaxis: { from: min, to: max }, yaxis: { from: 0, to: 0 } }]
234
+     markings: markings 
212 235
    },
213 236
    selection: { mode : "x" }
214 237
  });
215 238
 
216
- plots.cathistory = $.plot($('#cathistory'), catData, {
217
-   xaxis: { mode: 'time', timeformat: '%y/%m' },
218
-   legend: { noColumns: 2 },
219
-   series: {
220
-     stack: true,
221
-     lines: { show: true, fill: true }
222
-   },
223
- });
224
-
225 239
  $("#history").bind("plothover", function (event, pos, item) {
226 240
   if (item) {
227 241
    var id = {dataIndex: item.dataIndex, seriesIndex: item.seriesIndex};

Načítá se…
Zrušit
Uložit