visage-app 0.9.5 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.6
@@ -89,38 +89,41 @@ function formatSeriesLabel(labels) {
89
89
  return name.trim()
90
90
  }
91
91
 
92
- function formatValue(value, places) {
93
- var places = places ? places : 0
94
- switch(true) {
95
- case (Math.abs(value) > 1125899906842624):
96
- var label = value / 1125899906842624,
97
- unit = 'P';
98
- break
99
- case (Math.abs(value) > 1099511627776):
100
- var label = value / 1099511627776,
101
- unit = 'T';
102
- break
103
- case (Math.abs(value) > 1073741824):
104
- var label = value / 1073741824,
105
- unit = 'G';
106
- break
107
- case (Math.abs(value) > 1048576):
108
- var label = value / 1048576,
109
- unit = 'M';
110
- break
111
- case (Math.abs(value) > 1024):
112
- var label = value / 1024,
113
- unit = 'K';
114
- break
115
- default:
116
- var label = value,
117
- unit = '';
118
- break
119
- }
120
-
121
- var rounded = label.round(places)
122
-
123
- return rounded + unit
92
+ function formatValue(value, options) {
93
+ var precision = options.precision,
94
+ min = options.min,
95
+ max = options.max;
96
+
97
+ switch(true) {
98
+ case (Math.abs(max) > 1125899906842624):
99
+ var label = value / 1125899906842624,
100
+ unit = 'P';
101
+ break
102
+ case (Math.abs(max) > 1099511627776):
103
+ var label = value / 1099511627776,
104
+ unit = 'T';
105
+ break
106
+ case (Math.abs(max) > 1073741824):
107
+ var label = value / 1073741824,
108
+ unit = 'G';
109
+ break
110
+ case (Math.abs(max) > 1048576):
111
+ var label = value / 1048576,
112
+ unit = 'M';
113
+ break
114
+ case (Math.abs(max) > 1024):
115
+ var label = value / 1024,
116
+ unit = 'K';
117
+ break
118
+ default:
119
+ var label = value,
120
+ unit = '';
121
+ break
122
+ }
123
+
124
+ var rounded = label.round(precision)
125
+
126
+ return rounded + unit
124
127
  }
125
128
 
126
129
  function formatDate(d) {
@@ -245,7 +248,7 @@ var visageGraph = new Class({
245
248
  }, this);
246
249
 
247
250
  /* Reset the zoom */
248
- this.chart.toolbar.remove('zoom');
251
+ //this.chart.toolbar.remove('zoom');
249
252
  this.chart.xAxis.concat(this.chart.yAxis).each(function(axis) {
250
253
  axis.setExtremes(null,null,false);
251
254
  });
@@ -286,21 +289,46 @@ var visageGraph = new Class({
286
289
 
287
290
  return series
288
291
  },
292
+ getSeriesMinMax: function(series) {
293
+ var min, max;
294
+
295
+ series.each(function(set) {
296
+ values = set.data.map(function(point) {
297
+ var value = point[1];
298
+ return value
299
+ });
300
+
301
+ var setMin = values.min()
302
+ var setMax = values.max()
303
+
304
+ if ($chk(min)) {
305
+ min = min > setMin ? setMin : min
306
+ } else {
307
+ min = setMin
308
+ }
309
+
310
+ if ($chk(max)) {
311
+ max = max < setMax ? setMax : max
312
+ } else {
313
+ max = setMax
314
+ }
315
+ });
316
+
317
+ return {'min': min, 'max': max};
318
+ },
289
319
  drawChart: function() {
290
320
  var series = this.series,
291
321
  title = this.graphName(),
292
322
  element = this.parentElement,
293
323
  ytitle = formatPluginName(this.options.plugin),
294
- max = 0
324
+ min,
325
+ max;
295
326
 
296
327
  /* Get the maximum value across all sets.
297
328
  * Used later on to determine the decimal place in the label. */
298
- series.each(function(set) {
299
- var setMax = set.data.max()
300
- if ( setMax > max ) {
301
- max = setMax
302
- }
303
- });
329
+ meta = this.getSeriesMinMax(series);
330
+ var min = meta.min,
331
+ max = meta.max;
304
332
 
305
333
  this.chart = new Highcharts.Chart({
306
334
  chart: {
@@ -349,19 +377,25 @@ var visageGraph = new Class({
349
377
  title: {
350
378
  text: ytitle
351
379
  },
352
- maxPadding: 0,
353
- plotLines: [{
354
- width: 0.5,
355
- }],
380
+ startOnTick: false,
381
+ minPadding: 0.065,
382
+ max: max,
383
+ endOnTick: true,
356
384
  labels: {
357
- formatter: function() {
358
- var places = max < 10 ? 2 : 0
359
- return formatValue(this.value, places)
360
- }
385
+ formatter: function() {
386
+ var precision = min - max < 1000 ? 2 : 0,
387
+ value = formatValue(this.value, {
388
+ 'precision': precision,
389
+ 'min': min,
390
+ 'max': max
391
+ });
392
+ return value
393
+ }
361
394
  }
362
395
  },
363
396
  plotOptions: {
364
397
  series: {
398
+ shadow: false,
365
399
  marker: {
366
400
  enabled: false,
367
401
  stacking: 'normal',
@@ -376,9 +410,19 @@ var visageGraph = new Class({
376
410
  tooltip: {
377
411
  formatter: function() {
378
412
  var tip;
379
- tip = '<b>' + formatSeriesLabel(this.series.name).trim() + '</b>-> '
380
- tip += formatValue(this.y, 2) + ' <br/>'
413
+ tip = '<strong>'
414
+ tip += formatSeriesLabel(this.series.name).trim()
415
+ tip += '</strong>' + ' -> '
416
+ tip += '<span style="font-family: monospace; font-size: 14px;">'
417
+ tip += formatValue(this.y, { 'precision': 2, 'min': min, 'max': max })
418
+ tip += '<span style="font-size: 9px; color: #777">'
419
+ tip += ' (' + this.y + ')'
420
+ tip += '</span>'
421
+ tip += '</span>'
422
+ tip += '<br/>'
423
+ tip += '<span style="font-family: monospace">'
381
424
  tip += formatDate(this.x)
425
+ tip += '</span>'
382
426
 
383
427
  return tip
384
428
  }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 5
9
- version: 0.9.5
8
+ - 6
9
+ version: 0.9.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lindsay Holmwood
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-08 00:00:00 +10:00
17
+ date: 2011-05-11 00:00:00 +10:00
18
18
  default_executable: visage-app
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency