nvd3-rails 0.0.1 → 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/README.md +7 -71
  4. data/lib/nvd3/rails/version.rb +1 -1
  5. data/nvd3-rails.gemspec +3 -3
  6. metadata +8 -111
  7. data/vendor/assets/javascripts/nvd3/.git.sample/HEAD +0 -1
  8. data/vendor/assets/javascripts/nvd3/.git.sample/config +0 -13
  9. data/vendor/assets/javascripts/nvd3/.git.sample/description +0 -1
  10. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/applypatch-msg.sample +0 -15
  11. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/commit-msg.sample +0 -24
  12. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/post-update.sample +0 -8
  13. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-applypatch.sample +0 -14
  14. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-commit.sample +0 -50
  15. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-push.sample +0 -53
  16. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-rebase.sample +0 -169
  17. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/prepare-commit-msg.sample +0 -36
  18. data/vendor/assets/javascripts/nvd3/.git.sample/hooks/update.sample +0 -128
  19. data/vendor/assets/javascripts/nvd3/.git.sample/index +0 -0
  20. data/vendor/assets/javascripts/nvd3/.git.sample/info/exclude +0 -6
  21. data/vendor/assets/javascripts/nvd3/.git.sample/logs/HEAD +0 -1
  22. data/vendor/assets/javascripts/nvd3/.git.sample/logs/refs/heads/master +0 -1
  23. data/vendor/assets/javascripts/nvd3/.git.sample/logs/refs/remotes/origin/HEAD +0 -1
  24. data/vendor/assets/javascripts/nvd3/.git.sample/objects/pack/pack-babbb312d58dd7f03870b530a1b9a84c80918be3.idx +0 -0
  25. data/vendor/assets/javascripts/nvd3/.git.sample/objects/pack/pack-babbb312d58dd7f03870b530a1b9a84c80918be3.pack +0 -0
  26. data/vendor/assets/javascripts/nvd3/.git.sample/packed-refs +0 -5
  27. data/vendor/assets/javascripts/nvd3/.git.sample/refs/heads/master +0 -1
  28. data/vendor/assets/javascripts/nvd3/.git.sample/refs/remotes/origin/HEAD +0 -1
  29. data/vendor/assets/javascripts/nvd3/build.bat +0 -6
  30. data/vendor/assets/javascripts/nvd3/deprecated/bar.html +0 -198
  31. data/vendor/assets/javascripts/nvd3/deprecated/bar.js +0 -250
  32. data/vendor/assets/javascripts/nvd3/deprecated/charts/cumulativeLineChart.js +0 -174
  33. data/vendor/assets/javascripts/nvd3/deprecated/charts/discreteBarChart.js +0 -157
  34. data/vendor/assets/javascripts/nvd3/deprecated/charts/lineChart.js +0 -159
  35. data/vendor/assets/javascripts/nvd3/deprecated/charts/lineChartDaily.js +0 -168
  36. data/vendor/assets/javascripts/nvd3/deprecated/charts/stackedAreaChart.js +0 -177
  37. data/vendor/assets/javascripts/nvd3/deprecated/cumulativeLine.html +0 -171
  38. data/vendor/assets/javascripts/nvd3/deprecated/cumulativeLine.js +0 -334
  39. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarChartWithEnabledTooltip.html +0 -129
  40. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarChartWithEnabledTooltip.js +0 -222
  41. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarWithAxes.html +0 -172
  42. data/vendor/assets/javascripts/nvd3/deprecated/discreteBarWithAxes.js +0 -152
  43. data/vendor/assets/javascripts/nvd3/deprecated/lineChart-old.html +0 -83
  44. data/vendor/assets/javascripts/nvd3/deprecated/lineChartDaily.html +0 -109
  45. data/vendor/assets/javascripts/nvd3/deprecated/linePlusBar.html +0 -173
  46. data/vendor/assets/javascripts/nvd3/deprecated/linePlusBar.js +0 -250
  47. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFocus.html +0 -137
  48. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFocus.js +0 -354
  49. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFourAxes.html +0 -144
  50. data/vendor/assets/javascripts/nvd3/deprecated/lineWithFourAxes.js +0 -218
  51. data/vendor/assets/javascripts/nvd3/deprecated/lineWithLegend.html +0 -142
  52. data/vendor/assets/javascripts/nvd3/deprecated/lineWithLegend.js +0 -176
  53. data/vendor/assets/javascripts/nvd3/deprecated/monthendAxis.html +0 -99
  54. data/vendor/assets/javascripts/nvd3/deprecated/multiBarHorizontalWithLegend.html +0 -258
  55. data/vendor/assets/javascripts/nvd3/deprecated/multiBarHorizontalWithLegend.js +0 -226
  56. data/vendor/assets/javascripts/nvd3/deprecated/multiBarWithLegend.html +0 -162
  57. data/vendor/assets/javascripts/nvd3/deprecated/multiBarWithLegend.js +0 -249
  58. data/vendor/assets/javascripts/nvd3/deprecated/pie.js +0 -263
  59. data/vendor/assets/javascripts/nvd3/deprecated/scatterChart.html +0 -110
  60. data/vendor/assets/javascripts/nvd3/deprecated/scatterChart.js +0 -294
  61. data/vendor/assets/javascripts/nvd3/deprecated/scatterFisheyeChart.js +0 -418
  62. data/vendor/assets/javascripts/nvd3/deprecated/scatterWithLegend.html +0 -167
  63. data/vendor/assets/javascripts/nvd3/deprecated/scatterWithLegend.js +0 -261
  64. data/vendor/assets/javascripts/nvd3/deprecated/stackedArea.js +0 -286
  65. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaChart.html +0 -183
  66. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaChart_old.html +0 -137
  67. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaWithLegend.html +0 -222
  68. data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaWithLegend.js +0 -297
  69. data/vendor/assets/javascripts/nvd3/examples/bullet.html +0 -96
  70. data/vendor/assets/javascripts/nvd3/examples/bulletChart.html +0 -94
  71. data/vendor/assets/javascripts/nvd3/examples/crossfilter.html +0 -167
  72. data/vendor/assets/javascripts/nvd3/examples/crossfilterWithDimentions.html +0 -180
  73. data/vendor/assets/javascripts/nvd3/examples/crossfilterWithTables.html +0 -288
  74. data/vendor/assets/javascripts/nvd3/examples/cumulativeLineChart.html +0 -155
  75. data/vendor/assets/javascripts/nvd3/examples/discreteBarChart.html +0 -116
  76. data/vendor/assets/javascripts/nvd3/examples/dynamicTimeSeries.html +0 -148
  77. data/vendor/assets/javascripts/nvd3/examples/historicalBar.html +0 -157
  78. data/vendor/assets/javascripts/nvd3/examples/horizon.html +0 -163
  79. data/vendor/assets/javascripts/nvd3/examples/images/grey-minus.png +0 -0
  80. data/vendor/assets/javascripts/nvd3/examples/images/grey-plus.png +0 -0
  81. data/vendor/assets/javascripts/nvd3/examples/indentedtree.html +0 -126
  82. data/vendor/assets/javascripts/nvd3/examples/legend.html +0 -75
  83. data/vendor/assets/javascripts/nvd3/examples/line.html +0 -95
  84. data/vendor/assets/javascripts/nvd3/examples/lineChart.html +0 -112
  85. data/vendor/assets/javascripts/nvd3/examples/lineChartSVGResize.html +0 -151
  86. data/vendor/assets/javascripts/nvd3/examples/linePlusBarChart.html +0 -114
  87. data/vendor/assets/javascripts/nvd3/examples/linePlusBarWithFocusChart.html +0 -128
  88. data/vendor/assets/javascripts/nvd3/examples/lineTimeSeries.html +0 -142
  89. data/vendor/assets/javascripts/nvd3/examples/lineWithFisheyeChart.html +0 -101
  90. data/vendor/assets/javascripts/nvd3/examples/lineWithFocusChart.html +0 -87
  91. data/vendor/assets/javascripts/nvd3/examples/multiBar.html +0 -92
  92. data/vendor/assets/javascripts/nvd3/examples/multiBarChart.html +0 -93
  93. data/vendor/assets/javascripts/nvd3/examples/multiBarHorizontalChart.html +0 -388
  94. data/vendor/assets/javascripts/nvd3/examples/multiChart.html +0 -93
  95. data/vendor/assets/javascripts/nvd3/examples/nations.json +0 -1
  96. data/vendor/assets/javascripts/nvd3/examples/pie.html +0 -93
  97. data/vendor/assets/javascripts/nvd3/examples/pieChart.html +0 -114
  98. data/vendor/assets/javascripts/nvd3/examples/scatter.html +0 -95
  99. data/vendor/assets/javascripts/nvd3/examples/scatterChart.html +0 -115
  100. data/vendor/assets/javascripts/nvd3/examples/scatterPlusLineChart.html +0 -116
  101. data/vendor/assets/javascripts/nvd3/examples/sparkline.html +0 -62
  102. data/vendor/assets/javascripts/nvd3/examples/sparklinePlus.html +0 -67
  103. data/vendor/assets/javascripts/nvd3/examples/stackedArea.html +0 -155
  104. data/vendor/assets/javascripts/nvd3/examples/stackedAreaChart.html +0 -245
  105. data/vendor/assets/javascripts/nvd3/examples/stream_layers.js +0 -35
  106. data/vendor/assets/javascripts/nvd3/src/models/backup/bullet.js +0 -250
  107. data/vendor/assets/javascripts/nvd3/src/models/backup/bulletChart.js +0 -349
@@ -1,167 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
-
4
- <link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
5
-
6
- <style>
7
-
8
- body {
9
- overflow-y:scroll;
10
- }
11
-
12
- text {
13
- font: 12px sans-serif;
14
- }
15
-
16
- svg {
17
- display: block;
18
- }
19
-
20
- #chart1 svg {
21
- height: 500px;
22
- min-width: 100px;
23
- min-height: 100px;
24
- /*
25
- margin: 50px;
26
- Minimum height and width is a good idea to prevent negative SVG dimensions...
27
- For example width should be =< margin.left + margin.right + 1,
28
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
29
- */
30
- }
31
-
32
- </style>
33
- <body>
34
-
35
- <div id="chart">
36
- <svg style="height: 500px;"></svg>
37
- </div>
38
-
39
- <script src="../lib/d3.v2.js"></script>
40
- <script src="../lib/crossfilter.js"></script>
41
- <script src="../nv.d3.js"></script>
42
- <script src="../src/tooltip.js"></script>
43
- <script src="../src/utils.js"></script>
44
- <script src="../src/models/legend.js"></script>
45
- <script src="../src/models/axis.js"></script>
46
- <script src="../src/models/scatter.js"></script>
47
- <script src="../src/models/line.js"></script>
48
- <script src="../src/models/lineWithFocusChart.js"></script>
49
- <script src="stream_layers.js"></script>
50
- <script>
51
-
52
- extend = function(destination, source) {
53
- for (var property in source) {
54
- if (property in destination) {
55
- if ( typeof source[property] === "object" &&
56
- typeof destination[property] === "object") {
57
- destination[property] = extend(destination[property], source[property]);
58
- } else {
59
- continue;
60
- }
61
- } else {
62
- destination[property] = source[property];
63
- };
64
- }
65
- return destination;
66
- };
67
-
68
- nv.addGraph(function() {
69
- var chart = nv.models.lineWithFocusChart();
70
-
71
- chart.xAxis
72
- .tickFormat(d3.format(',f'));
73
- chart.x2Axis
74
- .tickFormat(d3.format(',f'));
75
-
76
- chart.yAxis
77
- .tickFormat(d3.format(',.2f'));
78
- chart.y2Axis
79
- .tickFormat(d3.format(',.2f'));
80
-
81
- var dimension = testCrossfilterData().data;
82
-
83
- var data = normalizeData(dimension.top(Infinity),
84
- [
85
- {
86
- name: 'Stream #1',
87
- key: 'stream1'
88
- },
89
- {
90
- name: 'Stream #2',
91
- key: 'stream2'
92
- },
93
- {
94
- name: 'Stream #3',
95
- key: 'stream3'
96
- }
97
- ], 'x');
98
-
99
- d3.select('#chart svg')
100
- .datum(data)
101
- .transition().duration(500)
102
- .call(chart);
103
-
104
- nv.utils.windowResize(chart.update);
105
-
106
- return chart;
107
- });
108
-
109
- function normalizeData(data, series, xAxis)
110
- {
111
- var sort = crossfilter.quicksort.by(function(d) { return d[xAxis]; });
112
- var sorted = sort(data, 0, data.length);
113
-
114
- var result = [];
115
-
116
- series.forEach(function(serie, index)
117
- {
118
- result.push({key: serie.name, values: [], color: serie.color});
119
- });
120
-
121
- data.forEach(function(data, dataIndex)
122
- {
123
- series.forEach(function(serie, serieIndex)
124
- {
125
- result[serieIndex].values.push({x: data[xAxis], y: data[serie.key]});
126
- });
127
- });
128
-
129
- return result;
130
- };
131
-
132
- function testCrossfilterData() {
133
- var data = crossfilter(testData());
134
-
135
- try
136
- {
137
- data.data = data.dimension(function(d) { return d.y; });
138
- } catch (e)
139
- {
140
- console.log(e.stack);
141
- }
142
-
143
- return data;
144
- }
145
-
146
- function testData() {
147
-
148
- var data1 = [];
149
- var data2 = [];
150
- var data3 = [];
151
-
152
- stream_layers(3,128,.1).map(function(layer, index) {
153
- layer.forEach(function(item, i) {
154
- var object = { x: item.x };
155
- object['stream' + (index + 1)] = item.y;
156
- eval('data' + (index + 1)).push(object);
157
- });
158
- });
159
-
160
- var data = extend(data1, data2);
161
- var result = extend(data, data3);
162
-
163
- return result;
164
- }
165
-
166
-
167
- </script>
@@ -1,180 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
-
4
- <link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
5
-
6
- <style>
7
-
8
- body {
9
- overflow-y:scroll;
10
- }
11
-
12
- text {
13
- font: 12px sans-serif;
14
- }
15
-
16
- svg {
17
- display: block;
18
- }
19
-
20
- #chart1 svg {
21
- height: 500px;
22
- min-width: 100px;
23
- min-height: 100px;
24
- /*
25
- margin: 50px;
26
- Minimum height and width is a good idea to prevent negative SVG dimensions...
27
- For example width should be =< margin.left + margin.right + 1,
28
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
29
- */
30
- }
31
-
32
- </style>
33
- <body>
34
-
35
- <div id="chart">
36
- <svg style="height: 500px;"></svg>
37
- </div>
38
-
39
- <script src="../lib/d3.v2.js"></script>
40
- <script src="../lib/crossfilter.js"></script>
41
- <script src="../nv.d3.js"></script>
42
- <script src="../src/tooltip.js"></script>
43
- <script src="../src/utils.js"></script>
44
- <script src="../src/models/legend.js"></script>
45
- <script src="../src/models/axis.js"></script>
46
- <script src="../src/models/scatter.js"></script>
47
- <script src="../src/models/line.js"></script>
48
- <script src="../src/models/lineWithFocusChart.js"></script>
49
- <script src="stream_layers.js"></script>
50
- <script>
51
-
52
- extend = function(destination, source) {
53
- for (var property in source) {
54
- if (property in destination) {
55
- if ( typeof source[property] === "object" &&
56
- typeof destination[property] === "object") {
57
- destination[property] = extend(destination[property], source[property]);
58
- } else {
59
- continue;
60
- }
61
- } else {
62
- destination[property] = source[property];
63
- };
64
- }
65
- return destination;
66
- };
67
-
68
- nv.addGraph(function() {
69
- var chart = nv.models.lineWithFocusChart();
70
-
71
- chart.xAxis
72
- .tickFormat(d3.format(',f'));
73
- chart.x2Axis
74
- .tickFormat(d3.format(',f'));
75
-
76
- chart.yAxis
77
- .tickFormat(d3.format(',.2f'));
78
- chart.y2Axis
79
- .tickFormat(d3.format(',.2f'));
80
-
81
- var rawData = testCrossfilterData();
82
- var data = normalizeData(rawData.datum,
83
- [
84
- {
85
- name: 'Stream #1',
86
- key: 'stream1'
87
- },
88
- {
89
- name: 'Stream #2',
90
- key: 'stream2'
91
- },
92
- {
93
- name: 'Stream #3',
94
- key: 'stream3'
95
- }
96
- ]);
97
-
98
- d3.select('#chart svg')
99
- .datum(data)
100
- .transition().duration(500)
101
- .call(chart);
102
-
103
- nv.utils.windowResize(chart.update);
104
-
105
- return chart;
106
- });
107
-
108
- function normalizeData(data, series)
109
- {
110
- var sort = crossfilter.quicksort.by(function(d) { return d.key; });
111
- var result = [];
112
-
113
- for (var i = 0; i < series.length; i++)
114
- {
115
- var seriesData = data.top(Infinity);
116
- var sorted = sort(seriesData, 0, seriesData.length);
117
- var values = [];
118
-
119
-
120
- seriesData.forEach(function(item, index)
121
- {
122
- values.push({x: item.key, y: item.value[series[i].key]});
123
- });
124
-
125
- result.push({key: series[i].name, values: values, color: series[i].color});
126
- };
127
-
128
- return result;
129
- };
130
-
131
- function testCrossfilterData() {
132
- var data = crossfilter(testData());
133
-
134
- try
135
- {
136
- data.data = data.dimension(function(d) { return d.x; });
137
- data.datum = data.data.group(function(d) { return d; });
138
- data.datum.reduce(function (p, v) {
139
- p.count++;
140
- p.stream1 += v.stream1;
141
- p.stream2 += v.stream2;
142
- p.stream3 += v.stream3;
143
- return p; },
144
- function (p, v) {
145
- p.count--;
146
- p.stream1 -= v.stream1;
147
- p.stream2 -= v.stream2;
148
- p.stream3 -= v.stream3;
149
- return p; },
150
- function () { return {count: 0, stream1: 0, stream2: 0, stream3: 0}; });
151
- } catch (e)
152
- {
153
- console.log(e.stack);
154
- }
155
-
156
- return data;
157
- }
158
-
159
- function testData() {
160
-
161
- var data1 = [];
162
- var data2 = [];
163
- var data3 = [];
164
-
165
- stream_layers(3,128,.1).map(function(layer, index) {
166
- layer.forEach(function(item, i) {
167
- var object = { x: item.x };
168
- object['stream' + (index + 1)] = item.y;
169
- eval('data' + (index + 1)).push(object);
170
- });
171
- });
172
-
173
- var data = extend(data1, data2);
174
- var result = extend(data, data3);
175
-
176
- return result;
177
- }
178
-
179
-
180
- </script>
@@ -1,288 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
-
4
- <link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
5
-
6
- <style>
7
-
8
- body {
9
- overflow-y:scroll;
10
- }
11
-
12
- text {
13
- font: 12px sans-serif;
14
- }
15
-
16
- svg {
17
- display: block;
18
- }
19
-
20
- #chart1 svg {
21
- height: 500px;
22
- min-width: 100px;
23
- min-height: 100px;
24
- /*
25
- margin: 50px;
26
- Minimum height and width is a good idea to prevent negative SVG dimensions...
27
- For example width should be =< margin.left + margin.right + 1,
28
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
29
- */
30
- }
31
-
32
- </style>
33
- <body>
34
-
35
- <div id="chart">
36
- <svg style="height: 500px;"></svg>
37
- </div>
38
- <div id="stream1" style="float: left; margin-left: 15px;">
39
- <div><h1>Stream #1</h1></div>
40
- </div>
41
- <div id="stream2" style="float: left; margin-left: 15px;">
42
- <div><h1>Stream #2</h1></div>
43
- </div>
44
- <div id="stream3" style="float: left; margin-left: 15px;">
45
- <div><h1>Stream #3</h1></div>
46
- </div>
47
-
48
- <script src="../lib/d3.v2.js"></script>
49
- <script src="../lib/crossfilter.js"></script>
50
- <script src="../nv.d3.js"></script>
51
- <script src="../src/tooltip.js"></script>
52
- <script src="../src/utils.js"></script>
53
- <script src="../src/models/legend.js"></script>
54
- <script src="../src/models/axis.js"></script>
55
- <script src="../src/models/scatter.js"></script>
56
- <script src="../src/models/line.js"></script>
57
- <script src="../src/models/lineWithFocusChart.js"></script>
58
- <script src="stream_layers.js"></script>
59
- <script>
60
-
61
- extend = function(destination, source) {
62
- for (var property in source) {
63
- if (property in destination) {
64
- if ( typeof source[property] === "object" &&
65
- typeof destination[property] === "object") {
66
- destination[property] = extend(destination[property], source[property]);
67
- } else {
68
- continue;
69
- }
70
- } else {
71
- destination[property] = source[property];
72
- };
73
- }
74
- return destination;
75
- };
76
-
77
- var rawData = testCrossfilterData();
78
-
79
- nv.addGraph(function() {
80
- var chart = nv.models.lineWithFocusChart();
81
-
82
- chart.xAxis
83
- .tickFormat(d3.format(',f'));
84
- chart.x2Axis
85
- .tickFormat(d3.format(',f'));
86
-
87
- chart.yAxis
88
- .tickFormat(d3.format(',.2f'));
89
- chart.y2Axis
90
- .tickFormat(d3.format(',.2f'));
91
-
92
- chart.dispatch.on('brush', click);
93
-
94
- var data = normalizeData(rawData.datum,
95
- [
96
- {
97
- name: 'Stream #1',
98
- key: 'stream1'
99
- },
100
- {
101
- name: 'Stream #2',
102
- key: 'stream2'
103
- },
104
- {
105
- name: 'Stream #3',
106
- key: 'stream3'
107
- }
108
- ]);
109
-
110
- d3.select('#chart svg')
111
- .datum(data)
112
- .transition().duration(500)
113
- .call(chart);
114
-
115
- nv.utils.windowResize(chart.update);
116
-
117
- return chart;
118
- });
119
-
120
- function click(e) {
121
- extent = e.extent;
122
-
123
- rawData.data.filter([extent[0], extent[1]]);
124
- streams("stream1");
125
- streams("stream2");
126
- streams("stream3");
127
- }
128
-
129
- function streams(key) {
130
- var topData = rawData.data.top(5);
131
-
132
- var stream = d3.select("div#" + key).selectAll(".stream-data")
133
- .data(topData, function(d) {
134
- return d.key;
135
- });
136
-
137
- stream
138
- .html(function(d) {
139
- return d[key];
140
- })
141
-
142
- stream.enter().append("div")
143
- .attr("class", "stream-data")
144
- .html(function(d) {
145
- return d[key];
146
- })
147
-
148
- stream.exit().remove();
149
-
150
- stream.order();
151
- }
152
-
153
- function normalizeData(data, series) {
154
- var sort = crossfilter.quicksort.by(function(d) { return d.key; });
155
- var result = [];
156
-
157
- for (var i = 0; i < series.length; i++) {
158
- var seriesData = data.top(Infinity);
159
- var sorted = sort(seriesData, 0, seriesData.length);
160
- var values = [];
161
-
162
- seriesData.forEach(function(item, index) {
163
- values.push({x: item.key, y: item.value[series[i].key]});
164
- });
165
-
166
- result.push({key: series[i].name, values: values, color: series[i].color});
167
- };
168
-
169
- return result;
170
- };
171
-
172
- function testCrossfilterData() {
173
- var data = crossfilter(testData());
174
-
175
- try {
176
- data.data = data.dimension(function(d) { return d.x; });
177
- data.datum = data.data.group(function(d) { return d; });
178
- data.datum.reduce(
179
- function (p, v) {
180
- p.count++;
181
- p.stream1 += v.stream1;
182
- p.stream2 += v.stream2;
183
- p.stream3 += v.stream3;
184
- return p;
185
- },
186
- function (p, v) {
187
- p.count--;
188
- p.stream1 -= v.stream1;
189
- p.stream2 -= v.stream2;
190
- p.stream3 -= v.stream3;
191
- return p;
192
- },
193
- function () {
194
- return {count: 0, stream1: 0, stream2: 0, stream3: 0};
195
- });
196
-
197
- data.stream1 = data.dimension(function(d) { return d.stream1; });
198
- data.stream1datum = data.data.group(function(d) { return d; });
199
- data.stream1datum.reduce(
200
- function (p, v) {
201
- p.count++;
202
- p.stream1 += v.stream1;
203
- p.stream2 += v.stream2;
204
- p.stream3 += v.stream3;
205
- return p;
206
- },
207
- function (p, v) {
208
- p.count--;
209
- p.stream1 -= v.stream1;
210
- p.stream2 -= v.stream2;
211
- p.stream3 -= v.stream3;
212
- return p;
213
- },
214
- function () {
215
- return {count: 0, stream1: 0, stream2: 0, stream3: 0};
216
- }
217
- );
218
-
219
- data.stream2 = data.dimension(function(d) { return d.stream2; });
220
- data.stream2datum = data.data.group(function(d) { return d; });
221
- data.stream2datum.reduce(
222
- function (p, v) {
223
- p.count++;
224
- p.stream1 += v.stream1;
225
- p.stream2 += v.stream2;
226
- p.stream3 += v.stream3;
227
- return p;
228
- },
229
- function (p, v) {
230
- p.count--;
231
- p.stream1 -= v.stream1;
232
- p.stream2 -= v.stream2;
233
- p.stream3 -= v.stream3;
234
- return p;
235
- },
236
- function () {
237
- return {count: 0, stream1: 0, stream2: 0, stream3: 0};
238
- }
239
- );
240
-
241
- data.stream3 = data.dimension(function(d) { return d.stream3; });
242
- data.stream3datum = data.data.group(function(d) { return d; });
243
- data.stream3datum.reduce(
244
- function (p, v) {
245
- p.count++;
246
- p.stream1 += v.stream1;
247
- p.stream2 += v.stream2;
248
- p.stream3 += v.stream3;
249
- return p; },
250
- function (p, v) {
251
- p.count--;
252
- p.stream1 -= v.stream1;
253
- p.stream2 -= v.stream2;
254
- p.stream3 -= v.stream3;
255
- return p;
256
- },
257
- function () {
258
- return {count: 0, stream1: 0, stream2: 0, stream3: 0};
259
- }
260
- );
261
- } catch (e) {
262
- nv.log(e.stack);
263
- }
264
-
265
- return data;
266
- }
267
-
268
- function testData() {
269
- var data1 = [];
270
- var data2 = [];
271
- var data3 = [];
272
-
273
- stream_layers(3,128,.1).map(function(layer, index) {
274
- layer.forEach(function(item, i) {
275
- var object = { x: item.x };
276
- object['stream' + (index + 1)] = item.y;
277
- eval('data' + (index + 1)).push(object);
278
- });
279
- });
280
-
281
- var data = extend(data1, data2);
282
- var result = extend(data, data3);
283
-
284
- return result;
285
- }
286
-
287
-
288
- </script>