pyk 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/lib/chardinjs.min.js +2 -0
  3. data/app/assets/javascripts/lib/crossfilter.js +1383 -1
  4. data/app/assets/javascripts/lib/{d3.js → d3.v3.js} +0 -0
  5. data/app/assets/javascripts/lib/dc.js +3492 -757
  6. data/app/assets/javascripts/lib/jquery.gridster.js +2 -3621
  7. data/app/assets/javascripts/lib/markermanager.js +2 -980
  8. data/app/assets/javascripts/lib/underscore.js +1276 -0
  9. data/app/assets/javascripts/nvd3/lib/colorbrewer.js +302 -0
  10. data/app/assets/javascripts/nvd3/lib/crossfilter.js +1180 -0
  11. data/app/assets/javascripts/nvd3/lib/crossfilter.min.js +1 -0
  12. data/app/assets/javascripts/nvd3/lib/d3.v2.js +7033 -0
  13. data/app/assets/javascripts/nvd3/lib/d3.v2.min.js +4 -0
  14. data/app/assets/javascripts/nvd3/lib/d3.v3.js +8436 -0
  15. data/app/assets/javascripts/nvd3/lib/fisheye.js +86 -0
  16. data/app/assets/javascripts/nvd3/lib/hive.js +80 -0
  17. data/app/assets/javascripts/nvd3/lib/horizon.js +192 -0
  18. data/app/assets/javascripts/nvd3/lib/sankey.js +292 -0
  19. data/app/assets/javascripts/nvd3/nv.d3.js +14312 -0
  20. data/app/assets/javascripts/nvd3/nv.d3.min.js +6 -0
  21. data/app/assets/javascripts/nvd3/src/core.js +122 -0
  22. data/app/assets/javascripts/nvd3/src/interactiveLayer.js +251 -0
  23. data/app/assets/javascripts/nvd3/src/models/axis.js +405 -0
  24. data/app/assets/javascripts/nvd3/src/models/backup/bullet.js +250 -0
  25. data/app/assets/javascripts/nvd3/src/models/backup/bulletChart.js +349 -0
  26. data/app/assets/javascripts/nvd3/src/models/boilerplate.js +104 -0
  27. data/app/assets/javascripts/nvd3/src/models/bullet.js +385 -0
  28. data/app/assets/javascripts/nvd3/src/models/bulletChart.js +343 -0
  29. data/app/assets/javascripts/nvd3/src/models/cumulativeLineChart.js +782 -0
  30. data/app/assets/javascripts/nvd3/src/models/discreteBar.js +349 -0
  31. data/app/assets/javascripts/nvd3/src/models/discreteBarChart.js +333 -0
  32. data/app/assets/javascripts/nvd3/src/models/distribution.js +148 -0
  33. data/app/assets/javascripts/nvd3/src/models/historicalBar.js +331 -0
  34. data/app/assets/javascripts/nvd3/src/models/historicalBarChart.js +419 -0
  35. data/app/assets/javascripts/nvd3/src/models/indentedTree.js +337 -0
  36. data/app/assets/javascripts/nvd3/src/models/legend.js +270 -0
  37. data/app/assets/javascripts/nvd3/src/models/line.js +284 -0
  38. data/app/assets/javascripts/nvd3/src/models/lineChart.js +465 -0
  39. data/app/assets/javascripts/nvd3/src/models/linePlusBarChart.js +433 -0
  40. data/app/assets/javascripts/nvd3/src/models/linePlusBarWithFocusChart.js +658 -0
  41. data/app/assets/javascripts/nvd3/src/models/lineWithFisheye.js +200 -0
  42. data/app/assets/javascripts/nvd3/src/models/lineWithFisheyeChart.js +297 -0
  43. data/app/assets/javascripts/nvd3/src/models/lineWithFocusChart.js +574 -0
  44. data/app/assets/javascripts/nvd3/src/models/multiBar.js +461 -0
  45. data/app/assets/javascripts/nvd3/src/models/multiBarChart.js +524 -0
  46. data/app/assets/javascripts/nvd3/src/models/multiBarHorizontal.js +424 -0
  47. data/app/assets/javascripts/nvd3/src/models/multiBarHorizontalChart.js +434 -0
  48. data/app/assets/javascripts/nvd3/src/models/multiBarTimeSeries.js +384 -0
  49. data/app/assets/javascripts/nvd3/src/models/multiBarTimeSeriesChart.js +405 -0
  50. data/app/assets/javascripts/nvd3/src/models/multiChart.js +452 -0
  51. data/app/assets/javascripts/nvd3/src/models/ohlcBar.js +380 -0
  52. data/app/assets/javascripts/nvd3/src/models/parallelCoordinates.js +239 -0
  53. data/app/assets/javascripts/nvd3/src/models/pie.js +398 -0
  54. data/app/assets/javascripts/nvd3/src/models/pieChart.js +292 -0
  55. data/app/assets/javascripts/nvd3/src/models/scatter.js +674 -0
  56. data/app/assets/javascripts/nvd3/src/models/scatterChart.js +628 -0
  57. data/app/assets/javascripts/nvd3/src/models/scatterPlusLineChart.js +620 -0
  58. data/app/assets/javascripts/nvd3/src/models/sparkline.js +194 -0
  59. data/app/assets/javascripts/nvd3/src/models/sparklinePlus.js +295 -0
  60. data/app/assets/javascripts/nvd3/src/models/stackedArea.js +368 -0
  61. data/app/assets/javascripts/nvd3/src/models/stackedAreaChart.js +629 -0
  62. data/app/assets/javascripts/nvd3/src/tooltip.js +490 -0
  63. data/app/assets/javascripts/nvd3/src/utils.js +152 -0
  64. data/app/assets/javascripts/pyk.js +1 -0
  65. data/app/assets/stylesheets/lib/chardinjs.css +82 -0
  66. data/app/assets/stylesheets/nvd3/nv.d3.css +769 -0
  67. data/app/assets/stylesheets/pyk.css.scss +1 -0
  68. metadata +61 -2
@@ -0,0 +1,461 @@
1
+
2
+ nv.models.multiBar = function() {
3
+ "use strict";
4
+ //============================================================
5
+ // Public Variables with Default Settings
6
+ //------------------------------------------------------------
7
+
8
+ var margin = {top: 0, right: 0, bottom: 0, left: 0}
9
+ , width = 960
10
+ , height = 500
11
+ , x = d3.scale.ordinal()
12
+ , y = d3.scale.linear()
13
+ , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one
14
+ , getX = function(d) { return d.x }
15
+ , getY = function(d) { return d.y }
16
+ , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
17
+ , clipEdge = true
18
+ , stacked = false
19
+ , stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function
20
+ , color = nv.utils.defaultColor()
21
+ , hideable = false
22
+ , barColor = null // adding the ability to set the color for each rather than the whole group
23
+ , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled
24
+ , delay = 1200
25
+ , xDomain
26
+ , yDomain
27
+ , xRange
28
+ , yRange
29
+ , groupSpacing = 0.1
30
+ , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout')
31
+ ;
32
+
33
+ //============================================================
34
+
35
+
36
+ //============================================================
37
+ // Private Variables
38
+ //------------------------------------------------------------
39
+
40
+ var x0, y0 //used to store previous scales
41
+ ;
42
+
43
+ //============================================================
44
+
45
+
46
+ function chart(selection) {
47
+ selection.each(function(data) {
48
+ var availableWidth = width - margin.left - margin.right,
49
+ availableHeight = height - margin.top - margin.bottom,
50
+ container = d3.select(this);
51
+
52
+ if(hideable && data.length) hideable = [{
53
+ values: data[0].values.map(function(d) {
54
+ return {
55
+ x: d.x,
56
+ y: 0,
57
+ series: d.series,
58
+ size: 0.01
59
+ };}
60
+ )}];
61
+
62
+ if (stacked)
63
+ data = d3.layout.stack()
64
+ .offset(stackOffset)
65
+ .values(function(d){ return d.values })
66
+ .y(getY)
67
+ (!data.length && hideable ? hideable : data);
68
+
69
+
70
+ //add series index to each data point for reference
71
+ data.forEach(function(series, i) {
72
+ series.values.forEach(function(point) {
73
+ point.series = i;
74
+ });
75
+ });
76
+
77
+
78
+ //------------------------------------------------------------
79
+ // HACK for negative value stacking
80
+ if (stacked)
81
+ data[0].values.map(function(d,i) {
82
+ var posBase = 0, negBase = 0;
83
+ data.map(function(d) {
84
+ var f = d.values[i]
85
+ f.size = Math.abs(f.y);
86
+ if (f.y<0) {
87
+ f.y1 = negBase;
88
+ negBase = negBase - f.size;
89
+ } else
90
+ {
91
+ f.y1 = f.size + posBase;
92
+ posBase = posBase + f.size;
93
+ }
94
+ });
95
+ });
96
+
97
+ //------------------------------------------------------------
98
+ // Setup Scales
99
+
100
+ // remap and flatten the data for use in calculating the scales' domains
101
+ var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate
102
+ data.map(function(d) {
103
+ return d.values.map(function(d,i) {
104
+ return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 }
105
+ })
106
+ });
107
+
108
+ x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))
109
+ .rangeBands(xRange || [0, availableWidth], groupSpacing);
110
+
111
+ //y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y + (stacked ? d.y1 : 0) }).concat(forceY)))
112
+ y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 : d.y1 + d.y ) : d.y }).concat(forceY)))
113
+ .range(yRange || [availableHeight, 0]);
114
+
115
+ // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point
116
+ if (x.domain()[0] === x.domain()[1])
117
+ x.domain()[0] ?
118
+ x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])
119
+ : x.domain([-1,1]);
120
+
121
+ if (y.domain()[0] === y.domain()[1])
122
+ y.domain()[0] ?
123
+ y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])
124
+ : y.domain([-1,1]);
125
+
126
+
127
+ x0 = x0 || x;
128
+ y0 = y0 || y;
129
+
130
+ //------------------------------------------------------------
131
+
132
+
133
+ //------------------------------------------------------------
134
+ // Setup containers and skeleton of chart
135
+
136
+ var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]);
137
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar');
138
+ var defsEnter = wrapEnter.append('defs');
139
+ var gEnter = wrapEnter.append('g');
140
+ var g = wrap.select('g')
141
+
142
+ gEnter.append('g').attr('class', 'nv-groups');
143
+
144
+ wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
145
+
146
+ //------------------------------------------------------------
147
+
148
+
149
+
150
+ defsEnter.append('clipPath')
151
+ .attr('id', 'nv-edge-clip-' + id)
152
+ .append('rect');
153
+ wrap.select('#nv-edge-clip-' + id + ' rect')
154
+ .attr('width', availableWidth)
155
+ .attr('height', availableHeight);
156
+
157
+ g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');
158
+
159
+
160
+
161
+ var groups = wrap.select('.nv-groups').selectAll('.nv-group')
162
+ .data(function(d) { return d }, function(d,i) { return i });
163
+ groups.enter().append('g')
164
+ .style('stroke-opacity', 1e-6)
165
+ .style('fill-opacity', 1e-6);
166
+ groups.exit()
167
+ .transition()
168
+ .selectAll('rect.nv-bar')
169
+ .delay(function(d,i) {
170
+ return i * delay/ data[0].values.length;
171
+ })
172
+ .attr('y', function(d) { return stacked ? y0(d.y0) : y0(0) })
173
+ .attr('height', 0)
174
+ .remove();
175
+ groups
176
+ .attr('class', function(d,i) { return 'nv-group nv-series-' + i })
177
+ .classed('hover', function(d) { return d.hover })
178
+ .style('fill', function(d,i){ return color(d, i) })
179
+ .style('stroke', function(d,i){ return color(d, i) });
180
+ groups
181
+ .transition()
182
+ .style('stroke-opacity', 1)
183
+ .style('fill-opacity', .75);
184
+
185
+
186
+ var bars = groups.selectAll('rect.nv-bar')
187
+ .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values });
188
+
189
+ bars.exit().remove();
190
+
191
+
192
+ var barsEnter = bars.enter().append('rect')
193
+ .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})
194
+ .attr('x', function(d,i,j) {
195
+ return stacked ? 0 : (j * x.rangeBand() / data.length )
196
+ })
197
+ .attr('y', function(d) { return y0(stacked ? d.y0 : 0) })
198
+ .attr('height', 0)
199
+ .attr('width', x.rangeBand() / (stacked ? 1 : data.length) )
200
+ .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; })
201
+ ;
202
+ bars
203
+ .style('fill', function(d,i,j){ return color(d, j, i); })
204
+ .style('stroke', function(d,i,j){ return color(d, j, i); })
205
+ .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here
206
+ d3.select(this).classed('hover', true);
207
+ dispatch.elementMouseover({
208
+ value: getY(d,i),
209
+ point: d,
210
+ series: data[d.series],
211
+ pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted
212
+ pointIndex: i,
213
+ seriesIndex: d.series,
214
+ e: d3.event
215
+ });
216
+ })
217
+ .on('mouseout', function(d,i) {
218
+ d3.select(this).classed('hover', false);
219
+ dispatch.elementMouseout({
220
+ value: getY(d,i),
221
+ point: d,
222
+ series: data[d.series],
223
+ pointIndex: i,
224
+ seriesIndex: d.series,
225
+ e: d3.event
226
+ });
227
+ })
228
+ .on('click', function(d,i) {
229
+ dispatch.elementClick({
230
+ value: getY(d,i),
231
+ point: d,
232
+ series: data[d.series],
233
+ pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted
234
+ pointIndex: i,
235
+ seriesIndex: d.series,
236
+ e: d3.event
237
+ });
238
+ d3.event.stopPropagation();
239
+ })
240
+ .on('dblclick', function(d,i) {
241
+ dispatch.elementDblClick({
242
+ value: getY(d,i),
243
+ point: d,
244
+ series: data[d.series],
245
+ pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted
246
+ pointIndex: i,
247
+ seriesIndex: d.series,
248
+ e: d3.event
249
+ });
250
+ d3.event.stopPropagation();
251
+ });
252
+ bars
253
+ .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'})
254
+ .transition()
255
+ .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; })
256
+
257
+ if (barColor) {
258
+ if (!disabled) disabled = data.map(function() { return true });
259
+ bars
260
+ .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); })
261
+ .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); });
262
+ }
263
+
264
+
265
+ if (stacked)
266
+ bars.transition()
267
+ .delay(function(d,i) {
268
+
269
+ return i * delay / data[0].values.length;
270
+ })
271
+ .attr('y', function(d,i) {
272
+
273
+ return y((stacked ? d.y1 : 0));
274
+ })
275
+ .attr('height', function(d,i) {
276
+ return Math.max(Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0))),1);
277
+ })
278
+ .attr('x', function(d,i) {
279
+ return stacked ? 0 : (d.series * x.rangeBand() / data.length )
280
+ })
281
+ .attr('width', x.rangeBand() / (stacked ? 1 : data.length) );
282
+ else
283
+ bars.transition()
284
+ .delay(function(d,i) {
285
+ return i * delay/ data[0].values.length;
286
+ })
287
+ .attr('x', function(d,i) {
288
+ return d.series * x.rangeBand() / data.length
289
+ })
290
+ .attr('width', x.rangeBand() / data.length)
291
+ .attr('y', function(d,i) {
292
+ return getY(d,i) < 0 ?
293
+ y(0) :
294
+ y(0) - y(getY(d,i)) < 1 ?
295
+ y(0) - 1 :
296
+ y(getY(d,i)) || 0;
297
+ })
298
+ .attr('height', function(d,i) {
299
+ return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0;
300
+ });
301
+
302
+
303
+
304
+ //store old scales for use in transitions on update
305
+ x0 = x.copy();
306
+ y0 = y.copy();
307
+
308
+ });
309
+
310
+ return chart;
311
+ }
312
+
313
+
314
+ //============================================================
315
+ // Expose Public Variables
316
+ //------------------------------------------------------------
317
+
318
+ chart.dispatch = dispatch;
319
+
320
+ chart.options = nv.utils.optionsFunc.bind(chart);
321
+
322
+ chart.x = function(_) {
323
+ if (!arguments.length) return getX;
324
+ getX = _;
325
+ return chart;
326
+ };
327
+
328
+ chart.y = function(_) {
329
+ if (!arguments.length) return getY;
330
+ getY = _;
331
+ return chart;
332
+ };
333
+
334
+ chart.margin = function(_) {
335
+ if (!arguments.length) return margin;
336
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
337
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
338
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
339
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
340
+ return chart;
341
+ };
342
+
343
+ chart.width = function(_) {
344
+ if (!arguments.length) return width;
345
+ width = _;
346
+ return chart;
347
+ };
348
+
349
+ chart.height = function(_) {
350
+ if (!arguments.length) return height;
351
+ height = _;
352
+ return chart;
353
+ };
354
+
355
+ chart.xScale = function(_) {
356
+ if (!arguments.length) return x;
357
+ x = _;
358
+ return chart;
359
+ };
360
+
361
+ chart.yScale = function(_) {
362
+ if (!arguments.length) return y;
363
+ y = _;
364
+ return chart;
365
+ };
366
+
367
+ chart.xDomain = function(_) {
368
+ if (!arguments.length) return xDomain;
369
+ xDomain = _;
370
+ return chart;
371
+ };
372
+
373
+ chart.yDomain = function(_) {
374
+ if (!arguments.length) return yDomain;
375
+ yDomain = _;
376
+ return chart;
377
+ };
378
+
379
+ chart.xRange = function(_) {
380
+ if (!arguments.length) return xRange;
381
+ xRange = _;
382
+ return chart;
383
+ };
384
+
385
+ chart.yRange = function(_) {
386
+ if (!arguments.length) return yRange;
387
+ yRange = _;
388
+ return chart;
389
+ };
390
+
391
+ chart.forceY = function(_) {
392
+ if (!arguments.length) return forceY;
393
+ forceY = _;
394
+ return chart;
395
+ };
396
+
397
+ chart.stacked = function(_) {
398
+ if (!arguments.length) return stacked;
399
+ stacked = _;
400
+ return chart;
401
+ };
402
+
403
+ chart.stackOffset = function(_) {
404
+ if (!arguments.length) return stackOffset;
405
+ stackOffset = _;
406
+ return chart;
407
+ };
408
+
409
+ chart.clipEdge = function(_) {
410
+ if (!arguments.length) return clipEdge;
411
+ clipEdge = _;
412
+ return chart;
413
+ };
414
+
415
+ chart.color = function(_) {
416
+ if (!arguments.length) return color;
417
+ color = nv.utils.getColor(_);
418
+ return chart;
419
+ };
420
+
421
+ chart.barColor = function(_) {
422
+ if (!arguments.length) return barColor;
423
+ barColor = nv.utils.getColor(_);
424
+ return chart;
425
+ };
426
+
427
+ chart.disabled = function(_) {
428
+ if (!arguments.length) return disabled;
429
+ disabled = _;
430
+ return chart;
431
+ };
432
+
433
+ chart.id = function(_) {
434
+ if (!arguments.length) return id;
435
+ id = _;
436
+ return chart;
437
+ };
438
+
439
+ chart.hideable = function(_) {
440
+ if (!arguments.length) return hideable;
441
+ hideable = _;
442
+ return chart;
443
+ };
444
+
445
+ chart.delay = function(_) {
446
+ if (!arguments.length) return delay;
447
+ delay = _;
448
+ return chart;
449
+ };
450
+
451
+ chart.groupSpacing = function(_) {
452
+ if (!arguments.length) return groupSpacing;
453
+ groupSpacing = _;
454
+ return chart;
455
+ };
456
+
457
+ //============================================================
458
+
459
+
460
+ return chart;
461
+ }