chartjs-ror 2.1.3 → 2.2.0
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/README.md +10 -8
- data/lib/chartjs/version.rb +1 -1
- data/vendor/assets/javascripts/Chart.js +26 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1305eb04d1021aef24382d5abd858e7d7e1bf6cc
|
4
|
+
data.tar.gz: dead45fff2f7983a0b633ae2b701e9096af037d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bb3b65298f372dd4bebd06bd5129f17e017b0ea5751b1928cfa8aadff630300db31a6bbb24880afe3350efe02744d84cb4d902f86affee65b03dff7700bf215
|
7
|
+
data.tar.gz: 8227ca71cdab84e8a8d28ebc49f564109d82f63aad66444e6903f39f5ced067ad81e4cdffbb38be813dce3bd24941d80a4d7c52202a9b242a7063b1297dfbaf3
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
Simplifies using [Chart.js][] in Rails views.
|
4
4
|
|
5
5
|
* All of Chart.js's features via one line of Ruby.
|
6
|
-
* Renders charts on page load rather than DOMContentReady ([reason][browsersupport]).
|
7
6
|
* Animates unless you have Modernizr and it doesn't detect canvas support ([reason][browsersupport]). You can manually override this.
|
8
7
|
* Optional alternative abscissa scale calculations (see [Chart.js#132][calculations]).
|
9
8
|
* Optional utility method for filling in gaps in integer series.
|
@@ -11,7 +10,7 @@ Simplifies using [Chart.js][] in Rails views.
|
|
11
10
|
|
12
11
|
## Current Chart.js version
|
13
12
|
|
14
|
-
This gem includes [Chart.js v1.0.
|
13
|
+
This gem includes [Chart.js v1.0.2](https://github.com/nnnick/Chart.js/tree/v1.0.2).
|
15
14
|
|
16
15
|
|
17
16
|
## Installation
|
@@ -165,13 +164,16 @@ You can put anything in the `options` hash that Chart.js recognises. It also su
|
|
165
164
|
legendHolder.innerHTML = legend;
|
166
165
|
canvas.parentNode.insertBefore(legendHolder.firstChild, canvas.nextSibling);
|
167
166
|
};
|
168
|
-
if (
|
169
|
-
|
170
|
-
document.addEventListener("page:load", initChart, false);
|
167
|
+
if (typeof Chart !== "undefined" && Chart !== null) {
|
168
|
+
initChart();
|
171
169
|
}
|
172
|
-
else
|
173
|
-
window.
|
174
|
-
|
170
|
+
else {
|
171
|
+
if (window.addEventListener) {
|
172
|
+
window.addEventListener("load", initChart, false);
|
173
|
+
}
|
174
|
+
else if (window.attachEvent) {
|
175
|
+
window.attachEvent("onload", initChart);
|
176
|
+
}
|
175
177
|
}
|
176
178
|
})();
|
177
179
|
</script>
|
data/lib/chartjs/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*!
|
2
2
|
* Chart.js
|
3
3
|
* http://chartjs.org/
|
4
|
-
* Version: 1.0.
|
4
|
+
* Version: 1.0.2
|
5
5
|
*
|
6
6
|
* Copyright 2015 Nick Downie
|
7
7
|
* Released under the MIT license
|
@@ -25,6 +25,25 @@
|
|
25
25
|
this.ctx = context;
|
26
26
|
|
27
27
|
//Variables global to the chart
|
28
|
+
var computeDimension = function(element,dimension)
|
29
|
+
{
|
30
|
+
if (element['offset'+dimension])
|
31
|
+
{
|
32
|
+
return element['offset'+dimension];
|
33
|
+
}
|
34
|
+
else
|
35
|
+
{
|
36
|
+
return document.defaultView.getComputedStyle(element).getPropertyValue(dimension);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
var width = this.width = computeDimension(context.canvas,'Width');
|
41
|
+
var height = this.height = computeDimension(context.canvas,'Height');
|
42
|
+
|
43
|
+
// Firefox requires this to work correctly
|
44
|
+
context.canvas.width = width;
|
45
|
+
context.canvas.height = height;
|
46
|
+
|
28
47
|
var width = this.width = context.canvas.width;
|
29
48
|
var height = this.height = context.canvas.height;
|
30
49
|
this.aspectRatio = this.width / this.height;
|
@@ -825,7 +844,7 @@
|
|
825
844
|
},
|
826
845
|
stop : function(){
|
827
846
|
// Stops any current animation loop occuring
|
828
|
-
|
847
|
+
cancelAnimFrame(this.animationFrame);
|
829
848
|
return this;
|
830
849
|
},
|
831
850
|
resize : function(callback){
|
@@ -1368,7 +1387,6 @@
|
|
1368
1387
|
var halfHeight = this.height/2;
|
1369
1388
|
|
1370
1389
|
//Check to ensure the height will fit on the canvas
|
1371
|
-
//The three is to buffer form the very
|
1372
1390
|
if (this.y - halfHeight < 0 ){
|
1373
1391
|
this.y = halfHeight;
|
1374
1392
|
} else if (this.y + halfHeight > this.chart.height){
|
@@ -1575,7 +1593,7 @@
|
|
1575
1593
|
var isRotated = (this.xLabelRotation > 0),
|
1576
1594
|
// innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding,
|
1577
1595
|
innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight),
|
1578
|
-
valueWidth = innerWidth/(this.valuesCount - ((this.offsetGridLines) ? 0 : 1)),
|
1596
|
+
valueWidth = innerWidth/Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1),
|
1579
1597
|
valueOffset = (valueWidth * index) + this.xScalePaddingLeft;
|
1580
1598
|
|
1581
1599
|
if (this.offsetGridLines){
|
@@ -2416,12 +2434,12 @@
|
|
2416
2434
|
}
|
2417
2435
|
},
|
2418
2436
|
calculateCircumference : function(value){
|
2419
|
-
return (Math.PI*2)*(value / this.total);
|
2437
|
+
return (Math.PI*2)*(Math.abs(value) / this.total);
|
2420
2438
|
},
|
2421
2439
|
calculateTotal : function(data){
|
2422
2440
|
this.total = 0;
|
2423
2441
|
helpers.each(data,function(segment){
|
2424
|
-
this.total += segment.value;
|
2442
|
+
this.total += Math.abs(segment.value);
|
2425
2443
|
},this);
|
2426
2444
|
},
|
2427
2445
|
update : function(){
|
@@ -3061,6 +3079,8 @@
|
|
3061
3079
|
helpers.each(this.segments,function(segment){
|
3062
3080
|
segment.save();
|
3063
3081
|
});
|
3082
|
+
|
3083
|
+
this.reflow();
|
3064
3084
|
this.render();
|
3065
3085
|
},
|
3066
3086
|
reflow : function(){
|