peity_vanilla_rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f04e35a10743476825e404056471ab5ec13c54372653d516a43c684e632b82
4
- data.tar.gz: ae91de3bee20977261f2ac80a70fcac274aa27e109035f5fdfe825f9f5481a92
3
+ metadata.gz: d8ef36129e4a4f5a3e7b6ff1017312096f2d491176b363b207d8124512ea6b76
4
+ data.tar.gz: 6cc33d0c33baaa411e68fa616453ad124a11e25fc62c1397656caa6608accffb
5
5
  SHA512:
6
- metadata.gz: 5a5903519f2834b17ab6a9e1421636855cba3602206e50d2224b4e072b38d218145e5ea6d0fef7ffbd35552494b51f57517ec25f6e8701048cf35a226dc1f213
7
- data.tar.gz: 3a3cf7fc61864c1b88d3459568997b56de62732eaf476b13bea94741942b25e59abfe43b88818fa6261f84043b8b54d17f190308aef3b538fb2f91e317342eef
6
+ metadata.gz: 2bc857d3c1db58c24ecfa884cac3f4ad50f220ab83c40747b8e6e11a9e0a95920ae75bbfa32be8653bdfc63f91e3382459457a17f02baa6f38a299bda8657ef8
7
+ data.tar.gz: 7cba004c469dfad243bf47cad673756a6b734adb7138c8e39c60a5059fde793a0bd9857b399e31e0d02618d6e236815e0c1f148e725ae9a3b599352bf1d3b177
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Peity Vanilla Rails
2
2
 
3
+ [![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
4
+
3
5
  Sparklines are small but intense charts. This gem is a wrapper around [peity_vanilla](https://github.com/railsjazz/peity_vanilla) library. You can generate simple but informative charts with vanilla JS.
4
6
 
5
7
  <img src="./docs/sparklines.png" height="400px"/>
@@ -14,10 +16,22 @@ gem "peity_vanilla_rails"
14
16
 
15
17
  2. Add to `application.js`
16
18
 
19
+ ### For Assets Pipeline:
20
+
17
21
  ```javascript
18
22
  //= require peity_vanilla.js
19
23
  ```
20
24
 
25
+ ### For Importmaps
26
+
27
+ In `application.js`
28
+
29
+ ```js
30
+ import peity from "peity";
31
+
32
+ window.peity = peity;
33
+ ```
34
+
21
35
  3. Add charts in your code:
22
36
 
23
37
  ```erb
@@ -58,13 +72,12 @@ Check the [original](https://github.com/railsjazz/peity_vanilla) page.
58
72
 
59
73
  setInterval(function() {
60
74
  var random = Math.round(Math.random() * 10)
61
- // debugger
62
- var values = updatingChart.innerText.split(",")
75
+ var values = updatingChart.element.innerText.split(",")
63
76
  values.shift()
64
77
  values.push(random)
65
78
 
66
- updatingChart.innerText = values.join(",")
67
- updatingChart.dispatchEvent(new Event('change'))
79
+ updatingChart.element.innerText = values.join(",")
80
+ updatingChart.element.dispatchEvent(new Event('change'))
68
81
  }, 1000);
69
82
  </script>
70
83
  ```
@@ -0,0 +1,376 @@
1
+ /*!
2
+ Peity Vanila JS 0.0.5
3
+ Copyright © 2022 RailsJazz
4
+ https://railsjazz.com
5
+ */
6
+
7
+ function _classCallCheck(instance, Constructor) {
8
+ if (!(instance instanceof Constructor)) {
9
+ throw new TypeError("Cannot call a class as a function");
10
+ }
11
+ }
12
+
13
+ function _defineProperties(target, props) {
14
+ for (var i = 0; i < props.length; i++) {
15
+ var descriptor = props[i];
16
+ descriptor.enumerable = descriptor.enumerable || false;
17
+ descriptor.configurable = true;
18
+ if ("value" in descriptor) descriptor.writable = true;
19
+ Object.defineProperty(target, descriptor.key, descriptor);
20
+ }
21
+ }
22
+
23
+ function _createClass(Constructor, protoProps, staticProps) {
24
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
+ if (staticProps) _defineProperties(Constructor, staticProps);
26
+ Object.defineProperty(Constructor, "prototype", {
27
+ writable: false
28
+ });
29
+ return Constructor;
30
+ }
31
+
32
+ function _defineProperty(obj, key, value) {
33
+ if (key in obj) {
34
+ Object.defineProperty(obj, key, {
35
+ value: value,
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true
39
+ });
40
+ } else {
41
+ obj[key] = value;
42
+ }
43
+
44
+ return obj;
45
+ }
46
+
47
+ var isFunction = function isFunction(o) {
48
+ return o !== null && typeof o === "function" && !!o.apply;
49
+ };
50
+ var svgElement = function svgElement(tag, attrs) {
51
+ var element = document.createElementNS("http://www.w3.org/2000/svg", tag);
52
+
53
+ for (var attr in attrs) {
54
+ element.setAttribute(attr, attrs[attr]);
55
+ }
56
+
57
+ return element;
58
+ };
59
+ var svgSupported = "createElementNS" in document && svgElement("svg", {}).createSVGRect();
60
+
61
+ var Peity = /*#__PURE__*/function () {
62
+ function Peity(element, type) {
63
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
64
+
65
+ _classCallCheck(this, Peity);
66
+
67
+ this.element = element;
68
+ this.type = type;
69
+ this.options = Object.assign({}, Peity.defaults[type], JSON.parse(element.dataset["peity"] || "{}"), options);
70
+ }
71
+
72
+ _createClass(Peity, [{
73
+ key: "draw",
74
+ value: function draw() {
75
+ var options = this.options;
76
+ Peity.graphers[this.type](this);
77
+ if (isFunction(options.after)) options.after.call(this, options);
78
+ }
79
+ }, {
80
+ key: "fill",
81
+ value: function fill() {
82
+ var fill = this.options.fill;
83
+ return isFunction(fill) ? fill : function (_, i) {
84
+ return fill[i % fill.length];
85
+ };
86
+ }
87
+ }, {
88
+ key: "prepare",
89
+ value: function prepare(width, height) {
90
+ if (!this.svg) {
91
+ this.element.style.display = "none";
92
+ this.element.after(this.svg = svgElement("svg", {
93
+ class: "peity"
94
+ }));
95
+ }
96
+
97
+ this.svg.innerHTML = "";
98
+ this.svg.setAttribute("width", width);
99
+ this.svg.setAttribute("height", height);
100
+ return this.svg;
101
+ }
102
+ }, {
103
+ key: "values",
104
+ get: function get() {
105
+ return this.element.innerText.split(this.options.delimiter).map(function (value) {
106
+ return parseFloat(value);
107
+ });
108
+ }
109
+ }, {
110
+ key: "mount",
111
+ value: function mount() {
112
+ if (!svgSupported) return;
113
+ this.element.addEventListener("change", this.draw.bind(this));
114
+ this.element.dataset["_peity"] = "1";
115
+ this.draw();
116
+ }
117
+ }, {
118
+ key: "unmount",
119
+ value: function unmount() {
120
+ this.element.removeEventListener("change", this.draw);
121
+ }
122
+ }], [{
123
+ key: "register",
124
+ value: function register(type, defaults, grapher) {
125
+ Peity.defaults[type] = defaults;
126
+ Peity.graphers[type] = grapher;
127
+ }
128
+ }]);
129
+
130
+ return Peity;
131
+ }();
132
+
133
+ _defineProperty(Peity, "defaults", {});
134
+
135
+ _defineProperty(Peity, "graphers", {});
136
+
137
+ var renderer$2 = function renderer(peity) {
138
+ if (!peity.options.delimiter) {
139
+ var delimiter = peity.element.innerText.match(/[^0-9\.]/);
140
+ peity.options.delimiter = delimiter ? delimiter[0] : ",";
141
+ }
142
+
143
+ var values = peity.values.map(function (n) {
144
+ return n > 0 ? n : 0;
145
+ });
146
+
147
+ if (peity.options.delimiter == "/") {
148
+ var v1 = values[0];
149
+ var v2 = values[1];
150
+ values = [v1, Math.max(0, v2 - v1)];
151
+ }
152
+
153
+ var i = 0;
154
+ var length = values.length;
155
+ var sum = 0;
156
+
157
+ for (; i < length; i++) {
158
+ sum += values[i];
159
+ }
160
+
161
+ if (!sum) {
162
+ length = 2;
163
+ sum = 1;
164
+ values = [0, 1];
165
+ }
166
+
167
+ var diameter = peity.options.radius * 2;
168
+ var svg = peity.prepare(peity.options.width || diameter, peity.options.height || diameter);
169
+ var width = svg.clientWidth;
170
+ var height = svg.clientHeight;
171
+ var cx = width / 2;
172
+ var cy = height / 2;
173
+ var radius = Math.min(cx, cy);
174
+ var innerRadius = peity.options.innerRadius;
175
+
176
+ if (peity.type == "donut" && !innerRadius) {
177
+ innerRadius = radius * 0.5;
178
+ }
179
+
180
+ var fill = peity.fill();
181
+
182
+ var scale = function scale(value, radius) {
183
+ var radians = value / sum * Math.PI * 2 - Math.PI / 2;
184
+ return [radius * Math.cos(radians) + cx, radius * Math.sin(radians) + cy];
185
+ };
186
+
187
+ var cumulative = 0;
188
+
189
+ for (i = 0; i < length; i++) {
190
+ var value = values[i];
191
+ var portion = value / sum;
192
+ var node = void 0;
193
+ if (portion == 0) continue;
194
+
195
+ if (portion == 1) {
196
+ if (innerRadius) {
197
+ var x2 = cx - 0.01;
198
+ var y1 = cy - radius;
199
+ var y2 = cy - innerRadius;
200
+ node = svgElement("path", {
201
+ d: ["M", cx, y1, "A", radius, radius, 0, 1, 1, x2, y1, "L", x2, y2, "A", innerRadius, innerRadius, 0, 1, 0, cx, y2].join(" "),
202
+ "data-value": value
203
+ });
204
+ } else {
205
+ node = svgElement("circle", {
206
+ cx: cx,
207
+ cy: cy,
208
+ "data-value": value,
209
+ r: radius
210
+ });
211
+ }
212
+ } else {
213
+ var cumulativePlusValue = cumulative + value;
214
+ var d = ["M"].concat(scale(cumulative, radius), "A", radius, radius, 0, portion > 0.5 ? 1 : 0, 1, scale(cumulativePlusValue, radius), "L");
215
+
216
+ if (innerRadius) {
217
+ d = d.concat(scale(cumulativePlusValue, innerRadius), "A", innerRadius, innerRadius, 0, portion > 0.5 ? 1 : 0, 0, scale(cumulative, innerRadius));
218
+ } else {
219
+ d.push(cx, cy);
220
+ }
221
+
222
+ cumulative += value;
223
+ node = svgElement("path", {
224
+ d: d.join(" "),
225
+ "data-value": value
226
+ });
227
+ }
228
+
229
+ node.setAttribute("fill", fill.call(peity, value, i, values));
230
+ svg.append(node);
231
+ }
232
+ };
233
+ var defaults$2 = {
234
+ fill: ["#ff9900", "#fff4dd", "#ffc66e"],
235
+ radius: 8
236
+ };
237
+
238
+ var renderer$1 = function renderer(peity) {
239
+ var values = peity.values;
240
+ var max = Math.max.apply(Math, peity.options.max == undefined ? values : values.concat(peity.options.max));
241
+ var min = Math.min.apply(Math, peity.options.min == undefined ? values : values.concat(peity.options.min));
242
+ var svg = peity.prepare(peity.options.width, peity.options.height);
243
+ var width = svg.clientWidth;
244
+ var height = svg.clientHeight;
245
+ var diff = max - min;
246
+ var padding = peity.options.padding;
247
+ var fill = peity.fill();
248
+
249
+ var xScale = function xScale(input) {
250
+ return input * width / values.length;
251
+ };
252
+
253
+ var yScale = function yScale(input) {
254
+ return height - (diff ? (input - min) / diff * height : 1);
255
+ };
256
+
257
+ for (var i = 0; i < values.length; i++) {
258
+ var x = xScale(i + padding);
259
+ var w = xScale(i + 1 - padding) - x;
260
+ var value = values[i];
261
+ var valueY = yScale(value);
262
+ var y1 = valueY;
263
+ var y2 = valueY;
264
+ var h = void 0;
265
+
266
+ if (!diff) {
267
+ h = 1;
268
+ } else if (value < 0) {
269
+ y1 = yScale(Math.min(max, 0));
270
+ } else {
271
+ y2 = yScale(Math.max(min, 0));
272
+ }
273
+
274
+ h = y2 - y1;
275
+
276
+ if (h == 0) {
277
+ h = 1;
278
+ if (max > 0 && diff) y1--;
279
+ }
280
+
281
+ svg.append(svgElement("rect", {
282
+ "data-value": value,
283
+ fill: fill.call(peity, value, i, values),
284
+ x: x,
285
+ y: y1,
286
+ width: w,
287
+ height: h
288
+ }));
289
+ }
290
+ };
291
+ var defaults$1 = {
292
+ delimiter: ",",
293
+ fill: ["#4D89F9"],
294
+ height: 16,
295
+ min: 0,
296
+ padding: 0.1,
297
+ width: 32
298
+ };
299
+
300
+ var renderer = function renderer(peity) {
301
+ var values = peity.values;
302
+ if (values.length == 1) values.push(values[0]);
303
+ var max = Math.max.apply(Math, peity.options.max == undefined ? values : values.concat(peity.options.max));
304
+ var min = Math.min.apply(Math, peity.options.min == undefined ? values : values.concat(peity.options.min));
305
+ var svg = peity.prepare(peity.options.width, peity.options.height);
306
+ var strokeWidth = peity.options.strokeWidth;
307
+ var width = svg.clientWidth;
308
+ var height = svg.clientHeight - strokeWidth;
309
+ var diff = max - min;
310
+
311
+ var xScale = function xScale(input) {
312
+ return input * (width / (values.length - 1));
313
+ };
314
+
315
+ var yScale = function yScale(input) {
316
+ var y = height;
317
+
318
+ if (diff) {
319
+ y -= (input - min) / diff * height;
320
+ }
321
+
322
+ return y + strokeWidth / 2;
323
+ };
324
+
325
+ var zero = yScale(Math.max(min, 0));
326
+ var coords = [0, zero];
327
+
328
+ for (var i = 0; i < values.length; i++) {
329
+ coords.push(xScale(i), yScale(values[i]));
330
+ }
331
+
332
+ coords.push(width, zero);
333
+
334
+ if (peity.options.fill) {
335
+ svg.append(svgElement("polygon", {
336
+ fill: peity.options.fill,
337
+ points: coords.join(" ")
338
+ }));
339
+ }
340
+
341
+ if (strokeWidth) {
342
+ svg.append(svgElement("polyline", {
343
+ fill: "none",
344
+ points: coords.slice(2, coords.length - 2).join(" "),
345
+ stroke: peity.options.stroke,
346
+ "stroke-width": strokeWidth,
347
+ "stroke-linecap": "square"
348
+ }));
349
+ }
350
+ };
351
+ var defaults = {
352
+ delimiter: ",",
353
+ fill: "#c6d9fd",
354
+ height: 16,
355
+ min: 0,
356
+ stroke: "#4d89f9",
357
+ strokeWidth: 1,
358
+ width: 32
359
+ };
360
+
361
+ Peity.register("pie", defaults$2, renderer$2);
362
+ Peity.register("donut", defaults$2, renderer$2);
363
+ Peity.register("bar", defaults$1, renderer$1);
364
+ Peity.register("line", defaults, renderer);
365
+
366
+ var peity = function peity(element, type, options) {
367
+ var peity = new Peity(element, type, options);
368
+ peity.mount();
369
+ return peity;
370
+ };
371
+
372
+ peity.defaults = Peity.defaults;
373
+ peity.graphers = Peity.graphers;
374
+
375
+ export { peity as default };
376
+
@@ -1,317 +1,385 @@
1
1
  /*!
2
- Peity Vanila JS
2
+ Peity Vanila JS 0.0.5
3
+ Copyright © 2022 RailsJazz
4
+ https://railsjazz.com
3
5
  */
4
6
 
5
- (function (global, factory) {
6
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
7
- typeof define === 'function' && define.amd ? define(factory) :
8
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.peity_vanilla = factory());
9
- })(this, (function () { 'use strict';
10
-
11
- var peity = function peity(element, type, options) {
12
- if (svgSupported) {
13
- var $this = element;
14
- var chart = new Peity($this, type, Object.assign({}, peity.defaults[type], JSON.parse($this.dataset['peity'] || '{}'), options));
15
- $this.addEventListener("change", function () {
16
- chart.draw();
17
- });
18
- $this.dataset['_peity'] = "1";
19
- chart.draw();
20
- return $this;
21
- }
22
- };
23
-
24
- var Peity = function Peity($el, type, opts) {
25
- this.$el = $el;
26
- this.type = type;
27
- this.opts = opts;
28
- };
29
-
30
- var PeityPrototype = Peity.prototype;
31
-
32
- var svgElement = PeityPrototype.svgElement = function (tag, attrs) {
33
- var element = document.createElementNS('http://www.w3.org/2000/svg', tag);
34
-
35
- for (var attr in attrs) {
36
- element.setAttribute(attr, attrs[attr]);
37
- }
38
-
39
- return element;
40
- }; // https://gist.github.com/madrobby/3201472
41
-
42
-
43
- var svgSupported = 'createElementNS' in document && svgElement('svg', {}).createSVGRect();
44
-
45
- PeityPrototype.draw = function () {
46
- var opts = this.opts;
47
- peity.graphers[this.type].call(this, opts);
48
- if (opts.after) opts.after.call(this, opts);
49
- };
50
-
51
- PeityPrototype.isFunction = function (o) {
52
- return null !== o && "function" === typeof o && !!o.apply;
53
- };
54
-
55
- PeityPrototype.fill = function () {
56
- var fill = this.opts.fill;
57
- return PeityPrototype.isFunction(fill) ? fill : function (_, i) {
58
- return fill[i % fill.length];
59
- };
60
- };
61
-
62
- PeityPrototype.prepare = function (width, height) {
63
- if (!this.$svg) {
64
- this.$el.style.display = 'none';
65
- this.$el.after(this.$svg = svgElement('svg', {
66
- "class": "peity"
67
- }));
68
- }
69
-
70
- this.$svg.innerHTML = "";
71
- this.$svg.setAttribute("width", width);
72
- this.$svg.setAttribute("height", height);
73
- return this.$svg;
74
- };
75
-
76
- PeityPrototype.values = function () {
77
- return this.$el.innerText.split(this.opts.delimiter).map(function (value) {
78
- return parseFloat(value);
79
- });
80
- };
81
-
82
- peity.defaults = {};
83
- peity.graphers = {};
84
-
85
- peity.register = function (type, defaults, grapher) {
86
- this.defaults[type] = defaults;
87
- this.graphers[type] = grapher;
88
- };
89
-
90
- peity.register('pie', {
91
- fill: ['#ff9900', '#fff4dd', '#ffc66e'],
92
- radius: 8
93
- }, function (opts) {
94
- if (!opts.delimiter) {
95
- var delimiter = this.$el.innerText.match(/[^0-9\.]/);
96
- opts.delimiter = delimiter ? delimiter[0] : ",";
97
- }
98
-
99
- var values = this.values().map(function (n) {
100
- return n > 0 ? n : 0;
101
- });
102
-
103
- if (opts.delimiter == "/") {
104
- var v1 = values[0];
105
- var v2 = values[1];
106
- values = [v1, Math.max(0, v2 - v1)];
7
+ (function (global, factory) {
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9
+ typeof define === 'function' && define.amd ? define(factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.peity = factory());
11
+ })(this, (function () { 'use strict';
12
+
13
+ function _classCallCheck(instance, Constructor) {
14
+ if (!(instance instanceof Constructor)) {
15
+ throw new TypeError("Cannot call a class as a function");
16
+ }
107
17
  }
108
-
109
- var i = 0;
110
- var length = values.length;
111
- var sum = 0;
112
-
113
- for (; i < length; i++) {
114
- sum += values[i];
18
+
19
+ function _defineProperties(target, props) {
20
+ for (var i = 0; i < props.length; i++) {
21
+ var descriptor = props[i];
22
+ descriptor.enumerable = descriptor.enumerable || false;
23
+ descriptor.configurable = true;
24
+ if ("value" in descriptor) descriptor.writable = true;
25
+ Object.defineProperty(target, descriptor.key, descriptor);
26
+ }
115
27
  }
116
-
117
- if (!sum) {
118
- length = 2;
119
- sum = 1;
120
- values = [0, 1];
28
+
29
+ function _createClass(Constructor, protoProps, staticProps) {
30
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
31
+ if (staticProps) _defineProperties(Constructor, staticProps);
32
+ Object.defineProperty(Constructor, "prototype", {
33
+ writable: false
34
+ });
35
+ return Constructor;
121
36
  }
122
-
123
- var diameter = opts.radius * 2;
124
- var $svg = this.prepare(opts.width || diameter, opts.height || diameter);
125
- var width = $svg.clientWidth,
126
- height = $svg.clientHeight,
127
- cx = width / 2,
128
- cy = height / 2;
129
- var radius = Math.min(cx, cy),
130
- innerRadius = opts.innerRadius;
131
-
132
- if (this.type == 'donut' && !innerRadius) {
133
- innerRadius = radius * 0.5;
37
+
38
+ function _defineProperty(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+
50
+ return obj;
134
51
  }
135
-
136
- var pi = Math.PI;
137
- var fill = this.fill();
138
-
139
- var scale = this.scale = function (value, radius) {
140
- var radians = value / sum * pi * 2 - pi / 2;
141
- return [radius * Math.cos(radians) + cx, radius * Math.sin(radians) + cy];
52
+
53
+ var isFunction = function isFunction(o) {
54
+ return o !== null && typeof o === "function" && !!o.apply;
142
55
  };
143
-
144
- var cumulative = 0;
145
-
146
- for (i = 0; i < length; i++) {
147
- var value = values[i],
148
- portion = value / sum,
149
- $node;
150
- if (portion == 0) continue;
151
-
152
- if (portion == 1) {
153
- if (innerRadius) {
154
- var x2 = cx - 0.01,
155
- y1 = cy - radius,
156
- y2 = cy - innerRadius;
157
- $node = svgElement('path', {
158
- d: ['M', cx, y1, 'A', radius, radius, 0, 1, 1, x2, y1, 'L', x2, y2, 'A', innerRadius, innerRadius, 0, 1, 0, cx, y2].join(' '),
159
- 'data-value': value
56
+ var svgElement = function svgElement(tag, attrs) {
57
+ var element = document.createElementNS("http://www.w3.org/2000/svg", tag);
58
+
59
+ for (var attr in attrs) {
60
+ element.setAttribute(attr, attrs[attr]);
61
+ }
62
+
63
+ return element;
64
+ };
65
+ var svgSupported = "createElementNS" in document && svgElement("svg", {}).createSVGRect();
66
+
67
+ var Peity = /*#__PURE__*/function () {
68
+ function Peity(element, type) {
69
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
70
+
71
+ _classCallCheck(this, Peity);
72
+
73
+ this.element = element;
74
+ this.type = type;
75
+ this.options = Object.assign({}, Peity.defaults[type], JSON.parse(element.dataset["peity"] || "{}"), options);
76
+ }
77
+
78
+ _createClass(Peity, [{
79
+ key: "draw",
80
+ value: function draw() {
81
+ var options = this.options;
82
+ Peity.graphers[this.type](this);
83
+ if (isFunction(options.after)) options.after.call(this, options);
84
+ }
85
+ }, {
86
+ key: "fill",
87
+ value: function fill() {
88
+ var fill = this.options.fill;
89
+ return isFunction(fill) ? fill : function (_, i) {
90
+ return fill[i % fill.length];
91
+ };
92
+ }
93
+ }, {
94
+ key: "prepare",
95
+ value: function prepare(width, height) {
96
+ if (!this.svg) {
97
+ this.element.style.display = "none";
98
+ this.element.after(this.svg = svgElement("svg", {
99
+ class: "peity"
100
+ }));
101
+ }
102
+
103
+ this.svg.innerHTML = "";
104
+ this.svg.setAttribute("width", width);
105
+ this.svg.setAttribute("height", height);
106
+ return this.svg;
107
+ }
108
+ }, {
109
+ key: "values",
110
+ get: function get() {
111
+ return this.element.innerText.split(this.options.delimiter).map(function (value) {
112
+ return parseFloat(value);
160
113
  });
114
+ }
115
+ }, {
116
+ key: "mount",
117
+ value: function mount() {
118
+ if (!svgSupported) return;
119
+ this.element.addEventListener("change", this.draw.bind(this));
120
+ this.element.dataset["_peity"] = "1";
121
+ this.draw();
122
+ }
123
+ }, {
124
+ key: "unmount",
125
+ value: function unmount() {
126
+ this.element.removeEventListener("change", this.draw);
127
+ }
128
+ }], [{
129
+ key: "register",
130
+ value: function register(type, defaults, grapher) {
131
+ Peity.defaults[type] = defaults;
132
+ Peity.graphers[type] = grapher;
133
+ }
134
+ }]);
135
+
136
+ return Peity;
137
+ }();
138
+
139
+ _defineProperty(Peity, "defaults", {});
140
+
141
+ _defineProperty(Peity, "graphers", {});
142
+
143
+ var renderer$2 = function renderer(peity) {
144
+ if (!peity.options.delimiter) {
145
+ var delimiter = peity.element.innerText.match(/[^0-9\.]/);
146
+ peity.options.delimiter = delimiter ? delimiter[0] : ",";
147
+ }
148
+
149
+ var values = peity.values.map(function (n) {
150
+ return n > 0 ? n : 0;
151
+ });
152
+
153
+ if (peity.options.delimiter == "/") {
154
+ var v1 = values[0];
155
+ var v2 = values[1];
156
+ values = [v1, Math.max(0, v2 - v1)];
157
+ }
158
+
159
+ var i = 0;
160
+ var length = values.length;
161
+ var sum = 0;
162
+
163
+ for (; i < length; i++) {
164
+ sum += values[i];
165
+ }
166
+
167
+ if (!sum) {
168
+ length = 2;
169
+ sum = 1;
170
+ values = [0, 1];
171
+ }
172
+
173
+ var diameter = peity.options.radius * 2;
174
+ var svg = peity.prepare(peity.options.width || diameter, peity.options.height || diameter);
175
+ var width = svg.clientWidth;
176
+ var height = svg.clientHeight;
177
+ var cx = width / 2;
178
+ var cy = height / 2;
179
+ var radius = Math.min(cx, cy);
180
+ var innerRadius = peity.options.innerRadius;
181
+
182
+ if (peity.type == "donut" && !innerRadius) {
183
+ innerRadius = radius * 0.5;
184
+ }
185
+
186
+ var fill = peity.fill();
187
+
188
+ var scale = function scale(value, radius) {
189
+ var radians = value / sum * Math.PI * 2 - Math.PI / 2;
190
+ return [radius * Math.cos(radians) + cx, radius * Math.sin(radians) + cy];
191
+ };
192
+
193
+ var cumulative = 0;
194
+
195
+ for (i = 0; i < length; i++) {
196
+ var value = values[i];
197
+ var portion = value / sum;
198
+ var node = void 0;
199
+ if (portion == 0) continue;
200
+
201
+ if (portion == 1) {
202
+ if (innerRadius) {
203
+ var x2 = cx - 0.01;
204
+ var y1 = cy - radius;
205
+ var y2 = cy - innerRadius;
206
+ node = svgElement("path", {
207
+ d: ["M", cx, y1, "A", radius, radius, 0, 1, 1, x2, y1, "L", x2, y2, "A", innerRadius, innerRadius, 0, 1, 0, cx, y2].join(" "),
208
+ "data-value": value
209
+ });
210
+ } else {
211
+ node = svgElement("circle", {
212
+ cx: cx,
213
+ cy: cy,
214
+ "data-value": value,
215
+ r: radius
216
+ });
217
+ }
161
218
  } else {
162
- $node = svgElement('circle', {
163
- cx: cx,
164
- cy: cy,
165
- 'data-value': value,
166
- r: radius
219
+ var cumulativePlusValue = cumulative + value;
220
+ var d = ["M"].concat(scale(cumulative, radius), "A", radius, radius, 0, portion > 0.5 ? 1 : 0, 1, scale(cumulativePlusValue, radius), "L");
221
+
222
+ if (innerRadius) {
223
+ d = d.concat(scale(cumulativePlusValue, innerRadius), "A", innerRadius, innerRadius, 0, portion > 0.5 ? 1 : 0, 0, scale(cumulative, innerRadius));
224
+ } else {
225
+ d.push(cx, cy);
226
+ }
227
+
228
+ cumulative += value;
229
+ node = svgElement("path", {
230
+ d: d.join(" "),
231
+ "data-value": value
167
232
  });
168
233
  }
169
- } else {
170
- var cumulativePlusValue = cumulative + value;
171
- var d = ['M'].concat(scale(cumulative, radius), 'A', radius, radius, 0, portion > 0.5 ? 1 : 0, 1, scale(cumulativePlusValue, radius), 'L');
172
-
173
- if (innerRadius) {
174
- d = d.concat(scale(cumulativePlusValue, innerRadius), 'A', innerRadius, innerRadius, 0, portion > 0.5 ? 1 : 0, 0, scale(cumulative, innerRadius));
234
+
235
+ node.setAttribute("fill", fill.call(peity, value, i, values));
236
+ svg.append(node);
237
+ }
238
+ };
239
+ var defaults$2 = {
240
+ fill: ["#ff9900", "#fff4dd", "#ffc66e"],
241
+ radius: 8
242
+ };
243
+
244
+ var renderer$1 = function renderer(peity) {
245
+ var values = peity.values;
246
+ var max = Math.max.apply(Math, peity.options.max == undefined ? values : values.concat(peity.options.max));
247
+ var min = Math.min.apply(Math, peity.options.min == undefined ? values : values.concat(peity.options.min));
248
+ var svg = peity.prepare(peity.options.width, peity.options.height);
249
+ var width = svg.clientWidth;
250
+ var height = svg.clientHeight;
251
+ var diff = max - min;
252
+ var padding = peity.options.padding;
253
+ var fill = peity.fill();
254
+
255
+ var xScale = function xScale(input) {
256
+ return input * width / values.length;
257
+ };
258
+
259
+ var yScale = function yScale(input) {
260
+ return height - (diff ? (input - min) / diff * height : 1);
261
+ };
262
+
263
+ for (var i = 0; i < values.length; i++) {
264
+ var x = xScale(i + padding);
265
+ var w = xScale(i + 1 - padding) - x;
266
+ var value = values[i];
267
+ var valueY = yScale(value);
268
+ var y1 = valueY;
269
+ var y2 = valueY;
270
+ var h = void 0;
271
+
272
+ if (!diff) {
273
+ h = 1;
274
+ } else if (value < 0) {
275
+ y1 = yScale(Math.min(max, 0));
175
276
  } else {
176
- d.push(cx, cy);
277
+ y2 = yScale(Math.max(min, 0));
177
278
  }
178
-
179
- cumulative += value;
180
- $node = svgElement('path', {
181
- d: d.join(" "),
182
- 'data-value': value
183
- });
279
+
280
+ h = y2 - y1;
281
+
282
+ if (h == 0) {
283
+ h = 1;
284
+ if (max > 0 && diff) y1--;
285
+ }
286
+
287
+ svg.append(svgElement("rect", {
288
+ "data-value": value,
289
+ fill: fill.call(peity, value, i, values),
290
+ x: x,
291
+ y: y1,
292
+ width: w,
293
+ height: h
294
+ }));
184
295
  }
185
-
186
- $node.setAttribute('fill', fill.call(this, value, i, values));
187
- $svg.append($node);
188
- }
189
- });
190
- peity.register('donut', Object.assign(true, {}, peity.defaults.pie), function (opts) {
191
- peity.graphers.pie.call(this, opts);
192
- });
193
- peity.register('bar', {
194
- delimiter: ",",
195
- fill: ["#4D89F9"],
196
- height: 16,
197
- min: 0,
198
- padding: 0.1,
199
- width: 32
200
- }, function (opts) {
201
- var values = this.values(),
202
- max = Math.max.apply(Math, opts.max == undefined ? values : values.concat(opts.max)),
203
- min = Math.min.apply(Math, opts.min == undefined ? values : values.concat(opts.min));
204
- var $svg = this.prepare(opts.width, opts.height),
205
- width = $svg.clientWidth,
206
- height = $svg.clientHeight,
207
- diff = max - min,
208
- padding = opts.padding,
209
- fill = this.fill();
210
-
211
- var xScale = this.x = function (input) {
212
- return input * width / values.length;
213
296
  };
214
-
215
- var yScale = this.y = function (input) {
216
- return height - (diff ? (input - min) / diff * height : 1);
297
+ var defaults$1 = {
298
+ delimiter: ",",
299
+ fill: ["#4D89F9"],
300
+ height: 16,
301
+ min: 0,
302
+ padding: 0.1,
303
+ width: 32
217
304
  };
218
-
219
- for (var i = 0; i < values.length; i++) {
220
- var x = xScale(i + padding),
221
- w = xScale(i + 1 - padding) - x,
222
- value = values[i],
223
- valueY = yScale(value),
224
- y1 = valueY,
225
- y2 = valueY,
226
- h;
227
-
228
- if (!diff) {
229
- h = 1;
230
- } else if (value < 0) {
231
- y1 = yScale(Math.min(max, 0));
232
- } else {
233
- y2 = yScale(Math.max(min, 0));
305
+
306
+ var renderer = function renderer(peity) {
307
+ var values = peity.values;
308
+ if (values.length == 1) values.push(values[0]);
309
+ var max = Math.max.apply(Math, peity.options.max == undefined ? values : values.concat(peity.options.max));
310
+ var min = Math.min.apply(Math, peity.options.min == undefined ? values : values.concat(peity.options.min));
311
+ var svg = peity.prepare(peity.options.width, peity.options.height);
312
+ var strokeWidth = peity.options.strokeWidth;
313
+ var width = svg.clientWidth;
314
+ var height = svg.clientHeight - strokeWidth;
315
+ var diff = max - min;
316
+
317
+ var xScale = function xScale(input) {
318
+ return input * (width / (values.length - 1));
319
+ };
320
+
321
+ var yScale = function yScale(input) {
322
+ var y = height;
323
+
324
+ if (diff) {
325
+ y -= (input - min) / diff * height;
326
+ }
327
+
328
+ return y + strokeWidth / 2;
329
+ };
330
+
331
+ var zero = yScale(Math.max(min, 0));
332
+ var coords = [0, zero];
333
+
334
+ for (var i = 0; i < values.length; i++) {
335
+ coords.push(xScale(i), yScale(values[i]));
234
336
  }
235
-
236
- h = y2 - y1;
237
-
238
- if (h == 0) {
239
- h = 1;
240
- if (max > 0 && diff) y1--;
337
+
338
+ coords.push(width, zero);
339
+
340
+ if (peity.options.fill) {
341
+ svg.append(svgElement("polygon", {
342
+ fill: peity.options.fill,
343
+ points: coords.join(" ")
344
+ }));
241
345
  }
242
-
243
- $svg.append(svgElement('rect', {
244
- 'data-value': value,
245
- fill: fill.call(this, value, i, values),
246
- x: x,
247
- y: y1,
248
- width: w,
249
- height: h
250
- }));
251
- }
252
- });
253
- peity.register("line", {
254
- delimiter: ",",
255
- fill: "#c6d9fd",
256
- height: 16,
257
- min: 0,
258
- stroke: "#4d89f9",
259
- strokeWidth: 1,
260
- width: 32
261
- }, function (opts) {
262
- var values = this.values();
263
- if (values.length == 1) values.push(values[0]);
264
- var max = Math.max.apply(Math, opts.max == undefined ? values : values.concat(opts.max)),
265
- min = Math.min.apply(Math, opts.min == undefined ? values : values.concat(opts.min));
266
- var $svg = this.prepare(opts.width, opts.height),
267
- strokeWidth = opts.strokeWidth,
268
- width = $svg.clientWidth,
269
- height = $svg.clientHeight - strokeWidth,
270
- diff = max - min;
271
-
272
- var xScale = this.x = function (input) {
273
- return input * (width / (values.length - 1));
274
- };
275
-
276
- var yScale = this.y = function (input) {
277
- var y = height;
278
-
279
- if (diff) {
280
- y -= (input - min) / diff * height;
346
+
347
+ if (strokeWidth) {
348
+ svg.append(svgElement("polyline", {
349
+ fill: "none",
350
+ points: coords.slice(2, coords.length - 2).join(" "),
351
+ stroke: peity.options.stroke,
352
+ "stroke-width": strokeWidth,
353
+ "stroke-linecap": "square"
354
+ }));
281
355
  }
282
-
283
- return y + strokeWidth / 2;
284
356
  };
285
-
286
- var zero = yScale(Math.max(min, 0)),
287
- coords = [0, zero];
288
-
289
- for (var i = 0; i < values.length; i++) {
290
- coords.push(xScale(i), yScale(values[i]));
291
- }
292
-
293
- coords.push(width, zero);
294
-
295
- if (opts.fill) {
296
- $svg.append(svgElement('polygon', {
297
- fill: opts.fill,
298
- points: coords.join(' ')
299
- }));
300
- }
301
-
302
- if (strokeWidth) {
303
- $svg.append(svgElement('polyline', {
304
- fill: 'none',
305
- points: coords.slice(2, coords.length - 2).join(' '),
306
- stroke: opts.stroke,
307
- 'stroke-width': strokeWidth,
308
- 'stroke-linecap': 'square'
309
- }));
310
- }
311
- });
312
- var index = window.peity = peity;
313
-
314
- return index;
315
-
316
- }));
317
- //# sourceMappingURL=peity_vanilla.js.map
357
+ var defaults = {
358
+ delimiter: ",",
359
+ fill: "#c6d9fd",
360
+ height: 16,
361
+ min: 0,
362
+ stroke: "#4d89f9",
363
+ strokeWidth: 1,
364
+ width: 32
365
+ };
366
+
367
+ Peity.register("pie", defaults$2, renderer$2);
368
+ Peity.register("donut", defaults$2, renderer$2);
369
+ Peity.register("bar", defaults$1, renderer$1);
370
+ Peity.register("line", defaults, renderer);
371
+
372
+ var peity = function peity(element, type, options) {
373
+ var peity = new Peity(element, type, options);
374
+ peity.mount();
375
+ return peity;
376
+ };
377
+
378
+ peity.defaults = Peity.defaults;
379
+ peity.graphers = Peity.graphers;
380
+
381
+ return peity;
382
+
383
+ }));
384
+ //# sourceMappingURL=peity_vanilla.js.map
385
+
@@ -1 +1 @@
1
- {"version":3,"file":"peity_vanilla.js","sources":["../src/index.js"],"sourcesContent":["\"use strict\";\r\n\r\nvar peity = function(element, type, options) {\r\n if (svgSupported) {\r\n var $this = element\r\n\r\n var chart = new Peity(\r\n $this,\r\n type,\r\n Object.assign({},\r\n peity.defaults[type],\r\n JSON.parse($this.dataset['peity'] || '{}'),\r\n options)\r\n )\r\n\r\n $this.addEventListener(\"change\", function() { chart.draw() })\r\n $this.dataset['_peity'] = \"1\"\r\n\r\n chart.draw()\r\n return $this;\r\n }\r\n};\r\n\r\nvar Peity = function($el, type, opts) {\r\n this.$el = $el\r\n this.type = type\r\n this.opts = opts\r\n}\r\n\r\nvar PeityPrototype = Peity.prototype\r\n\r\nvar svgElement = PeityPrototype.svgElement = function(tag, attrs) {\r\n var element = document.createElementNS('http://www.w3.org/2000/svg', tag)\r\n for(var attr in attrs) {\r\n element.setAttribute(attr, attrs[attr])\r\n }\r\n return element;\r\n}\r\n\r\n// https://gist.github.com/madrobby/3201472\r\nvar svgSupported = 'createElementNS' in document && svgElement('svg', {}).createSVGRect()\r\n\r\nPeityPrototype.draw = function() {\r\n var opts = this.opts\r\n peity.graphers[this.type].call(this, opts)\r\n if (opts.after) opts.after.call(this, opts)\r\n}\r\n\r\nPeityPrototype.isFunction = function(o) { return null !== o && \"function\" === typeof o && !!o.apply; }\r\n\r\nPeityPrototype.fill = function() {\r\n var fill = this.opts.fill\r\n\r\n return PeityPrototype.isFunction(fill)\r\n ? fill\r\n : function(_, i) { return fill[i % fill.length] }\r\n}\r\n\r\nPeityPrototype.prepare = function(width, height) {\r\n if (!this.$svg) {\r\n this.$el.style.display = 'none'\r\n this.$el.after(\r\n this.$svg = svgElement('svg', {\r\n \"class\": \"peity\"\r\n })\r\n )\r\n }\r\n\r\n this.$svg.innerHTML = \"\";\r\n this.$svg.setAttribute(\"width\", width)\r\n this.$svg.setAttribute(\"height\", height)\r\n\r\n return this.$svg;\r\n}\r\n\r\nPeityPrototype.values = function() {\r\n return this.$el.innerText.split(this.opts.delimiter).map(function(value) {\r\n return parseFloat(value)\r\n })\r\n}\r\n\r\npeity.defaults = {}\r\npeity.graphers = {}\r\n\r\npeity.register = function(type, defaults, grapher) {\r\n this.defaults[type] = defaults\r\n this.graphers[type] = grapher\r\n}\r\n\r\npeity.register(\r\n 'pie',\r\n {\r\n fill: ['#ff9900', '#fff4dd', '#ffc66e'],\r\n radius: 8\r\n },\r\n function(opts) {\r\n if (!opts.delimiter) {\r\n var delimiter = this.$el.innerText.match(/[^0-9\\.]/)\r\n opts.delimiter = delimiter ? delimiter[0] : \",\"\r\n }\r\n\r\n var values = this.values().map(function(n) {\r\n return n > 0 ? n : 0\r\n });\r\n\r\n if (opts.delimiter == \"/\") {\r\n var v1 = values[0]\r\n var v2 = values[1]\r\n values = [v1, Math.max(0, v2 - v1)]\r\n }\r\n\r\n var i = 0\r\n var length = values.length\r\n var sum = 0\r\n\r\n for (; i < length; i++) {\r\n sum += values[i]\r\n }\r\n\r\n if (!sum) {\r\n length = 2\r\n sum = 1\r\n values = [0, 1]\r\n }\r\n\r\n var diameter = opts.radius * 2\r\n\r\n var $svg = this.prepare(\r\n opts.width || diameter,\r\n opts.height || diameter\r\n )\r\n\r\n var width = $svg.clientWidth\r\n , height = $svg.clientHeight\r\n , cx = width / 2\r\n , cy = height / 2\r\n\r\n var radius = Math.min(cx, cy)\r\n , innerRadius = opts.innerRadius\r\n\r\n if (this.type == 'donut' && !innerRadius) {\r\n innerRadius = radius * 0.5\r\n }\r\n\r\n var pi = Math.PI\r\n var fill = this.fill()\r\n\r\n var scale = this.scale = function(value, radius) {\r\n var radians = value / sum * pi * 2 - pi / 2\r\n\r\n return [\r\n radius * Math.cos(radians) + cx,\r\n radius * Math.sin(radians) + cy\r\n ]\r\n }\r\n\r\n var cumulative = 0\r\n\r\n for (i = 0; i < length; i++) {\r\n var value = values[i]\r\n , portion = value / sum\r\n , $node\r\n\r\n if (portion == 0) continue\r\n\r\n if (portion == 1) {\r\n if (innerRadius) {\r\n var x2 = cx - 0.01\r\n , y1 = cy - radius\r\n , y2 = cy - innerRadius\r\n\r\n $node = svgElement('path', {\r\n d: [\r\n 'M', cx, y1,\r\n 'A', radius, radius, 0, 1, 1, x2, y1,\r\n 'L', x2, y2,\r\n 'A', innerRadius, innerRadius, 0, 1, 0, cx, y2\r\n ].join(' '),\r\n 'data-value': value,\r\n })\r\n } else {\r\n $node = svgElement('circle', {\r\n cx: cx,\r\n cy: cy,\r\n 'data-value': value,\r\n r: radius\r\n })\r\n }\r\n } else {\r\n var cumulativePlusValue = cumulative + value\r\n\r\n var d = ['M'].concat(\r\n scale(cumulative, radius),\r\n 'A', radius, radius, 0, portion > 0.5 ? 1 : 0, 1,\r\n scale(cumulativePlusValue, radius),\r\n 'L'\r\n )\r\n\r\n if (innerRadius) {\r\n d = d.concat(\r\n scale(cumulativePlusValue, innerRadius),\r\n 'A', innerRadius, innerRadius, 0, portion > 0.5 ? 1 : 0, 0,\r\n scale(cumulative, innerRadius)\r\n )\r\n } else {\r\n d.push(cx, cy)\r\n }\r\n\r\n cumulative += value\r\n\r\n $node = svgElement('path', {\r\n d: d.join(\" \"),\r\n 'data-value': value,\r\n })\r\n }\r\n\r\n $node.setAttribute('fill', fill.call(this, value, i, values))\r\n\r\n $svg.append($node)\r\n }\r\n }\r\n)\r\n\r\npeity.register(\r\n 'donut',\r\n Object.assign(true, {}, peity.defaults.pie),\r\n function(opts) {\r\n peity.graphers.pie.call(this, opts)\r\n }\r\n)\r\n\r\npeity.register(\r\n 'bar',\r\n {\r\n delimiter: \",\",\r\n fill: [\"#4D89F9\"],\r\n height: 16,\r\n min: 0,\r\n padding: 0.1,\r\n width: 32\r\n },\r\n function(opts) {\r\n var values = this.values()\r\n , max = Math.max.apply(Math, opts.max == undefined ? values : values.concat(opts.max))\r\n , min = Math.min.apply(Math, opts.min == undefined ? values : values.concat(opts.min))\r\n\r\n var $svg = this.prepare(opts.width, opts.height)\r\n , width = $svg.clientWidth\r\n , height = $svg.clientHeight\r\n , diff = max - min\r\n , padding = opts.padding\r\n , fill = this.fill()\r\n\r\n var xScale = this.x = function(input) {\r\n return input * width / values.length\r\n }\r\n\r\n var yScale = this.y = function(input) {\r\n return height - (\r\n diff\r\n ? ((input - min) / diff) * height\r\n : 1\r\n )\r\n }\r\n\r\n for (var i = 0; i < values.length; i++) {\r\n var x = xScale(i + padding)\r\n , w = xScale(i + 1 - padding) - x\r\n , value = values[i]\r\n , valueY = yScale(value)\r\n , y1 = valueY\r\n , y2 = valueY\r\n , h\r\n\r\n if (!diff) {\r\n h = 1\r\n } else if (value < 0) {\r\n y1 = yScale(Math.min(max, 0))\r\n } else {\r\n y2 = yScale(Math.max(min, 0))\r\n }\r\n\r\n h = y2 - y1\r\n\r\n if (h == 0) {\r\n h = 1\r\n if (max > 0 && diff) y1--\r\n }\r\n\r\n $svg.append(\r\n svgElement('rect', {\r\n 'data-value': value,\r\n fill: fill.call(this, value, i, values),\r\n x: x,\r\n y: y1,\r\n width: w,\r\n height: h\r\n })\r\n )\r\n }\r\n }\r\n);\r\n\r\npeity.register(\r\n \"line\",\r\n {\r\n delimiter: \",\",\r\n fill: \"#c6d9fd\",\r\n height: 16,\r\n min: 0,\r\n stroke: \"#4d89f9\",\r\n strokeWidth: 1,\r\n width: 32\r\n },\r\n function(opts) {\r\n var values = this.values()\r\n if (values.length == 1) values.push(values[0])\r\n var max = Math.max.apply(Math, opts.max == undefined ? values : values.concat(opts.max))\r\n , min = Math.min.apply(Math, opts.min == undefined ? values : values.concat(opts.min))\r\n\r\n var $svg = this.prepare(opts.width, opts.height)\r\n , strokeWidth = opts.strokeWidth\r\n , width = $svg.clientWidth\r\n , height = $svg.clientHeight - strokeWidth\r\n , diff = max - min\r\n\r\n var xScale = this.x = function(input) {\r\n return input * (width / (values.length - 1))\r\n }\r\n\r\n var yScale = this.y = function(input) {\r\n var y = height\r\n\r\n if (diff) {\r\n y -= ((input - min) / diff) * height\r\n }\r\n\r\n return y + strokeWidth / 2\r\n }\r\n\r\n var zero = yScale(Math.max(min, 0))\r\n , coords = [0, zero]\r\n\r\n for (var i = 0; i < values.length; i++) {\r\n coords.push(\r\n xScale(i),\r\n yScale(values[i])\r\n )\r\n }\r\n\r\n coords.push(width, zero)\r\n\r\n if (opts.fill) {\r\n $svg.append(\r\n svgElement('polygon', {\r\n fill: opts.fill,\r\n points: coords.join(' ')\r\n })\r\n )\r\n }\r\n\r\n if (strokeWidth) {\r\n $svg.append(\r\n svgElement('polyline', {\r\n fill: 'none',\r\n points: coords.slice(2, coords.length - 2).join(' '),\r\n stroke: opts.stroke,\r\n 'stroke-width': strokeWidth,\r\n 'stroke-linecap': 'square'\r\n })\r\n )\r\n }\r\n }\r\n);\r\n\r\nexport default window.peity = peity;"],"names":["peity","element","type","options","svgSupported","$this","chart","Peity","Object","assign","defaults","JSON","parse","dataset","addEventListener","draw","$el","opts","PeityPrototype","prototype","svgElement","tag","attrs","document","createElementNS","attr","setAttribute","createSVGRect","graphers","call","after","isFunction","o","apply","fill","_","i","length","prepare","width","height","$svg","style","display","innerHTML","values","innerText","split","delimiter","map","value","parseFloat","register","grapher","radius","match","n","v1","v2","Math","max","sum","diameter","clientWidth","clientHeight","cx","cy","min","innerRadius","pi","PI","scale","radians","cos","sin","cumulative","portion","$node","x2","y1","y2","d","join","r","cumulativePlusValue","concat","push","append","pie","padding","undefined","diff","xScale","x","input","yScale","y","w","valueY","h","stroke","strokeWidth","zero","coords","points","slice","window"],"mappings":";;;;;;;;;;EAEA,IAAIA,KAAK,G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;QAKrB,gBAAkB,EAAA,QAAA;EALG,KAAb,CADZ,CAAA,CAAA;EASD,GAAA;EACF,CArEH,CAAA,CAAA;AAwEA,cAAeK,MAAM,CAAC1G,KAAP,GAAeA,KAA9B;;;;;;;;"}
1
+ {"version":3,"file":"peity_vanilla.js","sources":["../src/utils.js","../src/peity.js","../src/renderers/pie.js","../src/renderers/bar.js","../src/renderers/line.js","../src/index.js"],"sourcesContent":["export const isFunction = (o) =>\n o !== null && typeof o === \"function\" && !!o.apply;\n\nexport const svgElement = (tag, attrs) => {\n const element = document.createElementNS(\"http://www.w3.org/2000/svg\", tag);\n for (var attr in attrs) {\n element.setAttribute(attr, attrs[attr]);\n }\n return element;\n};\n\nexport const svgSupported =\n \"createElementNS\" in document && svgElement(\"svg\", {}).createSVGRect();\n","import { isFunction, svgElement, svgSupported } from \"./utils\";\n\nclass Peity {\n static defaults = {};\n static graphers = {};\n\n constructor(element, type, options = {}) {\n this.element = element;\n this.type = type;\n this.options = Object.assign(\n {},\n Peity.defaults[type],\n JSON.parse(element.dataset[\"peity\"] || \"{}\"),\n options\n );\n }\n\n draw() {\n const options = this.options;\n Peity.graphers[this.type](this);\n if (isFunction(options.after)) options.after.call(this, options);\n }\n\n fill() {\n var fill = this.options.fill;\n\n return isFunction(fill)\n ? fill\n : function (_, i) {\n return fill[i % fill.length];\n };\n }\n\n prepare(width, height) {\n if (!this.svg) {\n this.element.style.display = \"none\";\n this.element.after(\n (this.svg = svgElement(\"svg\", {\n class: \"peity\",\n }))\n );\n }\n\n this.svg.innerHTML = \"\";\n this.svg.setAttribute(\"width\", width);\n this.svg.setAttribute(\"height\", height);\n\n return this.svg;\n }\n\n get values() {\n return this.element.innerText\n .split(this.options.delimiter)\n .map((value) => parseFloat(value));\n }\n\n mount() {\n if (!svgSupported) return;\n\n this.element.addEventListener(\"change\", this.draw.bind(this));\n this.element.dataset[\"_peity\"] = \"1\";\n\n this.draw();\n }\n\n unmount() {\n this.element.removeEventListener(\"change\", this.draw);\n }\n\n static register(type, defaults, grapher) {\n Peity.defaults[type] = defaults;\n Peity.graphers[type] = grapher;\n }\n}\n\nexport default Peity;\n","import { svgElement } from \"../utils\";\n\nexport const renderer = (peity) => {\n if (!peity.options.delimiter) {\n const delimiter = peity.element.innerText.match(/[^0-9\\.]/);\n peity.options.delimiter = delimiter ? delimiter[0] : \",\";\n }\n\n let values = peity.values.map((n) => (n > 0 ? n : 0));\n\n if (peity.options.delimiter == \"/\") {\n let v1 = values[0];\n let v2 = values[1];\n values = [v1, Math.max(0, v2 - v1)];\n }\n\n let i = 0;\n let length = values.length;\n let sum = 0;\n\n for (; i < length; i++) {\n sum += values[i];\n }\n\n if (!sum) {\n length = 2;\n sum = 1;\n values = [0, 1];\n }\n\n let diameter = peity.options.radius * 2;\n\n const svg = peity.prepare(\n peity.options.width || diameter,\n peity.options.height || diameter\n );\n\n const width = svg.clientWidth;\n const height = svg.clientHeight;\n const cx = width / 2;\n const cy = height / 2;\n\n const radius = Math.min(cx, cy);\n let innerRadius = peity.options.innerRadius;\n\n if (peity.type == \"donut\" && !innerRadius) {\n innerRadius = radius * 0.5;\n }\n\n const fill = peity.fill();\n\n const scale = (value, radius) => {\n const radians = (value / sum) * Math.PI * 2 - Math.PI / 2;\n\n return [radius * Math.cos(radians) + cx, radius * Math.sin(radians) + cy];\n };\n\n let cumulative = 0;\n\n for (i = 0; i < length; i++) {\n const value = values[i];\n const portion = value / sum;\n let node;\n\n if (portion == 0) continue;\n\n if (portion == 1) {\n if (innerRadius) {\n const x2 = cx - 0.01;\n const y1 = cy - radius;\n const y2 = cy - innerRadius;\n\n node = svgElement(\"path\", {\n d: [\n \"M\",\n cx,\n y1,\n \"A\",\n radius,\n radius,\n 0,\n 1,\n 1,\n x2,\n y1,\n \"L\",\n x2,\n y2,\n \"A\",\n innerRadius,\n innerRadius,\n 0,\n 1,\n 0,\n cx,\n y2,\n ].join(\" \"),\n \"data-value\": value,\n });\n } else {\n node = svgElement(\"circle\", {\n cx: cx,\n cy: cy,\n \"data-value\": value,\n r: radius,\n });\n }\n } else {\n const cumulativePlusValue = cumulative + value;\n\n let d = [\"M\"].concat(\n scale(cumulative, radius),\n \"A\",\n radius,\n radius,\n 0,\n portion > 0.5 ? 1 : 0,\n 1,\n scale(cumulativePlusValue, radius),\n \"L\"\n );\n\n if (innerRadius) {\n d = d.concat(\n scale(cumulativePlusValue, innerRadius),\n \"A\",\n innerRadius,\n innerRadius,\n 0,\n portion > 0.5 ? 1 : 0,\n 0,\n scale(cumulative, innerRadius)\n );\n } else {\n d.push(cx, cy);\n }\n\n cumulative += value;\n\n node = svgElement(\"path\", {\n d: d.join(\" \"),\n \"data-value\": value,\n });\n }\n\n node.setAttribute(\"fill\", fill.call(peity, value, i, values));\n\n svg.append(node);\n }\n};\n\nexport const defaults = {\n fill: [\"#ff9900\", \"#fff4dd\", \"#ffc66e\"],\n radius: 8,\n};\n","import { svgElement } from \"../utils\";\n\nexport const renderer = (peity) => {\n const values = peity.values;\n const max = Math.max.apply(\n Math,\n peity.options.max == undefined ? values : values.concat(peity.options.max)\n );\n const min = Math.min.apply(\n Math,\n peity.options.min == undefined ? values : values.concat(peity.options.min)\n );\n\n const svg = peity.prepare(peity.options.width, peity.options.height);\n const width = svg.clientWidth;\n const height = svg.clientHeight;\n const diff = max - min;\n const padding = peity.options.padding;\n const fill = peity.fill();\n\n const xScale = (input) => {\n return (input * width) / values.length;\n };\n\n const yScale = (input) => {\n return height - (diff ? ((input - min) / diff) * height : 1);\n };\n\n for (var i = 0; i < values.length; i++) {\n let x = xScale(i + padding);\n let w = xScale(i + 1 - padding) - x;\n let value = values[i];\n let valueY = yScale(value);\n let y1 = valueY;\n let y2 = valueY;\n let h;\n\n if (!diff) {\n h = 1;\n } else if (value < 0) {\n y1 = yScale(Math.min(max, 0));\n } else {\n y2 = yScale(Math.max(min, 0));\n }\n\n h = y2 - y1;\n\n if (h == 0) {\n h = 1;\n if (max > 0 && diff) y1--;\n }\n\n svg.append(\n svgElement(\"rect\", {\n \"data-value\": value,\n fill: fill.call(peity, value, i, values),\n x: x,\n y: y1,\n width: w,\n height: h,\n })\n );\n }\n};\n\nexport const defaults = {\n delimiter: \",\",\n fill: [\"#4D89F9\"],\n height: 16,\n min: 0,\n padding: 0.1,\n width: 32,\n};\n","import { svgElement } from \"../utils\";\n\nexport const renderer = (peity) => {\n const values = peity.values;\n if (values.length == 1) values.push(values[0]);\n const max = Math.max.apply(\n Math,\n peity.options.max == undefined ? values : values.concat(peity.options.max)\n );\n const min = Math.min.apply(\n Math,\n peity.options.min == undefined ? values : values.concat(peity.options.min)\n );\n\n const svg = peity.prepare(peity.options.width, peity.options.height);\n const strokeWidth = peity.options.strokeWidth;\n const width = svg.clientWidth;\n const height = svg.clientHeight - strokeWidth;\n const diff = max - min;\n\n const xScale = (input) => {\n return input * (width / (values.length - 1));\n };\n\n const yScale = (input) => {\n let y = height;\n\n if (diff) {\n y -= ((input - min) / diff) * height;\n }\n\n return y + strokeWidth / 2;\n };\n\n let zero = yScale(Math.max(min, 0));\n let coords = [0, zero];\n\n for (var i = 0; i < values.length; i++) {\n coords.push(xScale(i), yScale(values[i]));\n }\n\n coords.push(width, zero);\n\n if (peity.options.fill) {\n svg.append(\n svgElement(\"polygon\", {\n fill: peity.options.fill,\n points: coords.join(\" \"),\n })\n );\n }\n\n if (strokeWidth) {\n svg.append(\n svgElement(\"polyline\", {\n fill: \"none\",\n points: coords.slice(2, coords.length - 2).join(\" \"),\n stroke: peity.options.stroke,\n \"stroke-width\": strokeWidth,\n \"stroke-linecap\": \"square\",\n })\n );\n }\n};\n\nexport const defaults = {\n delimiter: \",\",\n fill: \"#c6d9fd\",\n height: 16,\n min: 0,\n stroke: \"#4d89f9\",\n strokeWidth: 1,\n width: 32,\n};\n","import Peity from \"./peity\";\r\nimport * as pie from \"./renderers/pie\";\r\nimport * as bar from \"./renderers/bar\";\r\nimport * as line from \"./renderers/line\";\r\n\r\nPeity.register(\"pie\", pie.defaults, pie.renderer);\r\nPeity.register(\"donut\", pie.defaults, pie.renderer);\r\nPeity.register(\"bar\", bar.defaults, bar.renderer);\r\nPeity.register(\"line\", line.defaults, line.renderer);\r\n\r\nexport * from \"./peity\";\r\n\r\nconst peity = function (element, type, options) {\r\n const peity = new Peity(element, type, options);\r\n peity.mount();\r\n\r\n return peity;\r\n};\r\n\r\npeity.defaults = Peity.defaults;\r\npeity.graphers = Peity.graphers;\r\n\r\nexport default peity;\r\n"],"names":["isFunction","o","apply","svgElement","tag","attrs","element","document","createElementNS","attr","setAttribute","svgSupported","createSVGRect","Peity","type","options","Object","assign","defaults","JSON","parse","dataset","graphers","after","call","fill","_","i","length","width","height","svg","style","display","class","innerHTML","innerText","split","delimiter","map","value","parseFloat","addEventListener","draw","bind","removeEventListener","grapher","renderer","peity","match","values","n","v1","v2","Math","max","sum","diameter","radius","prepare","clientWidth","clientHeight","cx","cy","min","innerRadius","scale","radians","PI","cos","sin","cumulative","portion","node","x2","y1","y2","d","join","r","cumulativePlusValue","concat","push","append","undefined","diff","padding","xScale","input","yScale","x","w","valueY","h","y","strokeWidth","zero","coords","points","slice","stroke","register","pie","bar","line","mount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAO,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAACC,CAAD,EAAA;EAAA,EAAA,OACxBA,CAAC,KAAK,IAAN,IAAc,OAAOA,CAAP,KAAa,UAA3B,IAAyC,CAAC,CAACA,CAAC,CAACC,KADrB,CAAA;EAAA,CAAnB,CAAA;EAGA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,GAAD,EAAMC,KAAN,EAAgB;IACxC,IAAMC,OAAO,GAAGC,QAAQ,CAACC,eAAT,CAAyB,4BAAzB,EAAuDJ,GAAvD,CAAhB,CAAA;;EACA,EAAA,KAAK,IAAIK,IAAT,IAAiBJ,KAAjB,EAAwB;MACtBC,OAAO,CAACI,YAAR,CAAqBD,IAArB,EAA2BJ,KAA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ACwF,QAAN,CAAe,KAAf,EAAsBE,UAAtB,EAAoCA,UAApC,CAAA,CAAA;EACA1F,KAAK,CAACwF,QAAN,CAAe,MAAf,EAAuBG,QAAvB,EAAsCA,QAAtC,CAAA,CAAA;;AAIMxD,MAAAA,KAAK,GAAG,SAAU1C,KAAAA,CAAAA,OAAV,EAAmBQ,IAAnB,EAAyBC,OAAzB,EAAkC;IAC9C,IAAMiC,KAAK,GAAG,IAAInC,KAAJ,CAAUP,OAAV,EAAmBQ,IAAnB,EAAyBC,OAAzB,CAAd,CAAA;EACAiC,EAAAA,KAAK,CAACyD,KAAN,EAAA,CAAA;EAEA,EAAA,OAAOzD,KAAP,CAAA;EACD,EALD;;EAOAA,KAAK,CAAC9B,QAAN,GAAiBL,KAAK,CAACK,QAAvB,CAAA;EACA8B,KAAK,CAAC1B,QAAN,GAAiBT,KAAK,CAACS,QAAvB;;;;;;;;"}
@@ -0,0 +1 @@
1
+ pin 'peity', to: 'peity_vanilla.esm.js'
@@ -1,11 +1,5 @@
1
1
  module PeityVanillaRails
2
2
  class Railtie < ::Rails::Engine
3
- initializer "peity_vanilla_rails.importmap", before: "importmap" do |app|
4
- if defined?(Importmap)
5
- app.config.importmap.cache_sweepers << root.join("app/assets/javascripts")
6
- end
7
- end
8
-
9
3
  PRECOMPILE_ASSETS = Dir[root.join("app/assets/javascripts/**/*")]
10
4
  initializer 'peity_vanilla_rails.assets' do |app|
11
5
  if app.config.respond_to?(:assets)
@@ -13,6 +7,12 @@ module PeityVanillaRails
13
7
  end
14
8
  end
15
9
 
10
+ initializer "peity_vanilla_rails.importmap", before: "importmap" do |app|
11
+ if Rails.application.respond_to?(:importmap)
12
+ app.config.importmap.paths << root.join("config/importmap.rb")
13
+ end
14
+ end
15
+
16
16
  initializer 'peity_vanilla_rails.helpers', before: :load_config_initializers do
17
17
  ActiveSupport.on_load :action_view do
18
18
  include PeityVanillaRails::Helpers
@@ -1,3 +1,3 @@
1
1
  module PeityVanillaRails
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peity_vanilla_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
8
+ - Liubomyr Manastyretskyi
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2022-04-30 00:00:00.000000000 Z
12
+ date: 2022-05-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
@@ -69,6 +70,7 @@ dependencies:
69
70
  description: Sparklines are small but intense charts.
70
71
  email:
71
72
  - igorkasyanchuk@gmail.com
73
+ - manastyretskyi@gmail.com
72
74
  executables: []
73
75
  extensions: []
74
76
  extra_rdoc_files: []
@@ -76,8 +78,10 @@ files:
76
78
  - MIT-LICENSE
77
79
  - README.md
78
80
  - Rakefile
81
+ - app/assets/javascripts/peity_vanilla.esm.js
79
82
  - app/assets/javascripts/peity_vanilla.js
80
83
  - app/assets/javascripts/peity_vanilla.js.map
84
+ - config/importmap.rb
81
85
  - lib/peity_vanilla_rails.rb
82
86
  - lib/peity_vanilla_rails/engine.rb
83
87
  - lib/peity_vanilla_rails/helpers.rb