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,176 +0,0 @@
1
-
2
- nv.models.lineWithLegend = function() {
3
- var margin = {top: 30, right: 20, bottom: 50, left: 60},
4
- color = d3.scale.category20().range(),
5
- width, height;
6
-
7
- var lines = nv.models.line(),
8
- //x = d3.scale.linear(),
9
- //y = d3.scale.linear(),
10
- x = lines.xScale(),
11
- y = lines.yScale(),
12
- xAxis = nv.models.axis().scale(x).orient('bottom'),
13
- yAxis = nv.models.axis().scale(y).orient('left'),
14
- legend = nv.models.legend().height(30),
15
- dispatch = d3.dispatch('tooltipShow', 'tooltipHide');
16
-
17
-
18
- function chart(selection) {
19
- selection.each(function(data) {
20
-
21
- var availableWidth = (width || parseInt(d3.select(this).style('width')) || 960)
22
- - margin.left - margin.right,
23
- availableHeight = (height || parseInt(d3.select(this).style('height')) || 400)
24
- - margin.top - margin.bottom;
25
-
26
-
27
- lines
28
- .width(availableWidth)
29
- .height(availableHeight)
30
- .color(data.map(function(d,i) {
31
- return d.color || color[i % 10];
32
- }).filter(function(d,i) { return !data[i].disabled }));
33
-
34
-
35
- var wrap = d3.select(this).selectAll('g.wrap.lineWithLegend').data([data]);
36
- var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithLegend').append('g');
37
-
38
- gEnter.append('g').attr('class', 'x axis');
39
- gEnter.append('g').attr('class', 'y axis');
40
- gEnter.append('g').attr('class', 'linesWrap');
41
- gEnter.append('g').attr('class', 'legendWrap');
42
-
43
-
44
-
45
- //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend
46
- margin.top = legend.height();
47
-
48
- var g = wrap.select('g')
49
- .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
50
-
51
-
52
-
53
- legend.width(availableWidth / 2);
54
-
55
- g.select('.legendWrap')
56
- .datum(data)
57
- .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')')
58
- .call(legend);
59
-
60
-
61
-
62
- var linesWrap = g.select('.linesWrap')
63
- .datum(data.filter(function(d) { return !d.disabled }))
64
-
65
- d3.transition(linesWrap).call(lines);
66
-
67
-
68
-
69
- xAxis
70
- .domain(x.domain())
71
- .range(x.range())
72
- .ticks( availableWidth / 100 )
73
- .tickSize(-availableHeight, 0);
74
-
75
- g.select('.x.axis')
76
- .attr('transform', 'translate(0,' + y.range()[0] + ')');
77
- d3.transition(g.select('.x.axis'))
78
- .call(xAxis);
79
-
80
-
81
- yAxis
82
- .domain(y.domain())
83
- .range(y.range())
84
- .ticks( availableHeight / 36 )
85
- .tickSize( -availableWidth, 0);
86
-
87
- d3.transition(g.select('.y.axis'))
88
- .call(yAxis);
89
-
90
-
91
-
92
-
93
- legend.dispatch.on('legendClick', function(d,i) {
94
- d.disabled = !d.disabled;
95
-
96
- if (!data.filter(function(d) { return !d.disabled }).length) {
97
- data.map(function(d) {
98
- d.disabled = false;
99
- wrap.selectAll('.series').classed('disabled', false);
100
- return d;
101
- });
102
- }
103
-
104
- selection.transition().call(chart);
105
- });
106
-
107
- /*
108
- //
109
- legend.dispatch.on('legendMouseover', function(d, i) {
110
- d.hover = true;
111
- selection.transition().call(chart)
112
- });
113
-
114
- legend.dispatch.on('legendMouseout', function(d, i) {
115
- d.hover = false;
116
- selection.transition().call(chart)
117
- });
118
- */
119
-
120
- lines.dispatch.on('elementMouseover.tooltip', function(e) {
121
- dispatch.tooltipShow({
122
- point: e.point,
123
- series: e.series,
124
- pos: [e.pos[0] + margin.left, e.pos[1] + margin.top],
125
- seriesIndex: e.seriesIndex,
126
- pointIndex: e.pointIndex
127
- });
128
- });
129
-
130
- lines.dispatch.on('elementMouseout.tooltip', function(e) {
131
- dispatch.tooltipHide(e);
132
- });
133
-
134
- });
135
-
136
-
137
- // If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work
138
- if (margin.top != legend.height())
139
- chart(selection);
140
-
141
-
142
- return chart;
143
- }
144
-
145
-
146
- chart.dispatch = dispatch;
147
- chart.legend = legend;
148
- chart.xAxis = xAxis;
149
- chart.yAxis = yAxis;
150
-
151
- d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id');
152
-
153
-
154
- chart.margin = function(_) {
155
- if (!arguments.length) return margin;
156
- margin = _;
157
- return chart;
158
- };
159
-
160
- chart.width = function(_) {
161
- if (!arguments.length) return width;
162
- width = _;
163
- //width = d3.functor(_);
164
- return chart;
165
- };
166
-
167
- chart.height = function(_) {
168
- if (!arguments.length) return height;
169
- height = _;
170
- //height = d3.functor(_);
171
- return chart;
172
- };
173
-
174
-
175
- return chart;
176
- }
@@ -1,99 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
- <link href="../src/nv.d3.css" rel="stylesheet" type="text/css">
4
- <style>
5
-
6
- </style>
7
-
8
- <body>
9
-
10
-
11
- <script src="../lib/d3.v2.js"></script>
12
- <script src="../nv.d3.js"></script>
13
- <script>
14
-
15
- function ilog(text) {
16
- console.log(text);
17
- return text;
18
- }
19
-
20
-
21
- function daysInMonth(month,year) {
22
- var m = [31,28,31,30,31,30,31,31,30,31,30,31];
23
- if (month != 2) return m[month - 1];
24
- if (year%4 != 0) return m[1];
25
- if (year%100 == 0 && year%400 != 0) return m[1];
26
- return m[1] + 1;
27
- }
28
-
29
-
30
- function d3_time_range(floor, step, number) {
31
- return function(t0, t1, dt) {
32
- var time = floor(t0), times = [];
33
- if (time < t0) step(time);
34
- if (dt > 1) {
35
- while (time < t1) {
36
- var date = new Date(+time);
37
- if (!(number(date) % dt)) times.push(date);
38
- step(time);
39
- }
40
- } else {
41
- while (time < t1) times.push(new Date(+time)), step(time);
42
- }
43
- return times;
44
- };
45
- }
46
-
47
-
48
- d3.time.monthEnd = function(date) {
49
- return new Date(date.getFullYear(), date.getMonth(), 0);
50
- };
51
-
52
-
53
- d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) {
54
- date.setUTCDate(date.getUTCDate() + 1);
55
- date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear()));
56
- }, function(date) {
57
- return date.getMonth();
58
- }
59
- );
60
-
61
-
62
-
63
-
64
- var margin = {top: 10, right: 40, bottom: 40, left: 40},
65
- width = 960 - margin.left - margin.right,
66
- height = 80 - margin.top - margin.bottom;
67
-
68
- var x = d3.time.scale()
69
- .domain([new Date(2010, 0, 1), new Date(2011, 0, 1)])
70
- .range([0, width]);
71
-
72
- var xAxis = d3.svg.axis()
73
- .scale(x)
74
- .orient("bottom")
75
- //.ticks(d3.time.months)
76
- .ticks(d3.time.monthEnds)
77
- //.tickSubdivide(3)
78
- .tickSize(8, 4, 0)
79
- .tickFormat(d3.time.format("%x"));
80
- //.tickFormat(d3.time.format("%B"));
81
-
82
- var svg = d3.select("body").append("svg")
83
- .attr("width", width + margin.left + margin.right)
84
- .attr("height", height + margin.top + margin.bottom)
85
- .append("g")
86
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
87
-
88
- svg.append("g")
89
- .attr("class", "x axis")
90
- .attr("transform", "translate(0," + height + ")")
91
- .call(xAxis)
92
-
93
- .selectAll("text")
94
- .attr("text-anchor", "middle")
95
- //.attr("text-anchor", "start")
96
- .attr("x", 0)
97
- .attr("y", 12);
98
-
99
- </script>
@@ -1,258 +0,0 @@
1
- <!DOCTYPE html>
2
- <meta charset="utf-8">
3
-
4
- <link href="../src/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
- #chart1 {
17
- height: 500px;
18
- margin: 10px;
19
- min-width: 100px;
20
- min-height: 100px;
21
- /*
22
- Minimum height and width is a good idea to prevent negative SVG dimensions...
23
- For example width should be =< margin.left + margin.right + 1,
24
- of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
25
- */
26
- }
27
-
28
- </style>
29
- <body>
30
-
31
- <div id="chart1">
32
- </div>
33
-
34
- <script src="../lib/d3.v2.js"></script>
35
- <script src="../nv.d3.js"></script>
36
- <script src="../src/tooltip.js"></script>
37
- <script src="../src/models/legend.js"></script>
38
- <script src="../src/models/axis.js"></script>
39
- <script src="../src/models/multiBarHorizontal.js"></script>
40
- <script src="../src/models/multiBarHorizontalWithLegend.js"></script>
41
- <script src="stream_layers.js"></script>
42
- <script>
43
-
44
- var test_data = stream_layers(3,12,.1).map(function(data, i) {
45
- return {
46
- key: 'Stream' + i,
47
- values: data
48
- };
49
- });
50
-
51
-
52
-
53
- long_short_data = [
54
- {
55
- key: 'Short',
56
- color: '#d62728',
57
- values: [
58
- {
59
- "label" : "Information Technology" ,
60
- "y" : -1.8746444827653
61
- } ,
62
- {
63
- "label" : "Consumer Discretionary" ,
64
- "y" : -8.0961543492239
65
- } ,
66
- {
67
- "label" : "Health Care" ,
68
- "y" : -0.57072943117674
69
- } ,
70
- {
71
- "label" : "Consumer Staples" ,
72
- "y" : -2.4174010336624
73
- } ,
74
- {
75
- "label" : "Financials" ,
76
- "y" : -0.72009071426284
77
- } ,
78
- {
79
- "label" : "Industrials" ,
80
- "y" : -0.77154485523777
81
- } ,
82
- {
83
- "label" : "Energy" ,
84
- "y" : -0.90152097798131
85
- } ,
86
- {
87
- "label" : "Materials" ,
88
- "y" : -0.91445417330854
89
- } ,
90
- {
91
- "label" : "Telecommunication Services" ,
92
- "y" : -0.055746319141851
93
- }
94
- ]
95
- },
96
- {
97
- key: 'Long',
98
- color: '#1f77b4',
99
- values: [
100
- {
101
- "label" : "Information Technology" ,
102
- "y" : 25.307646510375
103
- } ,
104
- {
105
- "label" : "Consumer Discretionary" ,
106
- "y" : 16.756779544553
107
- } ,
108
- {
109
- "label" : "Health Care" ,
110
- "y" : 18.451534877007
111
- } ,
112
- {
113
- "label" : "Consumer Staples" ,
114
- "y" : 8.6142352811805
115
- } ,
116
- {
117
- "label" : "Financials" ,
118
- "y" : 7.8082472075876
119
- } ,
120
- {
121
- "label" : "Industrials" ,
122
- "y" : 5.259101026956
123
- } ,
124
- {
125
- "label" : "Energy" ,
126
- "y" : 0.30947953487127
127
- } ,
128
- {
129
- "label" : "Materials" ,
130
- "y" : 0
131
- } ,
132
- {
133
- "label" : "Telecommunication Services" ,
134
- "y" : 0
135
- }
136
- ]
137
- }
138
- ];
139
-
140
-
141
-
142
- var selector = '#chart1',
143
- chart = nv.models.multiBarHorizontalWithLegend()
144
- .x(function(d) { return d.label })
145
- .margin({top: 30, right: 20, bottom: 50, left: 160})
146
- .showControls(false),
147
- data = long_short_data,
148
- //data = test_data,
149
- xTickFormat = function(d) { return d },
150
- //xTickFormat = d3.format(',r'),
151
- yTickFormat = d3.format(',.2f'),
152
- xAxisLabel = null,
153
- yAxisLabel = null,
154
- duration = 500;
155
-
156
- nv.addGraph({
157
- generate: function() {
158
- var container = d3.select(selector),
159
- width = function() { return parseInt(container.style('width')) },
160
- height = function() { return parseInt(container.style('height')) },
161
- svg = container.append('svg');
162
-
163
- chart
164
- .width(width)
165
- .height(height);
166
-
167
- chart.xAxis
168
- .tickFormat(xTickFormat);
169
-
170
- chart.yAxis
171
- .tickFormat(yTickFormat)
172
- .axisLabel(yAxisLabel);
173
-
174
- svg
175
- .attr('width', width())
176
- .attr('height', height())
177
- .datum(data)
178
- .transition().duration(duration).call(chart);
179
-
180
- return chart;
181
- },
182
- callback: function(chart) {
183
- var showTooltip = function showTooltip(e) {
184
- var offsetElement = document.getElementById(selector.substr(1)),
185
- left = e.pos[0] + offsetElement.offsetLeft,
186
- top = e.pos[1] + offsetElement.offsetTop,
187
- formatY = chart.yAxis.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc.
188
- formatX = chart.xAxis.tickFormat();
189
-
190
- // uses the chart's getX and getY, you may customize if x position is not the same as the value you want
191
- // ex. daily data without weekends, x is the index, while you want the date
192
- var content = '<h3>' + e.series.key + '</h3>' +
193
- '<p>' +
194
- formatX(chart.x()(e.point)) + ': ' + formatY(chart.y()(e.point)) +
195
- //formatY(chart.y()(e.point)) + ' at ' + formatX(chart.x()(e.point)) +
196
- '</p>';
197
-
198
- var tooltip = nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w');
199
-
200
- /*
201
- if (!arguments[1]) {
202
- tooltip.onmouseenter = function() { showTooltip(e, 1) }; //working on geting tooltips to stay if mouse hovers over them
203
- //tooltip.onmouseout = function() { console.log('mouseout'); };
204
- tooltip.onmouseout = nv.tooltip.cleanup;
205
- }
206
- */
207
- };
208
-
209
- chart.dispatch.on('tooltipShow', showTooltip);
210
- chart.dispatch.on('tooltipHide', nv.tooltip.cleanup);
211
-
212
-
213
- window.onresize= function() {
214
- // now that width and height are functions, should be automatic..of course you can always override them
215
-
216
- d3.select('#chart1 svg')
217
- .attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
218
- .attr('height', chart.height()())
219
- .transition().duration(duration)
220
- .call(chart);
221
-
222
- /*
223
- d3.select('#chart1 svg')
224
- .attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
225
- .attr('height', chart.height()())
226
- .call(chart);
227
- */
228
- };
229
- }
230
- });
231
-
232
-
233
-
234
- function sinAndCos() {
235
- var sin = [],
236
- cos = [];
237
-
238
- for (var i = 0; i < 100; i++) {
239
- sin.push({x: i, y: Math.sin(i/10)});
240
- cos.push({x: i, y: .5 * Math.cos(i/10)});
241
- }
242
-
243
- return [
244
- {
245
- values: sin,
246
- key: "Sine Wave",
247
- color: "#ff7f0e"
248
- },
249
- {
250
- values: cos,
251
- key: "Cosine Wave",
252
- color: "#2ca02c"
253
- }
254
- ];
255
- }
256
-
257
-
258
- </script>