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,194 @@
1
+
2
+ nv.models.sparkline = function() {
3
+ "use strict";
4
+ //============================================================
5
+ // Public Variables with Default Settings
6
+ //------------------------------------------------------------
7
+
8
+ var margin = {top: 2, right: 0, bottom: 2, left: 0}
9
+ , width = 400
10
+ , height = 32
11
+ , animate = true
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
+ , color = nv.utils.getColor(['#000'])
17
+ , xDomain
18
+ , yDomain
19
+ , xRange
20
+ , yRange
21
+ ;
22
+
23
+ //============================================================
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
+ container = d3.select(this);
31
+
32
+
33
+ //------------------------------------------------------------
34
+ // Setup Scales
35
+
36
+ x .domain(xDomain || d3.extent(data, getX ))
37
+ .range(xRange || [0, availableWidth]);
38
+
39
+ y .domain(yDomain || d3.extent(data, getY ))
40
+ .range(yRange || [availableHeight, 0]);
41
+
42
+ //------------------------------------------------------------
43
+
44
+
45
+ //------------------------------------------------------------
46
+ // Setup containers and skeleton of chart
47
+
48
+ var wrap = container.selectAll('g.nv-wrap.nv-sparkline').data([data]);
49
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparkline');
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 paths = wrap.selectAll('path')
59
+ .data(function(d) { return [d] });
60
+ paths.enter().append('path');
61
+ paths.exit().remove();
62
+ paths
63
+ .style('stroke', function(d,i) { return d.color || color(d, i) })
64
+ .attr('d', d3.svg.line()
65
+ .x(function(d,i) { return x(getX(d,i)) })
66
+ .y(function(d,i) { return y(getY(d,i)) })
67
+ );
68
+
69
+
70
+ // TODO: Add CURRENT data point (Need Min, Mac, Current / Most recent)
71
+ var points = wrap.selectAll('circle.nv-point')
72
+ .data(function(data) {
73
+ var yValues = data.map(function(d, i) { return getY(d,i); });
74
+ function pointIndex(index) {
75
+ if (index != -1) {
76
+ var result = data[index];
77
+ result.pointIndex = index;
78
+ return result;
79
+ } else {
80
+ return null;
81
+ }
82
+ }
83
+ var maxPoint = pointIndex(yValues.lastIndexOf(y.domain()[1])),
84
+ minPoint = pointIndex(yValues.indexOf(y.domain()[0])),
85
+ currentPoint = pointIndex(yValues.length - 1);
86
+ return [minPoint, maxPoint, currentPoint].filter(function (d) {return d != null;});
87
+ });
88
+ points.enter().append('circle');
89
+ points.exit().remove();
90
+ points
91
+ .attr('cx', function(d,i) { return x(getX(d,d.pointIndex)) })
92
+ .attr('cy', function(d,i) { return y(getY(d,d.pointIndex)) })
93
+ .attr('r', 2)
94
+ .attr('class', function(d,i) {
95
+ return getX(d, d.pointIndex) == x.domain()[1] ? 'nv-point nv-currentValue' :
96
+ getY(d, d.pointIndex) == y.domain()[0] ? 'nv-point nv-minValue' : 'nv-point nv-maxValue'
97
+ });
98
+ });
99
+
100
+ return chart;
101
+ }
102
+
103
+
104
+ //============================================================
105
+ // Expose Public Variables
106
+ //------------------------------------------------------------
107
+ chart.options = nv.utils.optionsFunc.bind(chart);
108
+
109
+ chart.margin = function(_) {
110
+ if (!arguments.length) return margin;
111
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
112
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
113
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
114
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
115
+ return chart;
116
+ };
117
+
118
+ chart.width = function(_) {
119
+ if (!arguments.length) return width;
120
+ width = _;
121
+ return chart;
122
+ };
123
+
124
+ chart.height = function(_) {
125
+ if (!arguments.length) return height;
126
+ height = _;
127
+ return chart;
128
+ };
129
+
130
+ chart.x = function(_) {
131
+ if (!arguments.length) return getX;
132
+ getX = d3.functor(_);
133
+ return chart;
134
+ };
135
+
136
+ chart.y = function(_) {
137
+ if (!arguments.length) return getY;
138
+ getY = d3.functor(_);
139
+ return chart;
140
+ };
141
+
142
+ chart.xScale = function(_) {
143
+ if (!arguments.length) return x;
144
+ x = _;
145
+ return chart;
146
+ };
147
+
148
+ chart.yScale = function(_) {
149
+ if (!arguments.length) return y;
150
+ y = _;
151
+ return chart;
152
+ };
153
+
154
+ chart.xDomain = function(_) {
155
+ if (!arguments.length) return xDomain;
156
+ xDomain = _;
157
+ return chart;
158
+ };
159
+
160
+ chart.yDomain = function(_) {
161
+ if (!arguments.length) return yDomain;
162
+ yDomain = _;
163
+ return chart;
164
+ };
165
+
166
+ chart.xRange = function(_) {
167
+ if (!arguments.length) return xRange;
168
+ xRange = _;
169
+ return chart;
170
+ };
171
+
172
+ chart.yRange = function(_) {
173
+ if (!arguments.length) return yRange;
174
+ yRange = _;
175
+ return chart;
176
+ };
177
+
178
+ chart.animate = function(_) {
179
+ if (!arguments.length) return animate;
180
+ animate = _;
181
+ return chart;
182
+ };
183
+
184
+ chart.color = function(_) {
185
+ if (!arguments.length) return color;
186
+ color = nv.utils.getColor(_);
187
+ return chart;
188
+ };
189
+
190
+ //============================================================
191
+
192
+
193
+ return chart;
194
+ }
@@ -0,0 +1,295 @@
1
+
2
+ nv.models.sparklinePlus = function() {
3
+ "use strict";
4
+ //============================================================
5
+ // Public Variables with Default Settings
6
+ //------------------------------------------------------------
7
+
8
+ var sparkline = nv.models.sparkline();
9
+
10
+ var margin = {top: 15, right: 100, bottom: 10, left: 50}
11
+ , width = null
12
+ , height = null
13
+ , x
14
+ , y
15
+ , index = []
16
+ , paused = false
17
+ , xTickFormat = d3.format(',r')
18
+ , yTickFormat = d3.format(',.2f')
19
+ , showValue = true
20
+ , alignValue = true
21
+ , rightAlignValue = false
22
+ , noData = "No Data Available."
23
+ ;
24
+
25
+ //============================================================
26
+
27
+
28
+ function chart(selection) {
29
+ selection.each(function(data) {
30
+ var container = d3.select(this);
31
+
32
+ var availableWidth = (width || parseInt(container.style('width')) || 960)
33
+ - margin.left - margin.right,
34
+ availableHeight = (height || parseInt(container.style('height')) || 400)
35
+ - margin.top - margin.bottom;
36
+
37
+
38
+
39
+ chart.update = function() { chart(selection) };
40
+ chart.container = this;
41
+
42
+
43
+ //------------------------------------------------------------
44
+ // Display No Data message if there's nothing to show.
45
+
46
+ if (!data || !data.length) {
47
+ var noDataText = container.selectAll('.nv-noData').data([noData]);
48
+
49
+ noDataText.enter().append('text')
50
+ .attr('class', 'nvd3 nv-noData')
51
+ .attr('dy', '-.7em')
52
+ .style('text-anchor', 'middle');
53
+
54
+ noDataText
55
+ .attr('x', margin.left + availableWidth / 2)
56
+ .attr('y', margin.top + availableHeight / 2)
57
+ .text(function(d) { return d });
58
+
59
+ return chart;
60
+ } else {
61
+ container.selectAll('.nv-noData').remove();
62
+ }
63
+
64
+ var currentValue = sparkline.y()(data[data.length-1], data.length-1);
65
+
66
+ //------------------------------------------------------------
67
+
68
+
69
+
70
+ //------------------------------------------------------------
71
+ // Setup Scales
72
+
73
+ x = sparkline.xScale();
74
+ y = sparkline.yScale();
75
+
76
+ //------------------------------------------------------------
77
+
78
+
79
+ //------------------------------------------------------------
80
+ // Setup containers and skeleton of chart
81
+
82
+ var wrap = container.selectAll('g.nv-wrap.nv-sparklineplus').data([data]);
83
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparklineplus');
84
+ var gEnter = wrapEnter.append('g');
85
+ var g = wrap.select('g');
86
+
87
+ gEnter.append('g').attr('class', 'nv-sparklineWrap');
88
+ gEnter.append('g').attr('class', 'nv-valueWrap');
89
+ gEnter.append('g').attr('class', 'nv-hoverArea');
90
+
91
+ wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
92
+
93
+ //------------------------------------------------------------
94
+
95
+
96
+ //------------------------------------------------------------
97
+ // Main Chart Component(s)
98
+
99
+ var sparklineWrap = g.select('.nv-sparklineWrap');
100
+
101
+ sparkline
102
+ .width(availableWidth)
103
+ .height(availableHeight);
104
+
105
+ sparklineWrap
106
+ .call(sparkline);
107
+
108
+ //------------------------------------------------------------
109
+
110
+
111
+ var valueWrap = g.select('.nv-valueWrap');
112
+
113
+ var value = valueWrap.selectAll('.nv-currentValue')
114
+ .data([currentValue]);
115
+
116
+ value.enter().append('text').attr('class', 'nv-currentValue')
117
+ .attr('dx', rightAlignValue ? -8 : 8)
118
+ .attr('dy', '.9em')
119
+ .style('text-anchor', rightAlignValue ? 'end' : 'start');
120
+
121
+ value
122
+ .attr('x', availableWidth + (rightAlignValue ? margin.right : 0))
123
+ .attr('y', alignValue ? function(d) { return y(d) } : 0)
124
+ .style('fill', sparkline.color()(data[data.length-1], data.length-1))
125
+ .text(yTickFormat(currentValue));
126
+
127
+
128
+
129
+ gEnter.select('.nv-hoverArea').append('rect')
130
+ .on('mousemove', sparklineHover)
131
+ .on('click', function() { paused = !paused })
132
+ .on('mouseout', function() { index = []; updateValueLine(); });
133
+ //.on('mouseout', function() { index = null; updateValueLine(); });
134
+
135
+ g.select('.nv-hoverArea rect')
136
+ .attr('transform', function(d) { return 'translate(' + -margin.left + ',' + -margin.top + ')' })
137
+ .attr('width', availableWidth + margin.left + margin.right)
138
+ .attr('height', availableHeight + margin.top);
139
+
140
+
141
+
142
+ function updateValueLine() { //index is currently global (within the chart), may or may not keep it that way
143
+ if (paused) return;
144
+
145
+ var hoverValue = g.selectAll('.nv-hoverValue').data(index)
146
+
147
+ var hoverEnter = hoverValue.enter()
148
+ .append('g').attr('class', 'nv-hoverValue')
149
+ .style('stroke-opacity', 0)
150
+ .style('fill-opacity', 0);
151
+
152
+ hoverValue.exit()
153
+ .transition().duration(250)
154
+ .style('stroke-opacity', 0)
155
+ .style('fill-opacity', 0)
156
+ .remove();
157
+
158
+ hoverValue
159
+ .attr('transform', function(d) { return 'translate(' + x(sparkline.x()(data[d],d)) + ',0)' })
160
+ .transition().duration(250)
161
+ .style('stroke-opacity', 1)
162
+ .style('fill-opacity', 1);
163
+
164
+ if (!index.length) return;
165
+
166
+ hoverEnter.append('line')
167
+ .attr('x1', 0)
168
+ .attr('y1', -margin.top)
169
+ .attr('x2', 0)
170
+ .attr('y2', availableHeight);
171
+
172
+
173
+ hoverEnter.append('text').attr('class', 'nv-xValue')
174
+ .attr('x', -6)
175
+ .attr('y', -margin.top)
176
+ .attr('text-anchor', 'end')
177
+ .attr('dy', '.9em')
178
+
179
+
180
+ g.select('.nv-hoverValue .nv-xValue')
181
+ .text(xTickFormat(sparkline.x()(data[index[0]], index[0])));
182
+
183
+ hoverEnter.append('text').attr('class', 'nv-yValue')
184
+ .attr('x', 6)
185
+ .attr('y', -margin.top)
186
+ .attr('text-anchor', 'start')
187
+ .attr('dy', '.9em')
188
+
189
+ g.select('.nv-hoverValue .nv-yValue')
190
+ .text(yTickFormat(sparkline.y()(data[index[0]], index[0])));
191
+
192
+ }
193
+
194
+
195
+ function sparklineHover() {
196
+ if (paused) return;
197
+
198
+ var pos = d3.mouse(this)[0] - margin.left;
199
+
200
+ function getClosestIndex(data, x) {
201
+ var distance = Math.abs(sparkline.x()(data[0], 0) - x);
202
+ var closestIndex = 0;
203
+ for (var i = 0; i < data.length; i++){
204
+ if (Math.abs(sparkline.x()(data[i], i) - x) < distance) {
205
+ distance = Math.abs(sparkline.x()(data[i], i) - x);
206
+ closestIndex = i;
207
+ }
208
+ }
209
+ return closestIndex;
210
+ }
211
+
212
+ index = [getClosestIndex(data, Math.round(x.invert(pos)))];
213
+
214
+ updateValueLine();
215
+ }
216
+
217
+ });
218
+
219
+ return chart;
220
+ }
221
+
222
+
223
+ //============================================================
224
+ // Expose Public Variables
225
+ //------------------------------------------------------------
226
+
227
+ // expose chart's sub-components
228
+ chart.sparkline = sparkline;
229
+
230
+ d3.rebind(chart, sparkline, 'x', 'y', 'xScale', 'yScale', 'color');
231
+
232
+ chart.options = nv.utils.optionsFunc.bind(chart);
233
+
234
+ chart.margin = function(_) {
235
+ if (!arguments.length) return margin;
236
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
237
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
238
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
239
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
240
+ return chart;
241
+ };
242
+
243
+ chart.width = function(_) {
244
+ if (!arguments.length) return width;
245
+ width = _;
246
+ return chart;
247
+ };
248
+
249
+ chart.height = function(_) {
250
+ if (!arguments.length) return height;
251
+ height = _;
252
+ return chart;
253
+ };
254
+
255
+ chart.xTickFormat = function(_) {
256
+ if (!arguments.length) return xTickFormat;
257
+ xTickFormat = _;
258
+ return chart;
259
+ };
260
+
261
+ chart.yTickFormat = function(_) {
262
+ if (!arguments.length) return yTickFormat;
263
+ yTickFormat = _;
264
+ return chart;
265
+ };
266
+
267
+ chart.showValue = function(_) {
268
+ if (!arguments.length) return showValue;
269
+ showValue = _;
270
+ return chart;
271
+ };
272
+
273
+ chart.alignValue = function(_) {
274
+ if (!arguments.length) return alignValue;
275
+ alignValue = _;
276
+ return chart;
277
+ };
278
+
279
+ chart.rightAlignValue = function(_) {
280
+ if (!arguments.length) return rightAlignValue;
281
+ rightAlignValue = _;
282
+ return chart;
283
+ };
284
+
285
+ chart.noData = function(_) {
286
+ if (!arguments.length) return noData;
287
+ noData = _;
288
+ return chart;
289
+ };
290
+
291
+ //============================================================
292
+
293
+
294
+ return chart;
295
+ }