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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 475d3c2bc4e116c303160ebe6d7ee481a327ec9f
4
- data.tar.gz: 7ac69774f198f1d39af5995446d6862d24eb6761
3
+ metadata.gz: 3fd2e85bdd6c7ae86f23c7689c7ff51ce68a6343
4
+ data.tar.gz: f7b3858f1ec10e0909aba49e3f2fccb07dab16ef
5
5
  SHA512:
6
- metadata.gz: 95aaf8f8d5fc8e7b88ef3a8116cf628b2f3a01ea425c8e85cde74109f0157a8db8601cba47667e8f4f9de49ff57ec655e550d39301b2738fd9b820371f2629a1
7
- data.tar.gz: add0166feba243f011faa403ab1979d4b2baeaa4b6c59ed9acb19172d98253860ccfa387ad9a27512ab589c172803d0c4be90cf72133edeb97294c5a0a60e3b6
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/Coffescript
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
- ###### coffeescript
116
- ```coffeescript
117
- SimpleChart.prototype.myChartOptions = ->
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
- borderWidth: 4
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/Coffescript
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.
@@ -1,3 +1,3 @@
1
1
  module SimpleChartjs
2
- VERSION = '1.0.5'.freeze
2
+ VERSION = '1.0.6'.freeze
3
3
  end