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,349 @@
1
+ //TODO: consider deprecating by adding necessary features to multiBar model
2
+ nv.models.discreteBar = 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.ordinal()
13
+ , y = d3.scale.linear()
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
+ , color = nv.utils.defaultColor()
18
+ , showValues = false
19
+ , valueFormat = d3.format(',.2f')
20
+ , xDomain
21
+ , yDomain
22
+ , xRange
23
+ , yRange
24
+ , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout')
25
+ , rectClass = 'discreteBar'
26
+ ;
27
+
28
+ //============================================================
29
+
30
+
31
+ //============================================================
32
+ // Private Variables
33
+ //------------------------------------------------------------
34
+
35
+ var x0, y0;
36
+
37
+ //============================================================
38
+
39
+
40
+ function chart(selection) {
41
+ selection.each(function(data) {
42
+ var availableWidth = width - margin.left - margin.right,
43
+ availableHeight = height - margin.top - margin.bottom,
44
+ container = d3.select(this);
45
+
46
+
47
+ //add series index to each data point for reference
48
+ data.forEach(function(series, i) {
49
+ series.values.forEach(function(point) {
50
+ point.series = i;
51
+ });
52
+ });
53
+
54
+
55
+ //------------------------------------------------------------
56
+ // Setup Scales
57
+
58
+ // remap and flatten the data for use in calculating the scales' domains
59
+ var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate
60
+ data.map(function(d) {
61
+ return d.values.map(function(d,i) {
62
+ return { x: getX(d,i), y: getY(d,i), y0: d.y0 }
63
+ })
64
+ });
65
+
66
+ x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x }))
67
+ .rangeBands(xRange || [0, availableWidth], .1);
68
+
69
+ y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY)));
70
+
71
+
72
+ // If showValues, pad the Y axis range to account for label height
73
+ if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]);
74
+ else y.range(yRange || [availableHeight, 0]);
75
+
76
+ //store old scales if they exist
77
+ x0 = x0 || x;
78
+ y0 = y0 || y.copy().range([y(0),y(0)]);
79
+
80
+ //------------------------------------------------------------
81
+
82
+
83
+ //------------------------------------------------------------
84
+ // Setup containers and skeleton of chart
85
+
86
+ var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]);
87
+ var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar');
88
+ var gEnter = wrapEnter.append('g');
89
+ var g = wrap.select('g');
90
+
91
+ gEnter.append('g').attr('class', 'nv-groups');
92
+
93
+ wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
94
+
95
+ //------------------------------------------------------------
96
+
97
+
98
+
99
+ //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later
100
+ var groups = wrap.select('.nv-groups').selectAll('.nv-group')
101
+ .data(function(d) { return d }, function(d) { return d.key });
102
+ groups.enter().append('g')
103
+ .style('stroke-opacity', 1e-6)
104
+ .style('fill-opacity', 1e-6);
105
+ groups.exit()
106
+ .transition()
107
+ .style('stroke-opacity', 1e-6)
108
+ .style('fill-opacity', 1e-6)
109
+ .remove();
110
+ groups
111
+ .attr('class', function(d,i) { return 'nv-group nv-series-' + i })
112
+ .classed('hover', function(d) { return d.hover });
113
+ groups
114
+ .transition()
115
+ .style('stroke-opacity', 1)
116
+ .style('fill-opacity', .75);
117
+
118
+
119
+ var bars = groups.selectAll('g.nv-bar')
120
+ .data(function(d) { return d.values });
121
+
122
+ bars.exit().remove();
123
+
124
+
125
+ var barsEnter = bars.enter().append('g')
126
+ .attr('transform', function(d,i,j) {
127
+ return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')'
128
+ })
129
+ .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here
130
+ d3.select(this).classed('hover', true);
131
+ dispatch.elementMouseover({
132
+ value: getY(d,i),
133
+ point: d,
134
+ series: data[d.series],
135
+ pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
136
+ pointIndex: i,
137
+ seriesIndex: d.series,
138
+ e: d3.event
139
+ });
140
+ })
141
+ .on('mouseout', function(d,i) {
142
+ d3.select(this).classed('hover', false);
143
+ dispatch.elementMouseout({
144
+ value: getY(d,i),
145
+ point: d,
146
+ series: data[d.series],
147
+ pointIndex: i,
148
+ seriesIndex: d.series,
149
+ e: d3.event
150
+ });
151
+ })
152
+ .on('click', function(d,i) {
153
+ dispatch.elementClick({
154
+ value: getY(d,i),
155
+ point: d,
156
+ series: data[d.series],
157
+ pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
158
+ pointIndex: i,
159
+ seriesIndex: d.series,
160
+ e: d3.event
161
+ });
162
+ d3.event.stopPropagation();
163
+ })
164
+ .on('dblclick', function(d,i) {
165
+ dispatch.elementDblClick({
166
+ value: getY(d,i),
167
+ point: d,
168
+ series: data[d.series],
169
+ pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted
170
+ pointIndex: i,
171
+ seriesIndex: d.series,
172
+ e: d3.event
173
+ });
174
+ d3.event.stopPropagation();
175
+ });
176
+
177
+ barsEnter.append('rect')
178
+ .attr('height', 0)
179
+ .attr('width', x.rangeBand() * .9 / data.length )
180
+
181
+ if (showValues) {
182
+ barsEnter.append('text')
183
+ .attr('text-anchor', 'middle')
184
+ ;
185
+
186
+ bars.select('text')
187
+ .text(function(d,i) { return valueFormat(getY(d,i)) })
188
+ .transition()
189
+ .attr('x', x.rangeBand() * .9 / 2)
190
+ .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 })
191
+
192
+ ;
193
+ } else {
194
+ bars.selectAll('text').remove();
195
+ }
196
+
197
+ bars
198
+ .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' })
199
+ .style('fill', function(d,i) { return d.color || color(d,i) })
200
+ .style('stroke', function(d,i) { return d.color || color(d,i) })
201
+ .select('rect')
202
+ .attr('class', rectClass)
203
+ .transition()
204
+ .attr('width', x.rangeBand() * .9 / data.length);
205
+ bars.transition()
206
+ //.delay(function(d,i) { return i * 1200 / data[0].values.length })
207
+ .attr('transform', function(d,i) {
208
+ var left = x(getX(d,i)) + x.rangeBand() * .05,
209
+ top = getY(d,i) < 0 ?
210
+ y(0) :
211
+ y(0) - y(getY(d,i)) < 1 ?
212
+ y(0) - 1 : //make 1 px positive bars show up above y=0
213
+ y(getY(d,i));
214
+
215
+ return 'translate(' + left + ', ' + top + ')'
216
+ })
217
+ .select('rect')
218
+ .attr('height', function(d,i) {
219
+ return Math.max(Math.abs(y(getY(d,i)) - y((yDomain && yDomain[0]) || 0)) || 1)
220
+ });
221
+
222
+
223
+ //store old scales for use in transitions on update
224
+ x0 = x.copy();
225
+ y0 = y.copy();
226
+
227
+ });
228
+
229
+ return chart;
230
+ }
231
+
232
+
233
+ //============================================================
234
+ // Expose Public Variables
235
+ //------------------------------------------------------------
236
+
237
+ chart.dispatch = dispatch;
238
+
239
+ chart.options = nv.utils.optionsFunc.bind(chart);
240
+
241
+ chart.x = function(_) {
242
+ if (!arguments.length) return getX;
243
+ getX = _;
244
+ return chart;
245
+ };
246
+
247
+ chart.y = function(_) {
248
+ if (!arguments.length) return getY;
249
+ getY = _;
250
+ return chart;
251
+ };
252
+
253
+ chart.margin = function(_) {
254
+ if (!arguments.length) return margin;
255
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
256
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
257
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
258
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
259
+ return chart;
260
+ };
261
+
262
+ chart.width = function(_) {
263
+ if (!arguments.length) return width;
264
+ width = _;
265
+ return chart;
266
+ };
267
+
268
+ chart.height = function(_) {
269
+ if (!arguments.length) return height;
270
+ height = _;
271
+ return chart;
272
+ };
273
+
274
+ chart.xScale = function(_) {
275
+ if (!arguments.length) return x;
276
+ x = _;
277
+ return chart;
278
+ };
279
+
280
+ chart.yScale = function(_) {
281
+ if (!arguments.length) return y;
282
+ y = _;
283
+ return chart;
284
+ };
285
+
286
+ chart.xDomain = function(_) {
287
+ if (!arguments.length) return xDomain;
288
+ xDomain = _;
289
+ return chart;
290
+ };
291
+
292
+ chart.yDomain = function(_) {
293
+ if (!arguments.length) return yDomain;
294
+ yDomain = _;
295
+ return chart;
296
+ };
297
+
298
+ chart.xRange = function(_) {
299
+ if (!arguments.length) return xRange;
300
+ xRange = _;
301
+ return chart;
302
+ };
303
+
304
+ chart.yRange = function(_) {
305
+ if (!arguments.length) return yRange;
306
+ yRange = _;
307
+ return chart;
308
+ };
309
+
310
+ chart.forceY = function(_) {
311
+ if (!arguments.length) return forceY;
312
+ forceY = _;
313
+ return chart;
314
+ };
315
+
316
+ chart.color = function(_) {
317
+ if (!arguments.length) return color;
318
+ color = nv.utils.getColor(_);
319
+ return chart;
320
+ };
321
+
322
+ chart.id = function(_) {
323
+ if (!arguments.length) return id;
324
+ id = _;
325
+ return chart;
326
+ };
327
+
328
+ chart.showValues = function(_) {
329
+ if (!arguments.length) return showValues;
330
+ showValues = _;
331
+ return chart;
332
+ };
333
+
334
+ chart.valueFormat= function(_) {
335
+ if (!arguments.length) return valueFormat;
336
+ valueFormat = _;
337
+ return chart;
338
+ };
339
+
340
+ chart.rectClass= function(_) {
341
+ if (!arguments.length) return rectClass;
342
+ rectClass = _;
343
+ return chart;
344
+ };
345
+ //============================================================
346
+
347
+
348
+ return chart;
349
+ }
@@ -0,0 +1,333 @@
1
+
2
+ nv.models.discreteBarChart = function() {
3
+ "use strict";
4
+ //============================================================
5
+ // Public Variables with Default Settings
6
+ //------------------------------------------------------------
7
+
8
+ var discretebar = nv.models.discreteBar()
9
+ , xAxis = nv.models.axis()
10
+ , yAxis = nv.models.axis()
11
+ ;
12
+
13
+ var margin = {top: 15, right: 10, bottom: 50, left: 60}
14
+ , width = null
15
+ , height = null
16
+ , color = nv.utils.getColor()
17
+ , showXAxis = true
18
+ , showYAxis = true
19
+ , rightAlignYAxis = false
20
+ , staggerLabels = false
21
+ , tooltips = true
22
+ , tooltip = function(key, x, y, e, graph) {
23
+ return '<h3>' + x + '</h3>' +
24
+ '<p>' + y + '</p>'
25
+ }
26
+ , x
27
+ , y
28
+ , noData = "No Data Available."
29
+ , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate')
30
+ , transitionDuration = 250
31
+ ;
32
+
33
+ xAxis
34
+ .orient('bottom')
35
+ .highlightZero(false)
36
+ .showMaxMin(false)
37
+ .tickFormat(function(d) { return d })
38
+ ;
39
+ yAxis
40
+ .orient((rightAlignYAxis) ? 'right' : 'left')
41
+ .tickFormat(d3.format(',.1f'))
42
+ ;
43
+
44
+ //============================================================
45
+
46
+
47
+ //============================================================
48
+ // Private Variables
49
+ //------------------------------------------------------------
50
+
51
+ var showTooltip = function(e, offsetElement) {
52
+ var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ),
53
+ top = e.pos[1] + ( offsetElement.offsetTop || 0),
54
+ x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)),
55
+ y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)),
56
+ content = tooltip(e.series.key, x, y, e, chart);
57
+
58
+ nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement);
59
+ };
60
+
61
+ //============================================================
62
+
63
+
64
+ function chart(selection) {
65
+ selection.each(function(data) {
66
+ var container = d3.select(this),
67
+ that = this;
68
+
69
+ var availableWidth = (width || parseInt(container.style('width')) || 960)
70
+ - margin.left - margin.right,
71
+ availableHeight = (height || parseInt(container.style('height')) || 400)
72
+ - margin.top - margin.bottom;
73
+
74
+
75
+ chart.update = function() {
76
+ dispatch.beforeUpdate();
77
+ container.transition().duration(transitionDuration).call(chart);
78
+ };
79
+ chart.container = this;
80
+
81
+
82
+ //------------------------------------------------------------
83
+ // Display No Data message if there's nothing to show.
84
+
85
+ if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
86
+ var noDataText = container.selectAll('.nv-noData').data([noData]);
87
+
88
+ noDataText.enter().append('text')
89
+ .attr('class', 'nvd3 nv-noData')
90
+ .attr('dy', '-.7em')
91
+ .style('text-anchor', 'middle');
92
+
93
+ noDataText
94
+ .attr('x', margin.left + availableWidth / 2)
95
+ .attr('y', margin.top + availableHeight / 2)
96
+ .text(function(d) { return d });
97
+
98
+ return chart;
99
+ } else {
100
+ container.selectAll('.nv-noData').remove();
101
+ }
102
+
103
+ //------------------------------------------------------------
104
+
105
+
106
+ //------------------------------------------------------------
107
+ // Setup Scales
108
+
109
+ x = discretebar.xScale();
110
+ y = discretebar.yScale().clamp(true);
111
+
112
+ //------------------------------------------------------------
113
+
114
+
115
+ //------------------------------------------------------------
116
+ // Setup containers and skeleton of chart
117
+
118
+ var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]);
119
+ var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g');
120
+ var defsEnter = gEnter.append('defs');
121
+ var g = wrap.select('g');
122
+
123
+ gEnter.append('g').attr('class', 'nv-x nv-axis');
124
+ gEnter.append('g').attr('class', 'nv-y nv-axis');
125
+ gEnter.append('g').attr('class', 'nv-barsWrap');
126
+
127
+ g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
128
+
129
+ if (rightAlignYAxis) {
130
+ g.select(".nv-y.nv-axis")
131
+ .attr("transform", "translate(" + availableWidth + ",0)");
132
+ }
133
+
134
+ //------------------------------------------------------------
135
+
136
+
137
+ //------------------------------------------------------------
138
+ // Main Chart Component(s)
139
+
140
+ discretebar
141
+ .width(availableWidth)
142
+ .height(availableHeight);
143
+
144
+
145
+ var barsWrap = g.select('.nv-barsWrap')
146
+ .datum(data.filter(function(d) { return !d.disabled }))
147
+
148
+ barsWrap.transition().call(discretebar);
149
+
150
+ //------------------------------------------------------------
151
+
152
+
153
+
154
+ defsEnter.append('clipPath')
155
+ .attr('id', 'nv-x-label-clip-' + discretebar.id())
156
+ .append('rect');
157
+
158
+ g.select('#nv-x-label-clip-' + discretebar.id() + ' rect')
159
+ .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1))
160
+ .attr('height', 16)
161
+ .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 ));
162
+
163
+
164
+ //------------------------------------------------------------
165
+ // Setup Axes
166
+
167
+ if (showXAxis) {
168
+ xAxis
169
+ .scale(x)
170
+ .ticks( availableWidth / 100 )
171
+ .tickSize(-availableHeight, 0);
172
+
173
+ g.select('.nv-x.nv-axis')
174
+ .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')');
175
+ //d3.transition(g.select('.nv-x.nv-axis'))
176
+ g.select('.nv-x.nv-axis').transition()
177
+ .call(xAxis);
178
+
179
+
180
+ var xTicks = g.select('.nv-x.nv-axis').selectAll('g');
181
+
182
+ if (staggerLabels) {
183
+ xTicks
184
+ .selectAll('text')
185
+ .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' })
186
+ }
187
+ }
188
+
189
+ if (showYAxis) {
190
+ yAxis
191
+ .scale(y)
192
+ .ticks( availableHeight / 36 )
193
+ .tickSize( -availableWidth, 0);
194
+
195
+ g.select('.nv-y.nv-axis').transition()
196
+ .call(yAxis);
197
+ }
198
+
199
+ //------------------------------------------------------------
200
+
201
+
202
+ //============================================================
203
+ // Event Handling/Dispatching (in chart's scope)
204
+ //------------------------------------------------------------
205
+
206
+ dispatch.on('tooltipShow', function(e) {
207
+ if (tooltips) showTooltip(e, that.parentNode);
208
+ });
209
+
210
+ //============================================================
211
+
212
+
213
+ });
214
+
215
+ return chart;
216
+ }
217
+
218
+ //============================================================
219
+ // Event Handling/Dispatching (out of chart's scope)
220
+ //------------------------------------------------------------
221
+
222
+ discretebar.dispatch.on('elementMouseover.tooltip', function(e) {
223
+ e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
224
+ dispatch.tooltipShow(e);
225
+ });
226
+
227
+ discretebar.dispatch.on('elementMouseout.tooltip', function(e) {
228
+ dispatch.tooltipHide(e);
229
+ });
230
+
231
+ dispatch.on('tooltipHide', function() {
232
+ if (tooltips) nv.tooltip.cleanup();
233
+ });
234
+
235
+ //============================================================
236
+
237
+
238
+ //============================================================
239
+ // Expose Public Variables
240
+ //------------------------------------------------------------
241
+
242
+ // expose chart's sub-components
243
+ chart.dispatch = dispatch;
244
+ chart.discretebar = discretebar;
245
+ chart.xAxis = xAxis;
246
+ chart.yAxis = yAxis;
247
+
248
+ d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat');
249
+
250
+ chart.options = nv.utils.optionsFunc.bind(chart);
251
+
252
+ chart.margin = function(_) {
253
+ if (!arguments.length) return margin;
254
+ margin.top = typeof _.top != 'undefined' ? _.top : margin.top;
255
+ margin.right = typeof _.right != 'undefined' ? _.right : margin.right;
256
+ margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom;
257
+ margin.left = typeof _.left != 'undefined' ? _.left : margin.left;
258
+ return chart;
259
+ };
260
+
261
+ chart.width = function(_) {
262
+ if (!arguments.length) return width;
263
+ width = _;
264
+ return chart;
265
+ };
266
+
267
+ chart.height = function(_) {
268
+ if (!arguments.length) return height;
269
+ height = _;
270
+ return chart;
271
+ };
272
+
273
+ chart.color = function(_) {
274
+ if (!arguments.length) return color;
275
+ color = nv.utils.getColor(_);
276
+ discretebar.color(color);
277
+ return chart;
278
+ };
279
+
280
+ chart.showXAxis = function(_) {
281
+ if (!arguments.length) return showXAxis;
282
+ showXAxis = _;
283
+ return chart;
284
+ };
285
+
286
+ chart.showYAxis = function(_) {
287
+ if (!arguments.length) return showYAxis;
288
+ showYAxis = _;
289
+ return chart;
290
+ };
291
+
292
+ chart.rightAlignYAxis = function(_) {
293
+ if(!arguments.length) return rightAlignYAxis;
294
+ rightAlignYAxis = _;
295
+ yAxis.orient( (_) ? 'right' : 'left');
296
+ return chart;
297
+ };
298
+
299
+ chart.staggerLabels = function(_) {
300
+ if (!arguments.length) return staggerLabels;
301
+ staggerLabels = _;
302
+ return chart;
303
+ };
304
+
305
+ chart.tooltips = function(_) {
306
+ if (!arguments.length) return tooltips;
307
+ tooltips = _;
308
+ return chart;
309
+ };
310
+
311
+ chart.tooltipContent = function(_) {
312
+ if (!arguments.length) return tooltip;
313
+ tooltip = _;
314
+ return chart;
315
+ };
316
+
317
+ chart.noData = function(_) {
318
+ if (!arguments.length) return noData;
319
+ noData = _;
320
+ return chart;
321
+ };
322
+
323
+ chart.transitionDuration = function(_) {
324
+ if (!arguments.length) return transitionDuration;
325
+ transitionDuration = _;
326
+ return chart;
327
+ };
328
+
329
+ //============================================================
330
+
331
+
332
+ return chart;
333
+ }