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,200 @@
1
+
2
+ nv.models.line = function() {
3
+ "use strict";
4
+ //Default Settings
5
+ var margin = {top: 0, right: 0, bottom: 0, left: 0},
6
+ width = 960,
7
+ height = 500,
8
+ color = nv.utils.defaultColor(), // function that returns colors
9
+ id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one
10
+ getX = function(d) { return d.x }, // accessor to get the x value from a data point
11
+ getY = function(d) { return d.y }, // accessor to get the y value from a data point
12
+ clipEdge = false, // if true, masks lines within x and y scale
13
+ interpolate = "linear"; // controls the line interpolation
14
+
15
+
16
+ var scatter = nv.models.scatter()
17
+ .id(id)
18
+ .size(16) // default size
19
+ .sizeDomain([16,256]), //set to speed up calculation, needs to be unset if there is a custom size accessor
20
+ //x = scatter.xScale(),
21
+ //y = scatter.yScale(),
22
+ x, y,
23
+ x0, y0, timeoutID;
24
+
25
+
26
+ function chart(selection) {
27
+ selection.each(function(data) {
28
+ var availableWidth = width - margin.left - margin.right,
29
+ availableHeight = height - margin.top - margin.bottom;
30
+
31
+ //get the scales inscase scatter scale was set manually
32
+ x = x || scatter.xScale();
33
+ y = y || scatter.yScale();
34
+
35
+ //store old scales if they exist
36
+ x0 = x0 || x;
37
+ y0 = y0 || y;
38
+
39
+
40
+ var wrap = d3.select(this).selectAll('g.nv-wrap.nv-line').data([data]);
41
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line');
42
+ var defsEnter = wrapEnter.append('defs');
43
+ var gEnter = wrapEnter.append('g');
44
+ var g = wrap.select('g')
45
+
46
+ wrapEnter.append('g').attr('class', 'nv-scatterWrap');
47
+ var scatterWrap = wrap.select('.nv-scatterWrap').datum(data);
48
+
49
+ gEnter.append('g').attr('class', 'nv-groups');
50
+
51
+
52
+ scatter
53
+ .width(availableWidth)
54
+ .height(availableHeight)
55
+
56
+ d3.transition(scatterWrap).call(scatter);
57
+
58
+
59
+ wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
60
+
61
+
62
+ defsEnter.append('clipPath')
63
+ .attr('id', 'nv-edge-clip-' + id)
64
+ .append('rect');
65
+
66
+ wrap.select('#nv-edge-clip-' + id + ' rect')
67
+ .attr('width', availableWidth)
68
+ .attr('height', availableHeight);
69
+
70
+ g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');
71
+ scatterWrap
72
+ .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : '');
73
+
74
+
75
+
76
+
77
+ var groups = wrap.select('.nv-groups').selectAll('.nv-group')
78
+ .data(function(d) { return d }, function(d) { return d.key });
79
+ groups.enter().append('g')
80
+ .style('stroke-opacity', 1e-6)
81
+ .style('fill-opacity', 1e-6);
82
+ d3.transition(groups.exit())
83
+ .style('stroke-opacity', 1e-6)
84
+ .style('fill-opacity', 1e-6)
85
+ .remove();
86
+ groups
87
+ .attr('class', function(d,i) { return 'nv-group nv-series-' + i })
88
+ .classed('hover', function(d) { return d.hover })
89
+ .style('fill', function(d,i){ return color(d, i) })
90
+ .style('stroke', function(d,i){ return color(d, i) })
91
+ d3.transition(groups)
92
+ .style('stroke-opacity', 1)
93
+ .style('fill-opacity', .5)
94
+
95
+
96
+ var paths = groups.selectAll('path')
97
+ .data(function(d, i) { return [d.values] });
98
+ paths.enter().append('path')
99
+ .attr('class', 'nv-line')
100
+ .attr('d', d3.svg.line()
101
+ .interpolate(interpolate)
102
+ .x(function(d,i) { return x0(getX(d,i)) })
103
+ .y(function(d,i) { return y0(getY(d,i)) })
104
+ );
105
+ d3.transition(groups.exit().selectAll('path'))
106
+ .attr('d', d3.svg.line()
107
+ .interpolate(interpolate)
108
+ .x(function(d,i) { return x(getX(d,i)) })
109
+ .y(function(d,i) { return y(getY(d,i)) })
110
+ )
111
+ .remove(); // redundant? line is already being removed
112
+ d3.transition(paths)
113
+ .attr('d', d3.svg.line()
114
+ .interpolate(interpolate)
115
+ .x(function(d,i) { return x(getX(d,i)) })
116
+ .y(function(d,i) { return y(getY(d,i)) })
117
+ );
118
+
119
+
120
+ //store old scales for use in transitions on update, to animate from old to new positions
121
+ x0 = x.copy();
122
+ y0 = y.copy();
123
+
124
+ });
125
+
126
+ return chart;
127
+ }
128
+
129
+
130
+ chart.dispatch = scatter.dispatch;
131
+
132
+ d3.rebind(chart, scatter, 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius');
133
+
134
+ chart.options = nv.utils.optionsFunc.bind(chart);
135
+
136
+ chart.margin = function(_) {
137
+ if (!arguments.length) return margin;
138
+ margin = _;
139
+ return chart;
140
+ };
141
+
142
+ chart.width = function(_) {
143
+ if (!arguments.length) return width;
144
+ width = _;
145
+ return chart;
146
+ };
147
+
148
+ chart.height = function(_) {
149
+ if (!arguments.length) return height;
150
+ height = _;
151
+ return chart;
152
+ };
153
+
154
+ chart.x = function(_) {
155
+ if (!arguments.length) return getX;
156
+ getX = _;
157
+ scatter.x(_);
158
+ return chart;
159
+ };
160
+
161
+ chart.y = function(_) {
162
+ if (!arguments.length) return getY;
163
+ getY = _;
164
+ scatter.y(_);
165
+ return chart;
166
+ };
167
+
168
+ chart.clipEdge = function(_) {
169
+ if (!arguments.length) return clipEdge;
170
+ clipEdge = _;
171
+ return chart;
172
+ };
173
+
174
+ chart.color = function(_) {
175
+ if (!arguments.length) return color;
176
+ color = nv.utils.getColor(_);
177
+ scatter.color(color);
178
+ return chart;
179
+ };
180
+
181
+ chart.id = function(_) {
182
+ if (!arguments.length) return id;
183
+ id = _;
184
+ return chart;
185
+ };
186
+
187
+ chart.interpolate = function(_) {
188
+ if (!arguments.length) return interpolate;
189
+ interpolate = _;
190
+ return chart;
191
+ };
192
+
193
+ chart.defined = function(_) {
194
+ if (!arguments.length) return defined;
195
+ defined = _;
196
+ return chart;
197
+ };
198
+
199
+ return chart;
200
+ }
@@ -0,0 +1,297 @@
1
+
2
+ nv.models.lineChart = function() {
3
+ "use strict";
4
+ var margin = {top: 30, right: 20, bottom: 50, left: 60},
5
+ color = nv.utils.defaultColor(),
6
+ width = null,
7
+ height = null,
8
+ showLegend = true,
9
+ showControls = true,
10
+ fisheye = 0,
11
+ pauseFisheye = false,
12
+ tooltips = true,
13
+ tooltip = function(key, x, y, e, graph) {
14
+ return '<h3>' + key + '</h3>' +
15
+ '<p>' + y + ' at ' + x + '</p>'
16
+ },
17
+ noData = "No Data Available."
18
+ ;
19
+
20
+
21
+ var x = d3.fisheye.scale(d3.scale.linear).distortion(0);
22
+
23
+ var lines = nv.models.line().xScale(x),
24
+ //x = lines.xScale(),
25
+ y = lines.yScale(),
26
+ xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5),
27
+ yAxis = nv.models.axis().scale(y).orient('left'),
28
+ legend = nv.models.legend().height(30),
29
+ controls = nv.models.legend().height(30).updateState(false),
30
+ dispatch = d3.dispatch('tooltipShow', 'tooltipHide');
31
+
32
+
33
+ var showTooltip = function(e, offsetElement) {
34
+ var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
35
+ top = e.pos[1] + ( offsetElement.offsetTop || 0),
36
+ x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)),
37
+ y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)),
38
+ content = tooltip(e.series.key, x, y, e, chart);
39
+
40
+ nv.tooltip.show([left, top], content, null, null, offsetElement);
41
+ };
42
+
43
+
44
+ var controlsData = [
45
+ { key: 'Magnify', disabled: true }
46
+ ];
47
+
48
+
49
+ function chart(selection) {
50
+ selection.each(function(data) {
51
+ var container = d3.select(this),
52
+ that = this;
53
+
54
+ var availableWidth = (width || parseInt(container.style('width')) || 960)
55
+ - margin.left - margin.right,
56
+ availableHeight = (height || parseInt(container.style('height')) || 400)
57
+ - margin.top - margin.bottom;
58
+
59
+ chart.update = function() { container.transition().call(chart) };
60
+ chart.container = this; // I need a reference to the container in order to have outside code check if the chart is visible or not
61
+ //------------------------------------------------------------
62
+ // Display No Data message if there's nothing to show.
63
+
64
+ if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
65
+ container.append('text')
66
+ .attr('class', 'nvd3 nv-noData')
67
+ .attr('x', availableWidth / 2)
68
+ .attr('y', availableHeight / 2)
69
+ .attr('dy', '-.7em')
70
+ .style('text-anchor', 'middle')
71
+ .text(noData);
72
+ return chart;
73
+ } else {
74
+ container.select('.nv-noData').remove();
75
+ }
76
+
77
+ //------------------------------------------------------------
78
+
79
+
80
+
81
+ var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]);
82
+ var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g');
83
+
84
+
85
+ gEnter.append('rect')
86
+ .attr('class', 'nvd3 nv-background')
87
+ .attr('width', availableWidth)
88
+ .attr('height', availableHeight);
89
+
90
+
91
+ gEnter.append('g').attr('class', 'nv-x nv-axis');
92
+ gEnter.append('g').attr('class', 'nv-y nv-axis');
93
+ gEnter.append('g').attr('class', 'nv-linesWrap');
94
+ gEnter.append('g').attr('class', 'nv-legendWrap');
95
+ gEnter.append('g').attr('class', 'nv-controlsWrap');
96
+ gEnter.append('g').attr('class', 'nv-controlsWrap');
97
+
98
+
99
+ var g = wrap.select('g');
100
+
101
+
102
+
103
+
104
+ if (showLegend) {
105
+ legend.width(availableWidth);
106
+
107
+ g.select('.nv-legendWrap')
108
+ .datum(data)
109
+ .call(legend);
110
+
111
+ if ( margin.top != legend.height()) {
112
+ margin.top = legend.height();
113
+ availableHeight = (height || parseInt(container.style('height')) || 400)
114
+ - margin.top - margin.bottom;
115
+ }
116
+
117
+ g.select('.nv-legendWrap')
118
+ .attr('transform', 'translate(0,' + (-margin.top) +')')
119
+ }
120
+
121
+ if (showControls) {
122
+ controls.width(180).color(['#444']);
123
+ g.select('.nv-controlsWrap')
124
+ .datum(controlsData)
125
+ .attr('transform', 'translate(0,' + (-margin.top) +')')
126
+ .call(controls);
127
+ }
128
+
129
+
130
+
131
+ lines
132
+ .width(availableWidth)
133
+ .height(availableHeight)
134
+ .color(data.map(function(d,i) {
135
+ return d.color || color(d, i);
136
+ }).filter(function(d,i) { return !data[i].disabled }));
137
+
138
+
139
+
140
+ g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
141
+
142
+
143
+ var linesWrap = g.select('.nv-linesWrap')
144
+ .datum(data.filter(function(d) { return !d.disabled }))
145
+
146
+ d3.transition(linesWrap).call(lines);
147
+
148
+
149
+
150
+ xAxis
151
+ //.scale(x)
152
+ .ticks( availableWidth / 100 )
153
+ .tickSize(-availableHeight, 0);
154
+
155
+ g.select('.nv-x.nv-axis')
156
+ .attr('transform', 'translate(0,' + y.range()[0] + ')');
157
+ d3.transition(g.select('.nv-x.nv-axis'))
158
+ .call(xAxis);
159
+
160
+
161
+ yAxis
162
+ //.scale(y)
163
+ .ticks( availableHeight / 36 )
164
+ .tickSize( -availableWidth, 0);
165
+
166
+ d3.transition(g.select('.nv-y.nv-axis'))
167
+ .call(yAxis);
168
+
169
+
170
+
171
+ g.select('.nv-background').on('mousemove', updateFisheye);
172
+ g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye; });
173
+ //g.select('.point-paths').on('mousemove', updateFisheye);
174
+
175
+
176
+ function updateFisheye() {
177
+ if (pauseFisheye) {
178
+ //g.select('.background') .style('pointer-events', 'none');
179
+ g.select('.nv-point-paths').style('pointer-events', 'all');
180
+ return false;
181
+ }
182
+
183
+ g.select('.nv-background') .style('pointer-events', 'all');
184
+ g.select('.nv-point-paths').style('pointer-events', 'none' );
185
+
186
+ var mouse = d3.mouse(this);
187
+ linesWrap.call(lines);
188
+ g.select('.nv-x.nv-axis').call(xAxis);
189
+ x.distortion(fisheye).focus(mouse[0]);
190
+ }
191
+
192
+
193
+ controls.dispatch.on('legendClick', function(d,i) {
194
+ d.disabled = !d.disabled;
195
+
196
+ fisheye = d.disabled ? 0 : 5;
197
+ g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all');
198
+ g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' );
199
+
200
+ //scatter.interactive(d.disabled);
201
+ //tooltips = d.disabled;
202
+
203
+ if (d.disabled) {
204
+ x.distortion(fisheye).focus(0);
205
+
206
+ linesWrap.call(lines);
207
+ g.select('.nv-x.nv-axis').call(xAxis);
208
+ } else {
209
+ pauseFisheye = false;
210
+ }
211
+
212
+ chart.update();
213
+ });
214
+
215
+
216
+ legend.dispatch.on('stateChange', function(newState) {
217
+ chart.update();
218
+ });
219
+
220
+ lines.dispatch.on('elementMouseover.tooltip', function(e) {
221
+ e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
222
+ dispatch.tooltipShow(e);
223
+ });
224
+ if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above?
225
+
226
+ lines.dispatch.on('elementMouseout.tooltip', function(e) {
227
+ dispatch.tooltipHide(e);
228
+ });
229
+ if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup);
230
+
231
+ });
232
+
233
+ return chart;
234
+ }
235
+
236
+
237
+ chart.dispatch = dispatch;
238
+ chart.legend = legend;
239
+ chart.xAxis = xAxis;
240
+ chart.yAxis = yAxis;
241
+
242
+ d3.rebind(chart, lines, 'defined', 'x', 'y', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate');
243
+
244
+ chart.options = nv.utils.optionsFunc.bind(chart);
245
+
246
+ chart.margin = function(_) {
247
+ if (!arguments.length) return margin;
248
+ margin = _;
249
+ return chart;
250
+ };
251
+
252
+ chart.width = function(_) {
253
+ if (!arguments.length) return width;
254
+ width = _;
255
+ return chart;
256
+ };
257
+
258
+ chart.height = function(_) {
259
+ if (!arguments.length) return height;
260
+ height = _;
261
+ return chart;
262
+ };
263
+
264
+ chart.color = function(_) {
265
+ if (!arguments.length) return color;
266
+ color = nv.utils.getColor(_);
267
+ legend.color(color);
268
+ return chart;
269
+ };
270
+
271
+ chart.showLegend = function(_) {
272
+ if (!arguments.length) return showLegend;
273
+ showLegend = _;
274
+ return chart;
275
+ };
276
+
277
+ chart.tooltips = function(_) {
278
+ if (!arguments.length) return tooltips;
279
+ tooltips = _;
280
+ return chart;
281
+ };
282
+
283
+ chart.tooltipContent = function(_) {
284
+ if (!arguments.length) return tooltip;
285
+ tooltip = _;
286
+ return chart;
287
+ };
288
+
289
+ chart.noData = function(_) {
290
+ if (!arguments.length) return noData;
291
+ noData = _;
292
+ return chart;
293
+ };
294
+
295
+
296
+ return chart;
297
+ }