simple_chartjs 1.0.5 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +27 -25
- data/lib/chartjs/version.rb +1 -1
- data/vendor/assets/javascript/Chart.js +14145 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd2e85bdd6c7ae86f23c7689c7ff51ce68a6343
|
4
|
+
data.tar.gz: f7b3858f1ec10e0909aba49e3f2fccb07dab16ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 528a8e4e3e0626021213f828a8cf60413df016434b9aac9cc46ae327e471e5a45d491f4a84611042be393c128ce4ba9a3ff0ea35e9582743c5bc9890cf7dad7a
|
7
|
+
data.tar.gz: d6b4f9197e8d643b1e84996b3dc186aea2616056def906fab11918cbc9f4de664cc5be0c57dc2f07014e3128ced916a75eeddbc3c3e5537a0dae8dd8b65cdef4
|
data/README.md
CHANGED
@@ -16,8 +16,22 @@ gem 'simple_chartjs'
|
|
16
16
|
|
17
17
|
In `application.js`, add:
|
18
18
|
|
19
|
+
Choose the appropriate ChartJS file depending on if you want it bundled with
|
20
|
+
MomentJS:
|
21
|
+
|
22
|
+
- Without Moment.js:
|
23
|
+
```javascript
|
24
|
+
//= require Chart.min
|
25
|
+
```
|
26
|
+
|
27
|
+
- With Moment.js:
|
28
|
+
```javascript
|
29
|
+
//= require Chart.bundle.min
|
30
|
+
```
|
31
|
+
|
32
|
+
Then require the simple_chartjs file
|
33
|
+
|
19
34
|
```javascript
|
20
|
-
//= require Chart.bundle
|
21
35
|
//= require simple_chartjs
|
22
36
|
```
|
23
37
|
|
@@ -94,14 +108,12 @@ The dataset properties can be set in the view like below.
|
|
94
108
|
bar_chart chart_data_path, dataset_properties: { border_width: 4 }
|
95
109
|
```
|
96
110
|
|
97
|
-
##### Javascript
|
111
|
+
##### Javascript
|
98
112
|
If you want more control from a javascript perspective you can set a function that the chart will call and add those dataset properties. To do this you name a method as a data attribute call options like below.
|
99
113
|
```ruby
|
100
114
|
bar_chart chart_data_path, data: { options: 'my-chart' }
|
101
115
|
```
|
102
116
|
In the javascript you create a function on SimpleChart
|
103
|
-
|
104
|
-
###### javascript
|
105
117
|
```javascript
|
106
118
|
SimpleChart.prototype.myChartOptions = function() {
|
107
119
|
return {
|
@@ -112,15 +124,20 @@ SimpleChart.prototype.myChartOptions = function() {
|
|
112
124
|
}
|
113
125
|
}
|
114
126
|
```
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
127
|
+
|
128
|
+
If you need to dynamically set a value such as Background Color for each value in the dataset, datasetProperties does support callbacks as shown below. The function will receive one argument, which is the current dataset.
|
129
|
+
|
130
|
+
```javascript
|
131
|
+
SimpleChart.prototype.myChartOptions = function() {
|
132
|
+
return {
|
119
133
|
datasetProperties: {
|
120
|
-
|
134
|
+
backgroundColor: function(data) {
|
135
|
+
...
|
136
|
+
}
|
121
137
|
},
|
122
138
|
options: {...}
|
123
139
|
}
|
140
|
+
}
|
124
141
|
```
|
125
142
|
|
126
143
|
#### Configuration Options
|
@@ -132,14 +149,12 @@ The configuration options can be set in the view like below.
|
|
132
149
|
bar_chart chart_data_path, options: { scales: { x_axes: [{ bar_percentage: 0.2}] } }
|
133
150
|
```
|
134
151
|
|
135
|
-
##### Javascript
|
152
|
+
##### Javascript
|
136
153
|
If you want more control from a javascript perspective you can set a function that the chart will call and add those configuration options. To do this you name a method as a data attribute call options like below.
|
137
154
|
```ruby
|
138
155
|
bar_chart chart_data_path, data: { options: 'my-chart' }
|
139
156
|
```
|
140
157
|
In the javascript you create a function on SimpleChart
|
141
|
-
|
142
|
-
###### javascript
|
143
158
|
```javascript
|
144
159
|
SimpleChart.prototype.myChartOptions = function() {
|
145
160
|
return {
|
@@ -152,19 +167,6 @@ SimpleChart.prototype.myChartOptions = function() {
|
|
152
167
|
}
|
153
168
|
}
|
154
169
|
```
|
155
|
-
###### coffeescript
|
156
|
-
```coffeescript
|
157
|
-
SimpleChart.prototype.myChartOptions = ->
|
158
|
-
{
|
159
|
-
datasetProperties: {...},
|
160
|
-
options: {
|
161
|
-
scales: {
|
162
|
-
xAxes: [{ barPercentage: 0.2 }]
|
163
|
-
}
|
164
|
-
}
|
165
|
-
}
|
166
|
-
```
|
167
|
-
|
168
170
|
## Development
|
169
171
|
|
170
172
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/chartjs/version.rb
CHANGED