simple_chartjs 1.0.4 → 1.0.5
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/.gitignore +1 -0
- data/app/assets/javascripts/simple_chartjs.js +21 -25
- data/lib/chartjs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 475d3c2bc4e116c303160ebe6d7ee481a327ec9f
|
4
|
+
data.tar.gz: 7ac69774f198f1d39af5995446d6862d24eb6761
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95aaf8f8d5fc8e7b88ef3a8116cf628b2f3a01ea425c8e85cde74109f0157a8db8601cba47667e8f4f9de49ff57ec655e550d39301b2738fd9b820371f2629a1
|
7
|
+
data.tar.gz: add0166feba243f011faa403ab1979d4b2baeaa4b6c59ed9acb19172d98253860ccfa387ad9a27512ab589c172803d0c4be90cf72133edeb97294c5a0a60e3b6
|
data/.gitignore
CHANGED
@@ -19,17 +19,17 @@ SimpleChart.prototype.createChart = function() {
|
|
19
19
|
if(xhr.status === 200) {
|
20
20
|
chart.buildChart(xhr.response);
|
21
21
|
} else {
|
22
|
-
chart.ctx.innerText = "Failed to Load: An Error has Occured"
|
23
|
-
chart.ctx.style.color = "red"
|
22
|
+
chart.ctx.innerText = "Failed to Load: An Error has Occured";
|
23
|
+
chart.ctx.style.color = "red";
|
24
24
|
}
|
25
25
|
}
|
26
|
-
}
|
26
|
+
};
|
27
27
|
xhr.send();
|
28
|
-
}
|
28
|
+
};
|
29
29
|
|
30
30
|
SimpleChart.prototype.buildChart = function(data) {
|
31
31
|
var data = JSON.parse(data);
|
32
|
-
|
32
|
+
this.chartConfiguration();
|
33
33
|
|
34
34
|
this.ctx.innerHTML = this.canvas();
|
35
35
|
var canvas = this.ctx.getElementsByTagName('canvas')[0];
|
@@ -39,23 +39,19 @@ SimpleChart.prototype.buildChart = function(data) {
|
|
39
39
|
data: this.formatChartData(data),
|
40
40
|
options: this.configurationOptions
|
41
41
|
});
|
42
|
-
}
|
42
|
+
};
|
43
43
|
|
44
44
|
SimpleChart.prototype.chartConfiguration = function() {
|
45
|
-
var optionMethod = this.ctx.dataset
|
45
|
+
var optionMethod = this.ctx.dataset.options;
|
46
46
|
|
47
47
|
if(typeof(optionMethod) != "undefined" && typeof(this[this.convertToCamelCase(optionMethod) + "Options"]) != "undefined") {
|
48
|
-
|
49
|
-
|
50
|
-
this.configureOption('options', JSON.parse(this.configurationOptions), optionMethod)
|
51
|
-
]
|
48
|
+
this.datasetProperties = this.configureOption('datasetProperties', JSON.parse(this.datasetProperties), optionMethod);
|
49
|
+
this.configurationOptions = this.configureOption('options', JSON.parse(this.configurationOptions), optionMethod);
|
52
50
|
} else {
|
53
|
-
|
54
|
-
|
55
|
-
this.formatRubyObject(JSON.parse(this.configurationOptions))
|
56
|
-
]
|
51
|
+
this.datasetProperties = this.formatRubyObject(JSON.parse(this.datasetProperties));
|
52
|
+
this.configurationOptions = this.formatRubyObject(JSON.parse(this.configurationOptions));
|
57
53
|
}
|
58
|
-
}
|
54
|
+
};
|
59
55
|
|
60
56
|
SimpleChart.prototype.configureOption = function(option_name, current_options, optionMethod) {
|
61
57
|
var options = this[this.convertToCamelCase(optionMethod) + "Options"]()[option_name];
|
@@ -64,11 +60,11 @@ SimpleChart.prototype.configureOption = function(option_name, current_options, o
|
|
64
60
|
return this.mergeObjects(
|
65
61
|
options,
|
66
62
|
this.formatRubyObject(current_options)
|
67
|
-
)
|
63
|
+
);
|
68
64
|
} else {
|
69
|
-
return this.formatRubyObject(current_options)
|
65
|
+
return this.formatRubyObject(current_options);
|
70
66
|
}
|
71
|
-
}
|
67
|
+
};
|
72
68
|
|
73
69
|
SimpleChart.prototype.formatChartData = function(data) {
|
74
70
|
var chartData = data;
|
@@ -92,14 +88,14 @@ SimpleChart.prototype.formatChartData = function(data) {
|
|
92
88
|
}
|
93
89
|
|
94
90
|
return chartData;
|
95
|
-
}
|
91
|
+
};
|
96
92
|
|
97
93
|
SimpleChart.prototype.formatArrayRubyObjects = function(array) {
|
98
94
|
for (var i = 0; i < array.length; i++) {
|
99
95
|
this.formatRubyObject(array[i]);
|
100
96
|
}
|
101
97
|
return array;
|
102
|
-
}
|
98
|
+
};
|
103
99
|
|
104
100
|
SimpleChart.prototype.formatRubyObject = function(object) {
|
105
101
|
for (property in object) {
|
@@ -115,18 +111,18 @@ SimpleChart.prototype.formatRubyObject = function(object) {
|
|
115
111
|
}
|
116
112
|
}
|
117
113
|
return object;
|
118
|
-
}
|
114
|
+
};
|
119
115
|
|
120
116
|
SimpleChart.prototype.convertToCamelCase = function(string) {
|
121
117
|
return string.replace(/[-_]([a-z])/, function(_, letter) {
|
122
118
|
return letter.toUpperCase();
|
123
119
|
});
|
124
|
-
}
|
120
|
+
};
|
125
121
|
|
126
122
|
SimpleChart.prototype.mergeObjects = function(obj, src) {
|
127
123
|
Object.keys(src).forEach(function(key) { obj[key] = src[key]; });
|
128
124
|
return obj;
|
129
|
-
}
|
125
|
+
};
|
130
126
|
|
131
127
|
SimpleChart.prototype.canvas = function() {
|
132
128
|
var canvas = '<canvas';
|
@@ -135,4 +131,4 @@ SimpleChart.prototype.canvas = function() {
|
|
135
131
|
canvas += '></canvas>';
|
136
132
|
|
137
133
|
return canvas;
|
138
|
-
}
|
134
|
+
};
|
data/lib/chartjs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_chartjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Venables
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|