morrisjs-rails 0.4.2.1 → 0.4.3
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.
- checksums.yaml +4 -4
- data/lib/morrisjs-rails/version.rb +1 -1
- data/vendor/assets/javascripts/morris.js +64 -23
- metadata +6 -5
- data/vendor/assets/stylesheets/untitled +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 557908fc7a271ae63e08996d9431037e79544876
|
|
4
|
+
data.tar.gz: 59a397f9c96a4fd6cad0be9e5af25dd3500c6330
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 093630ae1057b764c4c1699cd23b05e504b65843d1083bd22fe97c2146345a6b3c18fd3a1af34e2fb19bc3aad350615e302eeae409103bfcf55a9361d5ae9836
|
|
7
|
+
data.tar.gz: 04b2169c8e6cb7934ae6c849fffb55622b538d91af1dfea6d3c10a424f550bce9a062d03ee5e5836bbb7cc558477c7658139f35d20d83b4cf6c5377b36322b33
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
if (this.handlers[name] == null) {
|
|
22
22
|
this.handlers[name] = [];
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
this.handlers[name].push(handler);
|
|
25
|
+
return this;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
EventEmitter.prototype.fire = function() {
|
|
@@ -125,8 +126,11 @@
|
|
|
125
126
|
gridStrokeWidth: 0.5,
|
|
126
127
|
gridTextColor: '#888',
|
|
127
128
|
gridTextSize: 12,
|
|
129
|
+
gridTextFamily: 'sans-serif',
|
|
130
|
+
gridTextWeight: 'normal',
|
|
128
131
|
hideHover: false,
|
|
129
132
|
yLabelFormat: null,
|
|
133
|
+
xLabelAngle: 0,
|
|
130
134
|
numLines: 5,
|
|
131
135
|
padding: 25,
|
|
132
136
|
parseTime: true,
|
|
@@ -147,6 +151,7 @@
|
|
|
147
151
|
if (redraw == null) {
|
|
148
152
|
redraw = true;
|
|
149
153
|
}
|
|
154
|
+
this.options.data = data;
|
|
150
155
|
if (!(data != null) || data.length === 0) {
|
|
151
156
|
this.data = [];
|
|
152
157
|
this.raphael.clear();
|
|
@@ -179,6 +184,9 @@
|
|
|
179
184
|
}
|
|
180
185
|
} else {
|
|
181
186
|
ret.x = index;
|
|
187
|
+
if (this.options.xLabelFormat) {
|
|
188
|
+
ret.label = this.options.xLabelFormat(ret);
|
|
189
|
+
}
|
|
182
190
|
}
|
|
183
191
|
total = 0;
|
|
184
192
|
ret.y = (function() {
|
|
@@ -341,7 +349,7 @@
|
|
|
341
349
|
};
|
|
342
350
|
|
|
343
351
|
Grid.prototype._calc = function() {
|
|
344
|
-
var gridLine, h, w, yLabelWidths;
|
|
352
|
+
var bottomOffsets, gridLine, h, i, w, yLabelWidths;
|
|
345
353
|
w = this.el.width();
|
|
346
354
|
h = this.el.height();
|
|
347
355
|
if (this.elementWidth !== w || this.elementHeight !== h || this.dirty) {
|
|
@@ -359,12 +367,20 @@
|
|
|
359
367
|
_results = [];
|
|
360
368
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
361
369
|
gridLine = _ref[_i];
|
|
362
|
-
_results.push(this.measureText(this.yAxisFormat(gridLine)
|
|
370
|
+
_results.push(this.measureText(this.yAxisFormat(gridLine)).width);
|
|
363
371
|
}
|
|
364
372
|
return _results;
|
|
365
373
|
}).call(this);
|
|
366
374
|
this.left += Math.max.apply(Math, yLabelWidths);
|
|
367
|
-
|
|
375
|
+
bottomOffsets = (function() {
|
|
376
|
+
var _i, _ref, _results;
|
|
377
|
+
_results = [];
|
|
378
|
+
for (i = _i = 0, _ref = this.data.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
|
|
379
|
+
_results.push(this.measureText(this.data[i].text, -this.options.xLabelAngle).height);
|
|
380
|
+
}
|
|
381
|
+
return _results;
|
|
382
|
+
}).call(this);
|
|
383
|
+
this.bottom -= Math.max.apply(Math, bottomOffsets);
|
|
368
384
|
}
|
|
369
385
|
this.width = Math.max(1, this.right - this.left);
|
|
370
386
|
this.height = Math.max(1, this.bottom - this.top);
|
|
@@ -399,12 +415,12 @@
|
|
|
399
415
|
}
|
|
400
416
|
};
|
|
401
417
|
|
|
402
|
-
Grid.prototype.measureText = function(text,
|
|
418
|
+
Grid.prototype.measureText = function(text, angle) {
|
|
403
419
|
var ret, tt;
|
|
404
|
-
if (
|
|
405
|
-
|
|
420
|
+
if (angle == null) {
|
|
421
|
+
angle = 0;
|
|
406
422
|
}
|
|
407
|
-
tt = this.raphael.text(100, 100, text).attr('font-size',
|
|
423
|
+
tt = this.raphael.text(100, 100, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).rotate(angle);
|
|
408
424
|
ret = tt.getBBox();
|
|
409
425
|
tt.remove();
|
|
410
426
|
return ret;
|
|
@@ -485,7 +501,7 @@
|
|
|
485
501
|
};
|
|
486
502
|
|
|
487
503
|
Grid.prototype.drawYAxisLabel = function(xPos, yPos, text) {
|
|
488
|
-
return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end');
|
|
504
|
+
return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end');
|
|
489
505
|
};
|
|
490
506
|
|
|
491
507
|
Grid.prototype.drawGridLine = function(path) {
|
|
@@ -599,7 +615,7 @@
|
|
|
599
615
|
}
|
|
600
616
|
return this.el.css({
|
|
601
617
|
left: left + "px",
|
|
602
|
-
top: top + "px"
|
|
618
|
+
top: parseInt(top) + "px"
|
|
603
619
|
});
|
|
604
620
|
};
|
|
605
621
|
|
|
@@ -660,7 +676,7 @@
|
|
|
660
676
|
smooth: true,
|
|
661
677
|
xLabels: 'auto',
|
|
662
678
|
xLabelFormat: null,
|
|
663
|
-
xLabelMargin:
|
|
679
|
+
xLabelMargin: 24,
|
|
664
680
|
continuousLine: true,
|
|
665
681
|
hideHover: false
|
|
666
682
|
};
|
|
@@ -735,7 +751,7 @@
|
|
|
735
751
|
};
|
|
736
752
|
|
|
737
753
|
Line.prototype.onHoverOut = function() {
|
|
738
|
-
if (this.options.hideHover
|
|
754
|
+
if (this.options.hideHover !== false) {
|
|
739
755
|
return this.displayHoverForRow(null);
|
|
740
756
|
}
|
|
741
757
|
};
|
|
@@ -822,15 +838,28 @@
|
|
|
822
838
|
};
|
|
823
839
|
|
|
824
840
|
Line.prototype.drawXAxis = function() {
|
|
825
|
-
var drawLabel, l, labels, prevLabelMargin, row, ypos, _i, _len, _results,
|
|
841
|
+
var drawLabel, l, labels, prevAngleMargin, prevLabelMargin, row, ypos, _i, _len, _results,
|
|
826
842
|
_this = this;
|
|
827
|
-
ypos = this.bottom + this.options.
|
|
843
|
+
ypos = this.bottom + this.options.padding / 2;
|
|
828
844
|
prevLabelMargin = null;
|
|
845
|
+
prevAngleMargin = null;
|
|
829
846
|
drawLabel = function(labelText, xpos) {
|
|
830
|
-
var label, labelBox;
|
|
847
|
+
var label, labelBox, margin, offset, textBox;
|
|
831
848
|
label = _this.drawXAxisLabel(_this.transX(xpos), ypos, labelText);
|
|
849
|
+
textBox = label.getBBox();
|
|
850
|
+
label.transform("r" + (-_this.options.xLabelAngle));
|
|
832
851
|
labelBox = label.getBBox();
|
|
833
|
-
|
|
852
|
+
label.transform("t0," + (labelBox.height / 2) + "...");
|
|
853
|
+
if (_this.options.xLabelAngle !== 0) {
|
|
854
|
+
offset = -0.5 * textBox.width * Math.cos(_this.options.xLabelAngle * Math.PI / 180.0);
|
|
855
|
+
label.transform("t" + offset + ",0...");
|
|
856
|
+
}
|
|
857
|
+
labelBox = label.getBBox();
|
|
858
|
+
if ((!(prevLabelMargin != null) || prevLabelMargin >= labelBox.x + labelBox.width || (prevAngleMargin != null) && prevAngleMargin >= labelBox.x) && labelBox.x >= 0 && (labelBox.x + labelBox.width) < _this.el.width()) {
|
|
859
|
+
if (_this.options.xLabelAngle !== 0) {
|
|
860
|
+
margin = 1.25 * _this.options.gridTextSize / Math.sin(_this.options.xLabelAngle * Math.PI / 180.0);
|
|
861
|
+
prevAngleMargin = labelBox.x - margin;
|
|
862
|
+
}
|
|
834
863
|
return prevLabelMargin = labelBox.x - _this.options.xLabelMargin;
|
|
835
864
|
} else {
|
|
836
865
|
return label.remove();
|
|
@@ -997,7 +1026,7 @@
|
|
|
997
1026
|
};
|
|
998
1027
|
|
|
999
1028
|
Line.prototype.drawXAxisLabel = function(xPos, yPos, text) {
|
|
1000
|
-
return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor);
|
|
1029
|
+
return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor);
|
|
1001
1030
|
};
|
|
1002
1031
|
|
|
1003
1032
|
Line.prototype.drawLinePath = function(path, lineColor) {
|
|
@@ -1238,7 +1267,7 @@
|
|
|
1238
1267
|
Area.prototype.fillForSeries = function(i) {
|
|
1239
1268
|
var color;
|
|
1240
1269
|
color = Raphael.rgb2hsl(this.colorFor(this.data[i], i, 'line'));
|
|
1241
|
-
return Raphael.hsl(color.h,
|
|
1270
|
+
return Raphael.hsl(color.h, this.options.behaveLikeLine ? color.s * 0.9 : color.s * 0.75, Math.min(0.98, this.options.behaveLikeLine ? color.l * 1.2 : color.l * 1.25));
|
|
1242
1271
|
};
|
|
1243
1272
|
|
|
1244
1273
|
Area.prototype.drawFilledPath = function(path, fill) {
|
|
@@ -1327,15 +1356,27 @@
|
|
|
1327
1356
|
};
|
|
1328
1357
|
|
|
1329
1358
|
Bar.prototype.drawXAxis = function() {
|
|
1330
|
-
var i, label, labelBox, prevLabelMargin, row, ypos, _i, _ref, _results;
|
|
1331
|
-
ypos = this.bottom + this.options.
|
|
1359
|
+
var i, label, labelBox, margin, offset, prevAngleMargin, prevLabelMargin, row, textBox, ypos, _i, _ref, _results;
|
|
1360
|
+
ypos = this.bottom + this.options.padding / 2;
|
|
1332
1361
|
prevLabelMargin = null;
|
|
1362
|
+
prevAngleMargin = null;
|
|
1333
1363
|
_results = [];
|
|
1334
1364
|
for (i = _i = 0, _ref = this.data.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
|
|
1335
1365
|
row = this.data[this.data.length - 1 - i];
|
|
1336
1366
|
label = this.drawXAxisLabel(row._x, ypos, row.label);
|
|
1367
|
+
textBox = label.getBBox();
|
|
1368
|
+
label.transform("r" + (-this.options.xLabelAngle));
|
|
1337
1369
|
labelBox = label.getBBox();
|
|
1338
|
-
|
|
1370
|
+
label.transform("t0," + (labelBox.height / 2) + "...");
|
|
1371
|
+
if (this.options.xLabelAngle !== 0) {
|
|
1372
|
+
offset = -0.5 * textBox.width * Math.cos(this.options.xLabelAngle * Math.PI / 180.0);
|
|
1373
|
+
label.transform("t" + offset + ",0...");
|
|
1374
|
+
}
|
|
1375
|
+
if ((!(prevLabelMargin != null) || prevLabelMargin >= labelBox.x + labelBox.width || (prevAngleMargin != null) && prevAngleMargin >= labelBox.x) && labelBox.x >= 0 && (labelBox.x + labelBox.width) < this.el.width()) {
|
|
1376
|
+
if (this.options.xLabelAngle !== 0) {
|
|
1377
|
+
margin = 1.25 * this.options.gridTextSize / Math.sin(this.options.xLabelAngle * Math.PI / 180.0);
|
|
1378
|
+
prevAngleMargin = labelBox.x - margin;
|
|
1379
|
+
}
|
|
1339
1380
|
_results.push(prevLabelMargin = labelBox.x - this.options.xLabelMargin);
|
|
1340
1381
|
} else {
|
|
1341
1382
|
_results.push(label.remove());
|
|
@@ -1433,7 +1474,7 @@
|
|
|
1433
1474
|
};
|
|
1434
1475
|
|
|
1435
1476
|
Bar.prototype.onHoverOut = function() {
|
|
1436
|
-
if (this.options.hideHover
|
|
1477
|
+
if (this.options.hideHover !== false) {
|
|
1437
1478
|
return this.hover.hide();
|
|
1438
1479
|
}
|
|
1439
1480
|
};
|
|
@@ -1456,7 +1497,7 @@
|
|
|
1456
1497
|
|
|
1457
1498
|
Bar.prototype.drawXAxisLabel = function(xPos, yPos, text) {
|
|
1458
1499
|
var label;
|
|
1459
|
-
return label = this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('fill', this.options.gridTextColor);
|
|
1500
|
+
return label = this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor);
|
|
1460
1501
|
};
|
|
1461
1502
|
|
|
1462
1503
|
Bar.prototype.drawBar = function(xPos, yPos, width, height, barColor) {
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: morrisjs-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- beanie
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-05-
|
|
11
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|
|
@@ -41,10 +41,10 @@ files:
|
|
|
41
41
|
- lib/morrisjs-rails.rb
|
|
42
42
|
- vendor/assets/javascripts/morris.js
|
|
43
43
|
- vendor/assets/stylesheets/morris.css
|
|
44
|
-
- vendor/assets/stylesheets/untitled
|
|
45
44
|
- README.md
|
|
46
45
|
homepage: https://github.com/beanieboi/morrisjs-rails
|
|
47
|
-
licenses:
|
|
46
|
+
licenses:
|
|
47
|
+
- MIT
|
|
48
48
|
metadata: {}
|
|
49
49
|
post_install_message:
|
|
50
50
|
rdoc_options: []
|
|
@@ -62,8 +62,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
62
|
version: '0'
|
|
63
63
|
requirements: []
|
|
64
64
|
rubyforge_project:
|
|
65
|
-
rubygems_version: 2.0.
|
|
65
|
+
rubygems_version: 2.0.2
|
|
66
66
|
signing_key:
|
|
67
67
|
specification_version: 4
|
|
68
68
|
summary: morris.js for the Rails Asset Pipeline
|
|
69
69
|
test_files: []
|
|
70
|
+
has_rdoc:
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
path = File.join(Rails.root, 'config', 'action_mailer.yml')
|
|
2
|
-
options = YAML.load_file(path)[Rails.env]
|
|
3
|
-
|
|
4
|
-
ActionMailer::Base.delivery_method = Rails.env.test? ? :test : :smtp
|
|
5
|
-
|
|
6
|
-
ActionMailer::Base.smtp_settings = {
|
|
7
|
-
:host => options['host'],
|
|
8
|
-
:address => options['address'],
|
|
9
|
-
:port => options['port'],
|
|
10
|
-
:domain => options['domain'],
|
|
11
|
-
:user_name => options['user_name'],
|
|
12
|
-
:password => options['password'],
|
|
13
|
-
:authentication => options['authentication']
|
|
14
|
-
}
|