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,148 @@
1
+
2
+ nv.models.distribution = 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 = 400 //technically width or height depending on x or y....
10
+ , size = 8
11
+ , axis = 'x' // 'x' or 'y'... horizontal or vertical
12
+ , getData = function(d) { return d[axis] } // defaults d.x or d.y
13
+ , color = nv.utils.defaultColor()
14
+ , scale = d3.scale.linear()
15
+ , domain
16
+ ;
17
+
18
+ //============================================================
19
+
20
+
21
+ //============================================================
22
+ // Private Variables
23
+ //------------------------------------------------------------
24
+
25
+ var scale0;
26
+
27
+ //============================================================
28
+
29
+
30
+ function chart(selection) {
31
+ selection.each(function(data) {
32
+ var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom),
33
+ naxis = axis == 'x' ? 'y' : 'x',
34
+ container = d3.select(this);
35
+
36
+
37
+ //------------------------------------------------------------
38
+ // Setup Scales
39
+
40
+ scale0 = scale0 || scale;
41
+
42
+ //------------------------------------------------------------
43
+
44
+
45
+ //------------------------------------------------------------
46
+ // Setup containers and skeleton of chart
47
+
48
+ var wrap = container.selectAll('g.nv-distribution').data([data]);
49
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution');
50
+ var gEnter = wrapEnter.append('g');
51
+ var g = wrap.select('g');
52
+
53
+ wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')')
54
+
55
+ //------------------------------------------------------------
56
+
57
+
58
+ var distWrap = g.selectAll('g.nv-dist')
59
+ .data(function(d) { return d }, function(d) { return d.key });
60
+
61
+ distWrap.enter().append('g');
62
+ distWrap
63
+ .attr('class', function(d,i) { return 'nv-dist nv-series-' + i })
64
+ .style('stroke', function(d,i) { return color(d, i) });
65
+
66
+ var dist = distWrap.selectAll('line.nv-dist' + axis)
67
+ .data(function(d) { return d.values })
68
+ dist.enter().append('line')
69
+ .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) })
70
+ .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) })
71
+ distWrap.exit().selectAll('line.nv-dist' + axis)
72
+ .transition()
73
+ .attr(axis + '1', function(d,i) { return scale(getData(d,i)) })
74
+ .attr(axis + '2', function(d,i) { return scale(getData(d,i)) })
75
+ .style('stroke-opacity', 0)
76
+ .remove();
77
+ dist
78
+ .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i })
79
+ .attr(naxis + '1', 0)
80
+ .attr(naxis + '2', size);
81
+ dist
82
+ .transition()
83
+ .attr(axis + '1', function(d,i) { return scale(getData(d,i)) })
84
+ .attr(axis + '2', function(d,i) { return scale(getData(d,i)) })
85
+
86
+
87
+ scale0 = scale.copy();
88
+
89
+ });
90
+
91
+ return chart;
92
+ }
93
+
94
+
95
+ //============================================================
96
+ // Expose Public Variables
97
+ //------------------------------------------------------------
98
+ chart.options = nv.utils.optionsFunc.bind(chart);
99
+
100
+ chart.margin = function(_) {
101
+ if (!arguments.length) return margin;
102
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
103
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
104
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
105
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
106
+ return chart;
107
+ };
108
+
109
+ chart.width = function(_) {
110
+ if (!arguments.length) return width;
111
+ width = _;
112
+ return chart;
113
+ };
114
+
115
+ chart.axis = function(_) {
116
+ if (!arguments.length) return axis;
117
+ axis = _;
118
+ return chart;
119
+ };
120
+
121
+ chart.size = function(_) {
122
+ if (!arguments.length) return size;
123
+ size = _;
124
+ return chart;
125
+ };
126
+
127
+ chart.getData = function(_) {
128
+ if (!arguments.length) return getData;
129
+ getData = d3.functor(_);
130
+ return chart;
131
+ };
132
+
133
+ chart.scale = function(_) {
134
+ if (!arguments.length) return scale;
135
+ scale = _;
136
+ return chart;
137
+ };
138
+
139
+ chart.color = function(_) {
140
+ if (!arguments.length) return color;
141
+ color = nv.utils.getColor(_);
142
+ return chart;
143
+ };
144
+ //============================================================
145
+
146
+
147
+ return chart;
148
+ }
@@ -0,0 +1,331 @@
1
+ //TODO: consider deprecating and using multibar with single series for this
2
+ nv.models.historicalBar = 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
+ , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one
12
+ , x = d3.scale.linear()
13
+ , y = d3.scale.linear()
14
+ , getX = function(d) { return d.x }
15
+ , getY = function(d) { return d.y }
16
+ , forceX = []
17
+ , forceY = [0]
18
+ , padData = false
19
+ , clipEdge = true
20
+ , color = nv.utils.defaultColor()
21
+ , xDomain
22
+ , yDomain
23
+ , xRange
24
+ , yRange
25
+ , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout')
26
+ , interactive = true
27
+ ;
28
+
29
+ //============================================================
30
+
31
+
32
+ function chart(selection) {
33
+ selection.each(function(data) {
34
+ var availableWidth = width - margin.left - margin.right,
35
+ availableHeight = height - margin.top - margin.bottom,
36
+ container = d3.select(this);
37
+
38
+
39
+ //------------------------------------------------------------
40
+ // Setup Scales
41
+
42
+ x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) ))
43
+
44
+ if (padData)
45
+ x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]);
46
+ else
47
+ x.range(xRange || [0, availableWidth]);
48
+
49
+ y .domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) ))
50
+ .range(yRange || [availableHeight, 0]);
51
+
52
+ // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point
53
+
54
+ if (x.domain()[0] === x.domain()[1])
55
+ x.domain()[0] ?
56
+ x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01])
57
+ : x.domain([-1,1]);
58
+
59
+ if (y.domain()[0] === y.domain()[1])
60
+ y.domain()[0] ?
61
+ y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01])
62
+ : y.domain([-1,1]);
63
+
64
+ //------------------------------------------------------------
65
+
66
+
67
+ //------------------------------------------------------------
68
+ // Setup containers and skeleton of chart
69
+
70
+ var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]);
71
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id);
72
+ var defsEnter = wrapEnter.append('defs');
73
+ var gEnter = wrapEnter.append('g');
74
+ var g = wrap.select('g');
75
+
76
+ gEnter.append('g').attr('class', 'nv-bars');
77
+
78
+ wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
79
+
80
+ //------------------------------------------------------------
81
+
82
+
83
+ container
84
+ .on('click', function(d,i) {
85
+ dispatch.chartClick({
86
+ data: d,
87
+ index: i,
88
+ pos: d3.event,
89
+ id: id
90
+ });
91
+ });
92
+
93
+
94
+ defsEnter.append('clipPath')
95
+ .attr('id', 'nv-chart-clip-path-' + id)
96
+ .append('rect');
97
+
98
+ wrap.select('#nv-chart-clip-path-' + id + ' rect')
99
+ .attr('width', availableWidth)
100
+ .attr('height', availableHeight);
101
+
102
+ g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : '');
103
+
104
+
105
+
106
+ var bars = wrap.select('.nv-bars').selectAll('.nv-bar')
107
+ .data(function(d) { return d }, function(d,i) {return getX(d,i)});
108
+
109
+ bars.exit().remove();
110
+
111
+
112
+ var barsEnter = bars.enter().append('rect')
113
+ //.attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i })
114
+ .attr('x', 0 )
115
+ .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) })
116
+ .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) })
117
+ .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; })
118
+ .on('mouseover', function(d,i) {
119
+ if (!interactive) return;
120
+ d3.select(this).classed('hover', true);
121
+ dispatch.elementMouseover({
122
+ point: d,
123
+ series: data[0],
124
+ pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
125
+ pointIndex: i,
126
+ seriesIndex: 0,
127
+ e: d3.event
128
+ });
129
+
130
+ })
131
+ .on('mouseout', function(d,i) {
132
+ if (!interactive) return;
133
+ d3.select(this).classed('hover', false);
134
+ dispatch.elementMouseout({
135
+ point: d,
136
+ series: data[0],
137
+ pointIndex: i,
138
+ seriesIndex: 0,
139
+ e: d3.event
140
+ });
141
+ })
142
+ .on('click', function(d,i) {
143
+ if (!interactive) return;
144
+ dispatch.elementClick({
145
+ //label: d[label],
146
+ value: getY(d,i),
147
+ data: d,
148
+ index: i,
149
+ pos: [x(getX(d,i)), y(getY(d,i))],
150
+ e: d3.event,
151
+ id: id
152
+ });
153
+ d3.event.stopPropagation();
154
+ })
155
+ .on('dblclick', function(d,i) {
156
+ if (!interactive) return;
157
+ dispatch.elementDblClick({
158
+ //label: d[label],
159
+ value: getY(d,i),
160
+ data: d,
161
+ index: i,
162
+ pos: [x(getX(d,i)), y(getY(d,i))],
163
+ e: d3.event,
164
+ id: id
165
+ });
166
+ d3.event.stopPropagation();
167
+ });
168
+
169
+ bars
170
+ .attr('fill', function(d,i) { return color(d, i); })
171
+ .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i })
172
+ .transition()
173
+ .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; })
174
+ //TODO: better width calculations that don't assume always uniform data spacing;w
175
+ .attr('width', (availableWidth / data[0].values.length) * .9 );
176
+
177
+
178
+ bars.transition()
179
+ .attr('y', function(d,i) {
180
+ var rval = getY(d,i) < 0 ?
181
+ y(0) :
182
+ y(0) - y(getY(d,i)) < 1 ?
183
+ y(0) - 1 :
184
+ y(getY(d,i));
185
+ return nv.utils.NaNtoZero(rval);
186
+ })
187
+ .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) });
188
+
189
+ });
190
+
191
+ return chart;
192
+ }
193
+
194
+ //Create methods to allow outside functions to highlight a specific bar.
195
+ chart.highlightPoint = function(pointIndex, isHoverOver) {
196
+ d3.select(".nv-historicalBar-" + id)
197
+ .select(".nv-bars .nv-bar-0-" + pointIndex)
198
+ .classed("hover", isHoverOver)
199
+ ;
200
+ };
201
+
202
+ chart.clearHighlights = function() {
203
+ d3.select(".nv-historicalBar-" + id)
204
+ .select(".nv-bars .nv-bar.hover")
205
+ .classed("hover", false)
206
+ ;
207
+ };
208
+ //============================================================
209
+ // Expose Public Variables
210
+ //------------------------------------------------------------
211
+
212
+ chart.dispatch = dispatch;
213
+
214
+ chart.options = nv.utils.optionsFunc.bind(chart);
215
+
216
+ chart.x = function(_) {
217
+ if (!arguments.length) return getX;
218
+ getX = _;
219
+ return chart;
220
+ };
221
+
222
+ chart.y = function(_) {
223
+ if (!arguments.length) return getY;
224
+ getY = _;
225
+ return chart;
226
+ };
227
+
228
+ chart.margin = function(_) {
229
+ if (!arguments.length) return margin;
230
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
231
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
232
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
233
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
234
+ return chart;
235
+ };
236
+
237
+ chart.width = function(_) {
238
+ if (!arguments.length) return width;
239
+ width = _;
240
+ return chart;
241
+ };
242
+
243
+ chart.height = function(_) {
244
+ if (!arguments.length) return height;
245
+ height = _;
246
+ return chart;
247
+ };
248
+
249
+ chart.xScale = function(_) {
250
+ if (!arguments.length) return x;
251
+ x = _;
252
+ return chart;
253
+ };
254
+
255
+ chart.yScale = function(_) {
256
+ if (!arguments.length) return y;
257
+ y = _;
258
+ return chart;
259
+ };
260
+
261
+ chart.xDomain = function(_) {
262
+ if (!arguments.length) return xDomain;
263
+ xDomain = _;
264
+ return chart;
265
+ };
266
+
267
+ chart.yDomain = function(_) {
268
+ if (!arguments.length) return yDomain;
269
+ yDomain = _;
270
+ return chart;
271
+ };
272
+
273
+ chart.xRange = function(_) {
274
+ if (!arguments.length) return xRange;
275
+ xRange = _;
276
+ return chart;
277
+ };
278
+
279
+ chart.yRange = function(_) {
280
+ if (!arguments.length) return yRange;
281
+ yRange = _;
282
+ return chart;
283
+ };
284
+
285
+ chart.forceX = function(_) {
286
+ if (!arguments.length) return forceX;
287
+ forceX = _;
288
+ return chart;
289
+ };
290
+
291
+ chart.forceY = function(_) {
292
+ if (!arguments.length) return forceY;
293
+ forceY = _;
294
+ return chart;
295
+ };
296
+
297
+ chart.padData = function(_) {
298
+ if (!arguments.length) return padData;
299
+ padData = _;
300
+ return chart;
301
+ };
302
+
303
+ chart.clipEdge = function(_) {
304
+ if (!arguments.length) return clipEdge;
305
+ clipEdge = _;
306
+ return chart;
307
+ };
308
+
309
+ chart.color = function(_) {
310
+ if (!arguments.length) return color;
311
+ color = nv.utils.getColor(_);
312
+ return chart;
313
+ };
314
+
315
+ chart.id = function(_) {
316
+ if (!arguments.length) return id;
317
+ id = _;
318
+ return chart;
319
+ };
320
+
321
+ chart.interactive = function(_) {
322
+ if(!arguments.length) return interactive;
323
+ interactive = false;
324
+ return chart;
325
+ };
326
+
327
+ //============================================================
328
+
329
+
330
+ return chart;
331
+ }