active_frontend 14.0.82 → 14.0.83
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e57bf5f0a65eca6a04935173203b88114d3e9a
|
4
|
+
data.tar.gz: 2b778e54ed2bf292032e1c833edd6823d61c73ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68443d8397f48053339a0ce8acee41d76df4fec77220d2f538d12479a429db11c0818065c2dd967c6e0aff5f91257ae509e3e91fb08a9f3e341b864a63be1fac
|
7
|
+
data.tar.gz: d4b8b1f1b2684b6c95e72a40f09a2858b7332ccdd866d7d7493118df274fd09e463f8514e561522875ca50b88d4958c61480719418960ba572265f0ea5a56445
|
@@ -0,0 +1,252 @@
|
|
1
|
+
(function (root, factory) {
|
2
|
+
if (typeof define === 'function' && define.amd) {
|
3
|
+
define(factory);
|
4
|
+
} else if (typeof module === 'object' && module.exports) {
|
5
|
+
module.exports = factory();
|
6
|
+
} else {
|
7
|
+
root.FunnelChart = factory();
|
8
|
+
}
|
9
|
+
}(this, function() {
|
10
|
+
function extend(out) {
|
11
|
+
out = out || {};
|
12
|
+
|
13
|
+
for (var i = 1; i < arguments.length; i++) {
|
14
|
+
if (!arguments[i]) continue;
|
15
|
+
|
16
|
+
for (var key in arguments[i]) {
|
17
|
+
if (arguments[i].hasOwnProperty(key)) {
|
18
|
+
out[key] = arguments[i][key];
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
return out;
|
24
|
+
}
|
25
|
+
|
26
|
+
function FunnelChart(canvas, settings) {
|
27
|
+
if (!(this instanceof FunnelChart)) {
|
28
|
+
return new FunnelChart(canvas, settings);
|
29
|
+
}
|
30
|
+
|
31
|
+
this.canvas = (typeof canvas === 'string') ? document.getElementById(canvas) : canvas;
|
32
|
+
|
33
|
+
if (!settings.values || !settings.values.length) {
|
34
|
+
throw('A values setting must be provided');
|
35
|
+
}
|
36
|
+
|
37
|
+
this.settings = extend(this.settings, settings);
|
38
|
+
this.initialize();
|
39
|
+
}
|
40
|
+
|
41
|
+
FunnelChart.prototype = extend(FunnelChart.prototype, {
|
42
|
+
settings: {
|
43
|
+
displayPercentageChange: false,
|
44
|
+
pPrecision: 1,
|
45
|
+
labelLineColor: '#E5E8F1',
|
46
|
+
labelFontColor: '#2C3A49',
|
47
|
+
sectionColor: ['#054B8B', '#075FB0', '#0872D5', '#0D86F6', '#3298F7', '#57ABF9', '#7CDDFA'],
|
48
|
+
pSectionColor: '#F9FAFC',
|
49
|
+
font: 'Verdana',
|
50
|
+
maxFontSize: 12,
|
51
|
+
fontWeight: '600',
|
52
|
+
sectionFontColor: '#FFFFFF',
|
53
|
+
pSectionFontColor: '#FFFFFF',
|
54
|
+
pSectionHeightPercent: 50,
|
55
|
+
labelWidthPercent: 30,
|
56
|
+
funnelReductionPercent: 50,
|
57
|
+
labelOffset: 0,
|
58
|
+
lineHeight: 0
|
59
|
+
},
|
60
|
+
initialize: function() {
|
61
|
+
this.calculateDimensions();
|
62
|
+
this.draw();
|
63
|
+
},
|
64
|
+
calculateDimensions: function() {
|
65
|
+
var settings = this.settings;
|
66
|
+
var labelWidth, sectionTotalHeight, multiplier;
|
67
|
+
|
68
|
+
this.width = this.canvas.offsetWidth;
|
69
|
+
this.height = this.canvas.offsetHeight;
|
70
|
+
|
71
|
+
this.createHiDPICanvas();
|
72
|
+
|
73
|
+
labelWidth = this.hasLabels() ? this.width * (settings.labelWidthPercent / 100) : 0;
|
74
|
+
this.labelMaxWidth = labelWidth - settings.labelOffset;
|
75
|
+
this.startWidth = this.width - labelWidth;
|
76
|
+
this.endWidth = this.startWidth * (settings.funnelReductionPercent / 100);
|
77
|
+
|
78
|
+
sectionTotalHeight = (this.height / (settings.values.length));
|
79
|
+
|
80
|
+
if (settings.displayPercentageChange) {
|
81
|
+
multiplier = this.height / (this.height - (sectionTotalHeight / (100 + settings.pSectionHeightPercent)) * settings.pSectionHeightPercent);
|
82
|
+
this.sectionHeight = (multiplier * ((sectionTotalHeight / (100 + settings.pSectionHeightPercent)) * 100));
|
83
|
+
this.pSectionHeight = (multiplier * ((sectionTotalHeight / (100 + settings.pSectionHeightPercent)) * settings.pSectionHeightPercent));
|
84
|
+
} else {
|
85
|
+
this.sectionHeight = sectionTotalHeight;
|
86
|
+
this.pSectionHeight = 0;
|
87
|
+
}
|
88
|
+
},
|
89
|
+
pixelRatio: function(){
|
90
|
+
var ctx = this.canvas.getContext('2d');
|
91
|
+
var dpr = window.devicePixelRatio || 1;
|
92
|
+
var bsr = ctx.webkitBackingStorePixelRatio ||
|
93
|
+
ctx.mozBackingStorePixelRatio ||
|
94
|
+
ctx.msBackingStorePixelRatio ||
|
95
|
+
ctx.oBackingStorePixelRatio ||
|
96
|
+
ctx.backingStorePixelRatio || 1;
|
97
|
+
|
98
|
+
return dpr / bsr;
|
99
|
+
},
|
100
|
+
createHiDPICanvas: function() {
|
101
|
+
var canvas = this.canvas;
|
102
|
+
var ratio = this.pixelRatio();
|
103
|
+
var w = this.width;
|
104
|
+
var h = this.height;
|
105
|
+
|
106
|
+
canvas.width = w * ratio;
|
107
|
+
canvas.height = h * ratio;
|
108
|
+
canvas.style.width = w + 'px';
|
109
|
+
canvas.style.height = h + 'px';
|
110
|
+
canvas.getContext('2d').setTransform(ratio, 0, 0, ratio, 0, 0);
|
111
|
+
},
|
112
|
+
draw: function() {
|
113
|
+
var canvas = this.canvas;
|
114
|
+
var settings = this.settings;
|
115
|
+
|
116
|
+
if (canvas.getContext) {
|
117
|
+
var ctx = canvas.getContext('2d');
|
118
|
+
var maxAvailFontSize = ((settings.displayPercentageChange) ? this.pSectionHeight : this.sectionHeight) - 2;
|
119
|
+
|
120
|
+
if (settings.maxFontSize >= maxAvailFontSize) {
|
121
|
+
settings.maxFontSize = maxAvailFontSize;
|
122
|
+
}
|
123
|
+
|
124
|
+
ctx.font = settings.fontWeight + ' ' + settings.maxFontSize + 'px ' + settings.font;
|
125
|
+
|
126
|
+
if (this.hasLabels()) this.drawLabels(ctx);
|
127
|
+
|
128
|
+
this.drawClippingArea(ctx, settings);
|
129
|
+
|
130
|
+
ctx.fillStyle = '#E5E8F1';
|
131
|
+
ctx.fill();
|
132
|
+
ctx.clip();
|
133
|
+
|
134
|
+
this.drawSections(ctx);
|
135
|
+
this.drawClippingArea(ctx, settings, true);
|
136
|
+
|
137
|
+
ctx.lineWidth = 0;
|
138
|
+
ctx.strokeStyle = '#E5E8F1';
|
139
|
+
ctx.stroke();
|
140
|
+
}
|
141
|
+
},
|
142
|
+
drawLabels: function(ctx) {
|
143
|
+
var i;
|
144
|
+
var yPos;
|
145
|
+
var settings = this.settings;
|
146
|
+
|
147
|
+
ctx.textAlign = 'left';
|
148
|
+
ctx.strokeStyle = settings.labelLineColor;
|
149
|
+
ctx.lineWidth = settings.lineHeight;
|
150
|
+
|
151
|
+
for (i = 0; i < settings.values.length; i++) {
|
152
|
+
yPos = this.calculateYPos(i) - 1;
|
153
|
+
|
154
|
+
ctx.fillStyle = this.sequentialValue(settings.labelFontColor, i);
|
155
|
+
ctx.fillText(
|
156
|
+
settings.labels[i] || '',
|
157
|
+
this.startWidth + settings.labelOffset,
|
158
|
+
yPos + (this.sectionHeight / 2) + (settings.maxFontSize / 2) - 2,
|
159
|
+
this.labelMaxWidth
|
160
|
+
);
|
161
|
+
|
162
|
+
if (i > 0) {
|
163
|
+
ctx.beginPath();
|
164
|
+
ctx.moveTo(i, yPos);
|
165
|
+
ctx.lineTo(this.width, yPos);
|
166
|
+
ctx.stroke();
|
167
|
+
}
|
168
|
+
|
169
|
+
if (i < (settings.values.length - 1) && settings.displayPercentageChange) {
|
170
|
+
ctx.beginPath();
|
171
|
+
ctx.moveTo(i, yPos + this.sectionHeight);
|
172
|
+
ctx.lineTo(this.width, yPos + this.sectionHeight);
|
173
|
+
ctx.stroke();
|
174
|
+
}
|
175
|
+
}
|
176
|
+
},
|
177
|
+
drawClippingArea: function(ctx, settings, curvesOnly) {
|
178
|
+
var inset = (this.startWidth - this.endWidth) / 2;
|
179
|
+
var height = (settings.values.length * this.sectionHeight) +
|
180
|
+
((settings.values.length - 1) * this.pSectionHeight) +
|
181
|
+
(settings.values.length + 1);
|
182
|
+
var lineOrMove = curvesOnly ? 'moveTo' : 'lineTo';
|
183
|
+
|
184
|
+
ctx.beginPath();
|
185
|
+
ctx.moveTo(0,0);
|
186
|
+
ctx[lineOrMove](this.startWidth,0);
|
187
|
+
ctx.quadraticCurveTo(
|
188
|
+
(this.startWidth - inset),
|
189
|
+
(height / 3),
|
190
|
+
(this.startWidth - inset),
|
191
|
+
height
|
192
|
+
);
|
193
|
+
ctx[lineOrMove](inset,height);
|
194
|
+
ctx.quadraticCurveTo(inset, (height / 3), 0, 0);
|
195
|
+
},
|
196
|
+
drawSections: function(ctx) {
|
197
|
+
var i;
|
198
|
+
var yPos;
|
199
|
+
var settings = this.settings;
|
200
|
+
|
201
|
+
ctx.textAlign = 'center';
|
202
|
+
|
203
|
+
for (i = 0; i < settings.values.length; i++) {
|
204
|
+
yPos = this.calculateYPos(i);
|
205
|
+
|
206
|
+
ctx.fillStyle = this.sequentialValue(settings.sectionColor, i);
|
207
|
+
ctx.fillRect(0, yPos, this.startWidth, this.sectionHeight - settings.lineHeight);
|
208
|
+
ctx.fillStyle = this.sequentialValue(settings.sectionFontColor, i);
|
209
|
+
ctx.fillText(
|
210
|
+
settings.values[i],
|
211
|
+
this.startWidth / 2,
|
212
|
+
yPos + ((this.sectionHeight - settings.lineHeight) / 2) + (settings.maxFontSize / 2) - 2
|
213
|
+
);
|
214
|
+
|
215
|
+
if (i < (settings.values.length - 1) && settings.displayPercentageChange) {
|
216
|
+
ctx.fillStyle = this.sequentialValue(settings.pSectionColor, i);
|
217
|
+
ctx.fillRect(
|
218
|
+
0,
|
219
|
+
(yPos + this.sectionHeight),
|
220
|
+
this.startWidth,
|
221
|
+
this.pSectionHeight - settings.lineHeight
|
222
|
+
);
|
223
|
+
ctx.fillStyle = this.sequentialValue(settings.pSectionFontColor, i);
|
224
|
+
ctx.fillText(
|
225
|
+
(settings.values[i] === 0) ? '' : ((settings.values[i + 1] / settings.values[i]) * 100).toFixed(settings.pPrecision) + '%',
|
226
|
+
this.startWidth / 2,
|
227
|
+
yPos + this.sectionHeight + ((this.pSectionHeight - settings.lineHeight) / 2) + (settings.maxFontSize / 2) - 1
|
228
|
+
);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
},
|
232
|
+
hasLabels: function() {
|
233
|
+
var labels = this.settings.labels;
|
234
|
+
return labels && !!labels.length;
|
235
|
+
},
|
236
|
+
calculateYPos: function(i) {
|
237
|
+
var sectionHeight = this.sectionHeight;
|
238
|
+
|
239
|
+
if(this.settings.displayPercentageChange) {
|
240
|
+
sectionHeight += this.pSectionHeight;
|
241
|
+
}
|
242
|
+
|
243
|
+
return sectionHeight * i;
|
244
|
+
},
|
245
|
+
sequentialValue: function(arr, i) {
|
246
|
+
if (typeof arr === 'string') return arr;
|
247
|
+
return arr[i % arr.length];
|
248
|
+
}
|
249
|
+
});
|
250
|
+
|
251
|
+
return FunnelChart;
|
252
|
+
}));
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 14.0.
|
4
|
+
version: 14.0.83
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -249,6 +249,7 @@ files:
|
|
249
249
|
- vendor/assets/javascripts/extensions/_chart.js
|
250
250
|
- vendor/assets/javascripts/extensions/_cohort.js
|
251
251
|
- vendor/assets/javascripts/extensions/_copy.js
|
252
|
+
- vendor/assets/javascripts/extensions/_funnel.js
|
252
253
|
- vendor/assets/javascripts/extensions/_map.js
|
253
254
|
- vendor/assets/javascripts/extensions/_wysiwyg.js
|
254
255
|
- vendor/assets/stylesheets/.DS_Store
|