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.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/README.md +7 -71
- data/lib/nvd3/rails/version.rb +1 -1
- data/nvd3-rails.gemspec +3 -3
- metadata +8 -111
- data/vendor/assets/javascripts/nvd3/.git.sample/HEAD +0 -1
- data/vendor/assets/javascripts/nvd3/.git.sample/config +0 -13
- data/vendor/assets/javascripts/nvd3/.git.sample/description +0 -1
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/applypatch-msg.sample +0 -15
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/commit-msg.sample +0 -24
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/post-update.sample +0 -8
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-applypatch.sample +0 -14
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-commit.sample +0 -50
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-push.sample +0 -53
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/pre-rebase.sample +0 -169
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/prepare-commit-msg.sample +0 -36
- data/vendor/assets/javascripts/nvd3/.git.sample/hooks/update.sample +0 -128
- data/vendor/assets/javascripts/nvd3/.git.sample/index +0 -0
- data/vendor/assets/javascripts/nvd3/.git.sample/info/exclude +0 -6
- data/vendor/assets/javascripts/nvd3/.git.sample/logs/HEAD +0 -1
- data/vendor/assets/javascripts/nvd3/.git.sample/logs/refs/heads/master +0 -1
- data/vendor/assets/javascripts/nvd3/.git.sample/logs/refs/remotes/origin/HEAD +0 -1
- data/vendor/assets/javascripts/nvd3/.git.sample/objects/pack/pack-babbb312d58dd7f03870b530a1b9a84c80918be3.idx +0 -0
- data/vendor/assets/javascripts/nvd3/.git.sample/objects/pack/pack-babbb312d58dd7f03870b530a1b9a84c80918be3.pack +0 -0
- data/vendor/assets/javascripts/nvd3/.git.sample/packed-refs +0 -5
- data/vendor/assets/javascripts/nvd3/.git.sample/refs/heads/master +0 -1
- data/vendor/assets/javascripts/nvd3/.git.sample/refs/remotes/origin/HEAD +0 -1
- data/vendor/assets/javascripts/nvd3/build.bat +0 -6
- data/vendor/assets/javascripts/nvd3/deprecated/bar.html +0 -198
- data/vendor/assets/javascripts/nvd3/deprecated/bar.js +0 -250
- data/vendor/assets/javascripts/nvd3/deprecated/charts/cumulativeLineChart.js +0 -174
- data/vendor/assets/javascripts/nvd3/deprecated/charts/discreteBarChart.js +0 -157
- data/vendor/assets/javascripts/nvd3/deprecated/charts/lineChart.js +0 -159
- data/vendor/assets/javascripts/nvd3/deprecated/charts/lineChartDaily.js +0 -168
- data/vendor/assets/javascripts/nvd3/deprecated/charts/stackedAreaChart.js +0 -177
- data/vendor/assets/javascripts/nvd3/deprecated/cumulativeLine.html +0 -171
- data/vendor/assets/javascripts/nvd3/deprecated/cumulativeLine.js +0 -334
- data/vendor/assets/javascripts/nvd3/deprecated/discreteBarChartWithEnabledTooltip.html +0 -129
- data/vendor/assets/javascripts/nvd3/deprecated/discreteBarChartWithEnabledTooltip.js +0 -222
- data/vendor/assets/javascripts/nvd3/deprecated/discreteBarWithAxes.html +0 -172
- data/vendor/assets/javascripts/nvd3/deprecated/discreteBarWithAxes.js +0 -152
- data/vendor/assets/javascripts/nvd3/deprecated/lineChart-old.html +0 -83
- data/vendor/assets/javascripts/nvd3/deprecated/lineChartDaily.html +0 -109
- data/vendor/assets/javascripts/nvd3/deprecated/linePlusBar.html +0 -173
- data/vendor/assets/javascripts/nvd3/deprecated/linePlusBar.js +0 -250
- data/vendor/assets/javascripts/nvd3/deprecated/lineWithFocus.html +0 -137
- data/vendor/assets/javascripts/nvd3/deprecated/lineWithFocus.js +0 -354
- data/vendor/assets/javascripts/nvd3/deprecated/lineWithFourAxes.html +0 -144
- data/vendor/assets/javascripts/nvd3/deprecated/lineWithFourAxes.js +0 -218
- data/vendor/assets/javascripts/nvd3/deprecated/lineWithLegend.html +0 -142
- data/vendor/assets/javascripts/nvd3/deprecated/lineWithLegend.js +0 -176
- data/vendor/assets/javascripts/nvd3/deprecated/monthendAxis.html +0 -99
- data/vendor/assets/javascripts/nvd3/deprecated/multiBarHorizontalWithLegend.html +0 -258
- data/vendor/assets/javascripts/nvd3/deprecated/multiBarHorizontalWithLegend.js +0 -226
- data/vendor/assets/javascripts/nvd3/deprecated/multiBarWithLegend.html +0 -162
- data/vendor/assets/javascripts/nvd3/deprecated/multiBarWithLegend.js +0 -249
- data/vendor/assets/javascripts/nvd3/deprecated/pie.js +0 -263
- data/vendor/assets/javascripts/nvd3/deprecated/scatterChart.html +0 -110
- data/vendor/assets/javascripts/nvd3/deprecated/scatterChart.js +0 -294
- data/vendor/assets/javascripts/nvd3/deprecated/scatterFisheyeChart.js +0 -418
- data/vendor/assets/javascripts/nvd3/deprecated/scatterWithLegend.html +0 -167
- data/vendor/assets/javascripts/nvd3/deprecated/scatterWithLegend.js +0 -261
- data/vendor/assets/javascripts/nvd3/deprecated/stackedArea.js +0 -286
- data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaChart.html +0 -183
- data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaChart_old.html +0 -137
- data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaWithLegend.html +0 -222
- data/vendor/assets/javascripts/nvd3/deprecated/stackedAreaWithLegend.js +0 -297
- data/vendor/assets/javascripts/nvd3/examples/bullet.html +0 -96
- data/vendor/assets/javascripts/nvd3/examples/bulletChart.html +0 -94
- data/vendor/assets/javascripts/nvd3/examples/crossfilter.html +0 -167
- data/vendor/assets/javascripts/nvd3/examples/crossfilterWithDimentions.html +0 -180
- data/vendor/assets/javascripts/nvd3/examples/crossfilterWithTables.html +0 -288
- data/vendor/assets/javascripts/nvd3/examples/cumulativeLineChart.html +0 -155
- data/vendor/assets/javascripts/nvd3/examples/discreteBarChart.html +0 -116
- data/vendor/assets/javascripts/nvd3/examples/dynamicTimeSeries.html +0 -148
- data/vendor/assets/javascripts/nvd3/examples/historicalBar.html +0 -157
- data/vendor/assets/javascripts/nvd3/examples/horizon.html +0 -163
- data/vendor/assets/javascripts/nvd3/examples/images/grey-minus.png +0 -0
- data/vendor/assets/javascripts/nvd3/examples/images/grey-plus.png +0 -0
- data/vendor/assets/javascripts/nvd3/examples/indentedtree.html +0 -126
- data/vendor/assets/javascripts/nvd3/examples/legend.html +0 -75
- data/vendor/assets/javascripts/nvd3/examples/line.html +0 -95
- data/vendor/assets/javascripts/nvd3/examples/lineChart.html +0 -112
- data/vendor/assets/javascripts/nvd3/examples/lineChartSVGResize.html +0 -151
- data/vendor/assets/javascripts/nvd3/examples/linePlusBarChart.html +0 -114
- data/vendor/assets/javascripts/nvd3/examples/linePlusBarWithFocusChart.html +0 -128
- data/vendor/assets/javascripts/nvd3/examples/lineTimeSeries.html +0 -142
- data/vendor/assets/javascripts/nvd3/examples/lineWithFisheyeChart.html +0 -101
- data/vendor/assets/javascripts/nvd3/examples/lineWithFocusChart.html +0 -87
- data/vendor/assets/javascripts/nvd3/examples/multiBar.html +0 -92
- data/vendor/assets/javascripts/nvd3/examples/multiBarChart.html +0 -93
- data/vendor/assets/javascripts/nvd3/examples/multiBarHorizontalChart.html +0 -388
- data/vendor/assets/javascripts/nvd3/examples/multiChart.html +0 -93
- data/vendor/assets/javascripts/nvd3/examples/nations.json +0 -1
- data/vendor/assets/javascripts/nvd3/examples/pie.html +0 -93
- data/vendor/assets/javascripts/nvd3/examples/pieChart.html +0 -114
- data/vendor/assets/javascripts/nvd3/examples/scatter.html +0 -95
- data/vendor/assets/javascripts/nvd3/examples/scatterChart.html +0 -115
- data/vendor/assets/javascripts/nvd3/examples/scatterPlusLineChart.html +0 -116
- data/vendor/assets/javascripts/nvd3/examples/sparkline.html +0 -62
- data/vendor/assets/javascripts/nvd3/examples/sparklinePlus.html +0 -67
- data/vendor/assets/javascripts/nvd3/examples/stackedArea.html +0 -155
- data/vendor/assets/javascripts/nvd3/examples/stackedAreaChart.html +0 -245
- data/vendor/assets/javascripts/nvd3/examples/stream_layers.js +0 -35
- data/vendor/assets/javascripts/nvd3/src/models/backup/bullet.js +0 -250
- data/vendor/assets/javascripts/nvd3/src/models/backup/bulletChart.js +0 -349
@@ -1,152 +0,0 @@
|
|
1
|
-
|
2
|
-
nv.models.discreteBarWithAxes = function() {
|
3
|
-
var margin = {top: 30, right: 20, bottom: 50, left: 60},
|
4
|
-
width = function() { return 960 },
|
5
|
-
height = function() { return 500 },
|
6
|
-
color = d3.scale.category20().range(),
|
7
|
-
staggerLabels = false;
|
8
|
-
|
9
|
-
var discretebar = nv.models.discreteBar(),
|
10
|
-
x = discretebar.xScale(),
|
11
|
-
y = discretebar.yScale(),
|
12
|
-
xAxis = nv.models.axis().scale(x).orient('bottom').highlightZero(false),
|
13
|
-
yAxis = nv.models.axis().scale(y).orient('left'),
|
14
|
-
dispatch = d3.dispatch('tooltipShow', 'tooltipHide');
|
15
|
-
|
16
|
-
//TODO: let user select default
|
17
|
-
var controlsData = [
|
18
|
-
{ key: 'Grouped' },
|
19
|
-
{ key: 'Stacked', disabled: true }
|
20
|
-
];
|
21
|
-
|
22
|
-
function chart(selection) {
|
23
|
-
selection.each(function(data) {
|
24
|
-
var availableWidth = width() - margin.left - margin.right,
|
25
|
-
availableHeight = height() - margin.top - margin.bottom;
|
26
|
-
|
27
|
-
var seriesData = data.filter(function(d) { return !d.disabled })
|
28
|
-
.map(function(d) {
|
29
|
-
return d.values.map(function(d,i) {
|
30
|
-
return { x: discretebar.x()(d,i), y: discretebar.y()(d,i) }
|
31
|
-
})
|
32
|
-
});
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
discretebar
|
37
|
-
.width(availableWidth)
|
38
|
-
.height(availableHeight);
|
39
|
-
|
40
|
-
|
41
|
-
var wrap = d3.select(this).selectAll('g.wrap.discreteBarWithAxes').data([data]);
|
42
|
-
var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 discreteBarWithAxes').append('g');
|
43
|
-
|
44
|
-
gEnter.append('g').attr('class', 'x axis');
|
45
|
-
gEnter.append('g').attr('class', 'y axis');
|
46
|
-
gEnter.append('g').attr('class', 'barsWrap');
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
var g = wrap.select('g');
|
51
|
-
|
52
|
-
|
53
|
-
g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
54
|
-
|
55
|
-
var barsWrap = g.select('.barsWrap')
|
56
|
-
.datum(data.filter(function(d) { return !d.disabled }))
|
57
|
-
|
58
|
-
|
59
|
-
d3.transition(barsWrap).call(discretebar);
|
60
|
-
|
61
|
-
|
62
|
-
xAxis
|
63
|
-
.scale(x)
|
64
|
-
.ticks( availableWidth / 100 )
|
65
|
-
.tickSize(-availableHeight, 0);
|
66
|
-
|
67
|
-
g.select('.x.axis')
|
68
|
-
.attr('transform', 'translate(0,' + y.range()[0] + ')');
|
69
|
-
d3.transition(g.select('.x.axis'))
|
70
|
-
.call(xAxis);
|
71
|
-
|
72
|
-
|
73
|
-
var xTicks = g.select('.x.axis').selectAll('g');
|
74
|
-
|
75
|
-
if (staggerLabels)
|
76
|
-
xTicks
|
77
|
-
.selectAll('text')
|
78
|
-
.attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '0' : '12') + ')' })
|
79
|
-
|
80
|
-
/*
|
81
|
-
xTicks.filter(function(d,i) {
|
82
|
-
return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0;
|
83
|
-
})
|
84
|
-
.selectAll('line, text')
|
85
|
-
.style('opacity', 0)
|
86
|
-
*/
|
87
|
-
|
88
|
-
yAxis
|
89
|
-
.scale(y)
|
90
|
-
.ticks( availableHeight / 36 )
|
91
|
-
.tickSize( -availableWidth, 0);
|
92
|
-
|
93
|
-
d3.transition(g.select('.y.axis'))
|
94
|
-
.call(yAxis);
|
95
|
-
|
96
|
-
|
97
|
-
discretebar.dispatch.on('elementMouseover.tooltip', function(e) {
|
98
|
-
e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
|
99
|
-
dispatch.tooltipShow(e);
|
100
|
-
});
|
101
|
-
|
102
|
-
discretebar.dispatch.on('elementMouseout.tooltip', function(e) {
|
103
|
-
dispatch.tooltipHide(e);
|
104
|
-
});
|
105
|
-
|
106
|
-
});
|
107
|
-
|
108
|
-
return chart;
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
chart.dispatch = dispatch;
|
113
|
-
chart.xAxis = xAxis;
|
114
|
-
chart.yAxis = yAxis;
|
115
|
-
|
116
|
-
d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id');
|
117
|
-
|
118
|
-
|
119
|
-
chart.margin = function(_) {
|
120
|
-
if (!arguments.length) return margin;
|
121
|
-
margin = _;
|
122
|
-
return chart;
|
123
|
-
};
|
124
|
-
|
125
|
-
chart.width = function(_) {
|
126
|
-
if (!arguments.length) return width;
|
127
|
-
width = d3.functor(_);
|
128
|
-
return chart;
|
129
|
-
};
|
130
|
-
|
131
|
-
chart.height = function(_) {
|
132
|
-
if (!arguments.length) return height;
|
133
|
-
height = d3.functor(_);
|
134
|
-
return chart;
|
135
|
-
};
|
136
|
-
|
137
|
-
chart.color = function(_) {
|
138
|
-
if (!arguments.length) return color;
|
139
|
-
color = _;
|
140
|
-
discretebar.color(_);
|
141
|
-
return chart;
|
142
|
-
};
|
143
|
-
|
144
|
-
chart.staggerLabels = function(_) {
|
145
|
-
if (!arguments.length) return staggerLabels;
|
146
|
-
staggerLabels = _;
|
147
|
-
return chart;
|
148
|
-
};
|
149
|
-
|
150
|
-
|
151
|
-
return chart;
|
152
|
-
}
|
@@ -1,83 +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
|
-
<!-- including all the components so I don't have to minify every time I test in development -->
|
37
|
-
<script src="../src/tooltip.js"></script>
|
38
|
-
<script src="../src/models/legend.js"></script>
|
39
|
-
<script src="../src/models/axis.js"></script>
|
40
|
-
<script src="../src/models/line.js"></script>
|
41
|
-
<script src="../src/models/lineWithLegend.js"></script>
|
42
|
-
<script src="../src/charts/lineChart.js"></script>
|
43
|
-
<script>
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
nv.charts.line()
|
48
|
-
.selector('#chart1')
|
49
|
-
.data(sinAndCos())
|
50
|
-
.y(function(d) { return d.voltage })
|
51
|
-
.yAxisLabel('Voltage (v)')
|
52
|
-
.build();
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
function sinAndCos() {
|
58
|
-
var sin = [],
|
59
|
-
cos = [],
|
60
|
-
r1 = Math.random(),
|
61
|
-
r2 = Math.random();
|
62
|
-
|
63
|
-
for (var i = 0; i < 100; i++) {
|
64
|
-
sin.push({x: i, voltage: r2 * Math.sin(i/10)});
|
65
|
-
cos.push({x: i, voltage: r1 * Math.cos(i/10)});
|
66
|
-
}
|
67
|
-
|
68
|
-
return [
|
69
|
-
{
|
70
|
-
values: sin,
|
71
|
-
key: "Sine Wave",
|
72
|
-
color: "#ff7f0e"
|
73
|
-
},
|
74
|
-
{
|
75
|
-
values: cos,
|
76
|
-
key: "Cosine Wave",
|
77
|
-
color: "#2ca02c"
|
78
|
-
}
|
79
|
-
];
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
</script>
|
@@ -1,109 +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
|
-
<!-- including all the components so I don't have to minify every time I test in development -->
|
37
|
-
<script src="../src/tooltip.js"></script>
|
38
|
-
<script src="../src/models/legend.js"></script>
|
39
|
-
<script src="../src/models/axis.js"></script>
|
40
|
-
<script src="../src/models/line.js"></script>
|
41
|
-
<script src="../src/models/lineWithLegend.js"></script>
|
42
|
-
<script src="../src/charts/lineChartDaily.js"></script>
|
43
|
-
<script>
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
var cumulativeDailyTestData = [
|
48
|
-
{
|
49
|
-
key: "Actual Return" ,
|
50
|
-
values: [ [ 1317614400000 , -1.4475640131507] , [ 1317700800000 , -0.50785241139112] , [ 1317787200000 , 1.2232844878178] , [ 1317873600000 , 2.3277976069464] , [ 1317960000000 , 0.87828538009238] , [ 1318046400000 , 0.87828538009238] , [ 1318132800000 , 0.87828538009238] , [ 1318219200000 , 2.8821394715025] , [ 1318305600000 , 3.0600496997189] , [ 1318392000000 , 4.1615801183747] , [ 1318478400000 , 3.8560316339337] , [ 1318564800000 , 4.2624578565545] , [ 1318651200000 , 4.2624578565545] , [ 1318737600000 , 4.2624578565545] , [ 1318824000000 , 2.8760203477064] , [ 1318910400000 , 4.2802792900813] , [ 1318996800000 , 3.5644216125341] , [ 1319083200000 , 3.8267230522883] , [ 1319169600000 , 4.5897674196334] , [ 1319256000000 , 4.5897674196334] , [ 1319342400000 , 4.5897674196334] , [ 1319428800000 , 6.1435681595838] , [ 1319515200000 , 4.6773634913148] , [ 1319601600000 , 5.5686828861057] , [ 1319688000000 , 8.6510229437140] , [ 1319774400000 , 8.4035095885256] , [ 1319860800000 , 8.4035095885256] , [ 1319947200000 , 8.4035095885256] , [ 1320033600000 , 5.9304228949775] , [ 1320120000000 , 4.6694048881845] , [ 1320206400000 , 5.5755229192740] , [ 1320292800000 , 5.9596062543264] , [ 1320379200000 , 5.8750173069172] , [ 1320465600000 , 5.8750173069172] , [ 1320552000000 , 5.8750173069172] , [ 1320642000000 , 6.2705601567990] , [ 1320728400000 , 6.4422984536501] , [ 1320814800000 , 3.7696655204518] , [ 1320901200000 , 3.9256502879070] , [ 1320987600000 , 4.9896568610477] , [ 1321074000000 , 4.9896568610477] , [ 1321160400000 , 4.9896568610477] , [ 1321246800000 , 4.5101581898062] , [ 1321333200000 , 5.1852026589187] , [ 1321419600000 , 4.1412722333259] , [ 1321506000000 , 2.6646651357988] , [ 1321592400000 , 2.5391402402758] , [ 1321678800000 , 2.5391402402758] , [ 1321765200000 , 2.5391402402758] , [ 1321851600000 , 1.4480191418839] , [ 1321938000000 , 1.1851353770435] , [ 1322024400000 , -0.0110471601546] , [ 1322110800000 , -0.0110471601546] , [ 1322197200000 , -0.2607790366052] , [ 1322283600000 , -0.2607790366052] , [ 1322370000000 , -0.2607790366052] , [ 1322456400000 , -0.2993491727393] , [ 1322542800000 , -0.8721365094791] , [ 1322629200000 , 1.3826624677829] , [ 1322715600000 , 1.1413888639683] , [ 1322802000000 , 1.1916488459919] , [ 1322888400000 , 1.1916488459919] , [ 1322974800000 , 1.1916488459919] , [ 1323061200000 , 1.6640075295100] , [ 1323147600000 , 1.4333447279330] , [ 1323234000000 , 1.5756501095903] , [ 1323320400000 , 0.1566240837346] , [ 1323406800000 , 1.1957087351357] , [ 1323493200000 , 1.1957087351357] , [ 1323579600000 , 1.1957087351357] , [ 1323666000000 , 0.1529279857726] , [ 1323752400000 , -0.4379146622043] , [ 1323838800000 , -1.6307803651431] , [ 1323925200000 , -1.8097182178695] , [ 1324011600000 , -1.6612784009542] , [ 1324098000000 , -1.6612784009542] , [ 1324184400000 , -1.6612784009542] , [ 1324270800000 , -2.7123628804330] , [ 1324357200000 , -0.9156099608796] , [ 1324443600000 , -1.3441101479801] , [ 1324530000000 , -0.4285924644141] , [ 1324616400000 , 0.0289302220607] , [ 1324702800000 , 0.0289302220607] , [ 1324789200000 , 0.0289302220607] , [ 1324875600000 , 0.0289302220607] , [ 1324962000000 , -0.1680182906741] , [ 1325048400000 , -1.1735228321827] , [ 1325134800000 , -0.4819867447246] , [ 1325221200000 , -0.5667569440908] , [ 1325307600000 , -0.5667569440908] , [ 1325394000000 , -0.5667569440908] , [ 1325480400000 , -0.5667569440908] , [ 1325566800000 , 0.6031318427099] , [ 1325653200000 , 0.5247518205078] , [ 1325739600000 , 0.8575949798359] , [ 1325826000000 , 0.9983061584652] , [ 1325912400000 , 0.9983061584652] , [ 1325998800000 , 0.9983061584652] , [ 1326085200000 , 1.4032665222444] , [ 1326171600000 , 1.8976558759597] , [ 1326258000000 , 2.1532858156245] , [ 1326344400000 , 2.3864413393018] , [ 1326430800000 , 1.8718218939651] , [ 1326517200000 , 1.8718218939651] , [ 1326603600000 , 1.8718218939651] , [ 1326690000000 , 1.8718218939651] , [ 1326776400000 , 1.7604328445901] , [ 1326862800000 , 2.6068832572249] , [ 1326949200000 , 3.0615220945767] , [ 1327035600000 , 2.9348684033730] , [ 1327122000000 , 2.9348684033730] , [ 1327208400000 , 2.9348684033730] , [ 1327294800000 , 3.1172684824147] , [ 1327381200000 , 2.9842827363639] , [ 1327467600000 , 3.2794961257832] , [ 1327554000000 , 3.2797701308936] , [ 1327640400000 , 3.7651100285428] , [ 1327726800000 , 3.7651100285428] , [ 1327813200000 , 3.7651100285428] , [ 1327899600000 , 3.4448337693528] , [ 1327986000000 , 3.4404569794837] , [ 1328072400000 , 4.1401512200522] , [ 1328158800000 , 4.6727018946707] , [ 1328245200000 , 5.2867004865128] , [ 1328331600000 , 5.2867004865128] , [ 1328418000000 , 5.2867004865128] , [ 1328504400000 , 5.3018888374398] , [ 1328590800000 , 5.1280880489145] , [ 1328677200000 , 5.4871623117969] , [ 1328763600000 , 5.9003310858354] , [ 1328850000000 , 5.0814183419277] , [ 1328936400000 , 5.0814183419277] , [ 1329022800000 , 5.0814183419277] , [ 1329109200000 , 5.2642419624752] , [ 1329195600000 , 4.8821179791227] , [ 1329282000000 , 4.5757484771430] , [ 1329368400000 , 5.3842423229681] , [ 1329454800000 , 5.8228981100571] , [ 1329541200000 , 5.8228981100571] , [ 1329627600000 , 5.8228981100571] , [ 1329714000000 , 5.8228981100571] , [ 1329800400000 , 5.9363351939783] , [ 1329886800000 , 5.8228361646391] , [ 1329973200000 , 6.0558840413572] , [ 1330059600000 , 5.9445876811563] , [ 1330146000000 , 5.9445876811563] , [ 1330232400000 , 5.9445876811563] , [ 1330318800000 , 6.1681584877353] , [ 1330405200000 , 6.3035995639854] , [ 1330491600000 , 5.6363506399283]]
|
51
|
-
},
|
52
|
-
{
|
53
|
-
key: "Average Exposure Return" ,
|
54
|
-
values: [ [ 1317614400000 , -1.4090582224638] , [ 1317700800000 , -0.33947919866996] , [ 1317787200000 , 1.3209670502436] , [ 1317873600000 , 2.4188464341509] , [ 1317960000000 , 1.0255951936249] , [ 1318046400000 , 1.0255951936249] , [ 1318132800000 , 1.0255951936249] , [ 1318219200000 , 2.6899883270271] , [ 1318305600000 , 2.8018416928856] , [ 1318392000000 , 3.8403942243892] , [ 1318478400000 , 3.5468986968984] , [ 1318564800000 , 4.0243375950513] , [ 1318651200000 , 4.0243375950513] , [ 1318737600000 , 4.0243375950513] , [ 1318824000000 , 2.4581180602808] , [ 1318910400000 , 4.1316695396727] , [ 1318996800000 , 3.1991658519074] , [ 1319083200000 , 3.3754265861117] , [ 1319169600000 , 4.4804434889521] , [ 1319256000000 , 4.4804434889521] , [ 1319342400000 , 4.4804434889521] , [ 1319428800000 , 6.0509760703797] , [ 1319515200000 , 4.5220450819341] , [ 1319601600000 , 5.4035696887952] , [ 1319688000000 , 8.5378579094975] , [ 1319774400000 , 8.3016796632707] , [ 1319860800000 , 8.3016796632707] , [ 1319947200000 , 8.3016796632707] , [ 1320033600000 , 6.2091232673734] , [ 1320120000000 , 4.6685577522987] , [ 1320206400000 , 5.6873278908841] , [ 1320292800000 , 6.1826552943765] , [ 1320379200000 , 6.0959959548027] , [ 1320465600000 , 6.0959959548027] , [ 1320552000000 , 6.0959959548027] , [ 1320642000000 , 6.4745420383103] , [ 1320728400000 , 6.6925431963260] , [ 1320814800000 , 4.0430621035979] , [ 1320901200000 , 4.2956347789229] , [ 1320987600000 , 5.5492974385965] , [ 1321074000000 , 5.5492974385965] , [ 1321160400000 , 5.5492974385965] , [ 1321246800000 , 5.0642000641245] , [ 1321333200000 , 5.6666120553597] , [ 1321419600000 , 4.6202390103380] , [ 1321506000000 , 3.0124066565603] , [ 1321592400000 , 2.8681458220660] , [ 1321678800000 , 2.8681458220660] , [ 1321765200000 , 2.8681458220660] , [ 1321851600000 , 1.6604177140523] , [ 1321938000000 , 1.3391308252236] , [ 1322024400000 , -0.1027204753207] , [ 1322110800000 , -0.1027204753207] , [ 1322197200000 , -0.4062707232214] , [ 1322283600000 , -0.4062707232214] , [ 1322370000000 , -0.4062707232214] , [ 1322456400000 , 0.5651520529190] , [ 1322542800000 , 0.1114911016548] , [ 1322629200000 , 2.2135818365753] , [ 1322715600000 , 1.9445161544187] , [ 1322802000000 , 1.9427980090936] , [ 1322888400000 , 1.9427980090936] , [ 1322974800000 , 1.9427980090936] , [ 1323061200000 , 2.3501860364827] , [ 1323147600000 , 2.1136672636407] , [ 1323234000000 , 2.2418743103244] , [ 1323320400000 , 1.0064931140733] , [ 1323406800000 , 1.9661258515092] , [ 1323493200000 , 1.9661258515092] , [ 1323579600000 , 1.9661258515092] , [ 1323666000000 , 1.0175542221399] , [ 1323752400000 , 0.5024676440828] , [ 1323838800000 , -0.6545437495700] , [ 1323925200000 , -0.8689652158149] , [ 1324011600000 , -0.7645004652824] , [ 1324098000000 , -0.7645004652824] , [ 1324184400000 , -0.7645004652824] , [ 1324270800000 , -1.7880862317039] , [ 1324357200000 , -0.1461682112898] , [ 1324443600000 , -0.5871487877962] , [ 1324530000000 , 0.2867400066741] , [ 1324616400000 , 0.7000618003773] , [ 1324702800000 , 0.7000618003773] , [ 1324789200000 , 0.7000618003773] , [ 1324875600000 , 0.7000618003773] , [ 1324962000000 , 0.4859463316191] , [ 1325048400000 , -0.4119526235861] , [ 1325134800000 , 0.2230991860845] , [ 1325221200000 , 0.1595400012524] , [ 1325307600000 , 0.1595400012524] , [ 1325394000000 , 0.1595400012524] , [ 1325480400000 , 0.1595400012524] , [ 1325566800000 , 1.2638744291023] , [ 1325653200000 , 1.1480591676914] , [ 1325739600000 , 1.4876618741657] , [ 1325826000000 , 1.6476476765120] , [ 1325912400000 , 1.6476476765120] , [ 1325998800000 , 1.6476476765120] , [ 1326085200000 , 2.1063050593731] , [ 1326171600000 , 2.5653649043989] , [ 1326258000000 , 2.8466857983576] , [ 1326344400000 , 3.0747141460071] , [ 1326430800000 , 2.4992620202541] , [ 1326517200000 , 2.4992620202541] , [ 1326603600000 , 2.4992620202541] , [ 1326690000000 , 2.4992620202541] , [ 1326776400000 , 2.2880782376570] , [ 1326862800000 , 3.1353436274553] , [ 1326949200000 , 3.5677616820370] , [ 1327035600000 , 3.5059469003623] , [ 1327122000000 , 3.5059469003623] , [ 1327208400000 , 3.5059469003623] , [ 1327294800000 , 3.6741640726128] , [ 1327381200000 , 3.5476135299444] , [ 1327467600000 , 3.8207752112587] , [ 1327554000000 , 3.8616315638872] , [ 1327640400000 , 4.3254831376284] , [ 1327726800000 , 4.3254831376284] , [ 1327813200000 , 4.3254831376284] , [ 1327899600000 , 4.0133484282063] , [ 1327986000000 , 4.0086992762233] , [ 1328072400000 , 4.6741072621578] , [ 1328158800000 , 5.1853600238372] , [ 1328245200000 , 5.7164828688020] , [ 1328331600000 , 5.7164828688020] , [ 1328418000000 , 5.7164828688020] , [ 1328504400000 , 5.7706486616140] , [ 1328590800000 , 5.5821721041319] , [ 1328677200000 , 5.9281978759001] , [ 1328763600000 , 6.3202608081270] , [ 1328850000000 , 5.4952215782126] , [ 1328936400000 , 5.4952215782126] , [ 1329022800000 , 5.4952215782126] , [ 1329109200000 , 5.6378737590063] , [ 1329195600000 , 5.2228974160623] , [ 1329282000000 , 4.8974412407240] , [ 1329368400000 , 5.7203603398934] , [ 1329454800000 , 6.1518150836713] , [ 1329541200000 , 6.1518150836713] , [ 1329627600000 , 6.1518150836713] , [ 1329714000000 , 6.1518150836713] , [ 1329800400000 , 6.2799444735621] , [ 1329886800000 , 6.1985966532271] , [ 1329973200000 , 6.3441512518544] , [ 1330059600000 , 6.2162658382840] , [ 1330146000000 , 6.2162658382840] , [ 1330232400000 , 6.2162658382840] , [ 1330318800000 , 6.4153940933982] , [ 1330405200000 , 6.5112028076997] , [ 1330491600000 , 5.8186218494908]]
|
55
|
-
}
|
56
|
-
].map(function(line) {
|
57
|
-
line.values = line.values.map(function(d) { return {x: d[0], y: d[1]/100 }})
|
58
|
-
.filter(function(d) {
|
59
|
-
var day = (new Date(d.x)).getDay();
|
60
|
-
return day != 0 && day != 6; //get rid of weekends for this example
|
61
|
-
});
|
62
|
-
return line;
|
63
|
-
});
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
nv.charts.lineChartDaily()
|
75
|
-
.selector('#chart1')
|
76
|
-
//.data(sinAndCos())
|
77
|
-
.data(cumulativeDailyTestData)
|
78
|
-
.build();
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
function sinAndCos() {
|
84
|
-
var sin = [],
|
85
|
-
cos = [],
|
86
|
-
r1 = Math.random(),
|
87
|
-
r2 = Math.random();
|
88
|
-
|
89
|
-
for (var i = 0; i < 100; i++) {
|
90
|
-
sin.push({x: i, voltage: r2 * Math.sin(i/10)});
|
91
|
-
cos.push({x: i, voltage: r1 * Math.cos(i/10)});
|
92
|
-
}
|
93
|
-
|
94
|
-
return [
|
95
|
-
{
|
96
|
-
values: sin,
|
97
|
-
key: "Sine Wave",
|
98
|
-
color: "#ff7f0e"
|
99
|
-
},
|
100
|
-
{
|
101
|
-
values: cos,
|
102
|
-
key: "Cosine Wave",
|
103
|
-
color: "#2ca02c"
|
104
|
-
}
|
105
|
-
];
|
106
|
-
}
|
107
|
-
|
108
|
-
|
109
|
-
</script>
|
@@ -1,173 +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/scatter.js"></script>
|
40
|
-
<script src="../src/models/line.js"></script>
|
41
|
-
<script src="../src/models/historicalBar.js"></script>
|
42
|
-
<script src="../src/models/linePlusBar.js"></script>
|
43
|
-
<script>
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
var valueVsQuantity = [
|
48
|
-
{
|
49
|
-
"key" : "Quantity" ,
|
50
|
-
"bar": true,
|
51
|
-
"values" : [ [ 1136005200000 , 1271000.0] , [ 1138683600000 , 1271000.0] , [ 1141102800000 , 1271000.0] , [ 1143781200000 , 0] , [ 1146369600000 , 0] , [ 1149048000000 , 0] , [ 1151640000000 , 0] , [ 1154318400000 , 0] , [ 1156996800000 , 0] , [ 1159588800000 , 3899486.0] , [ 1162270800000 , 3899486.0] , [ 1164862800000 , 3899486.0] , [ 1167541200000 , 3564700.0] , [ 1170219600000 , 3564700.0] , [ 1172638800000 , 3564700.0] , [ 1175313600000 , 2648493.0] , [ 1177905600000 , 2648493.0] , [ 1180584000000 , 2648493.0] , [ 1183176000000 , 2522993.0] , [ 1185854400000 , 2522993.0] , [ 1188532800000 , 2522993.0] , [ 1191124800000 , 2906501.0] , [ 1193803200000 , 2906501.0] , [ 1196398800000 , 2906501.0] , [ 1199077200000 , 2206761.0] , [ 1201755600000 , 2206761.0] , [ 1204261200000 , 2206761.0] , [ 1206936000000 , 2287726.0] , [ 1209528000000 , 2287726.0] , [ 1212206400000 , 2287726.0] , [ 1214798400000 , 2732646.0] , [ 1217476800000 , 2732646.0] , [ 1220155200000 , 2732646.0] , [ 1222747200000 , 2599196.0] , [ 1225425600000 , 2599196.0] , [ 1228021200000 , 2599196.0] , [ 1230699600000 , 1924387.0] , [ 1233378000000 , 1924387.0] , [ 1235797200000 , 1924387.0] , [ 1238472000000 , 1756311.0] , [ 1241064000000 , 1756311.0] , [ 1243742400000 , 1756311.0] , [ 1246334400000 , 1743470.0] , [ 1249012800000 , 1743470.0] , [ 1251691200000 , 1743470.0] , [ 1254283200000 , 1519010.0] , [ 1256961600000 , 1519010.0] , [ 1259557200000 , 1519010.0] , [ 1262235600000 , 1591444.0] , [ 1264914000000 , 1591444.0] , [ 1267333200000 , 1591444.0] , [ 1270008000000 , 1543784.0] , [ 1272600000000 , 1543784.0] , [ 1275278400000 , 1543784.0] , [ 1277870400000 , 1309915.0] , [ 1280548800000 , 1309915.0] , [ 1283227200000 , 1309915.0] , [ 1285819200000 , 1331875.0] , [ 1288497600000 , 1331875.0] , [ 1291093200000 , 1331875.0] , [ 1293771600000 , 1331875.0] , [ 1296450000000 , 1154695.0] , [ 1298869200000 , 1154695.0] , [ 1301544000000 , 1194025.0] , [ 1304136000000 , 1194025.0] , [ 1306814400000 , 1194025.0] , [ 1309406400000 , 1194025.0] , [ 1312084800000 , 1194025.0] , [ 1314763200000 , 1244525.0] , [ 1317355200000 , 475000.0] , [ 1320033600000 , 475000.0] , [ 1322629200000 , 475000.0] , [ 1325307600000 , 690033.0] , [ 1327986000000 , 690033.0] , [ 1330491600000 , 690033.0] , [ 1333166400000 , 514733.0] , [ 1335758400000 , 514733.0]]
|
52
|
-
} ,
|
53
|
-
|
54
|
-
{
|
55
|
-
"key" : "Price" ,
|
56
|
-
"values" : [ [ 1136005200000 , 71.89] , [ 1138683600000 , 75.51] , [ 1141102800000 , 68.49] , [ 1143781200000 , 62.72] , [ 1146369600000 , 70.39] , [ 1149048000000 , 59.77] , [ 1151640000000 , 57.27] , [ 1154318400000 , 67.96] , [ 1156996800000 , 67.85] , [ 1159588800000 , 76.98] , [ 1162270800000 , 81.08] , [ 1164862800000 , 91.66] , [ 1167541200000 , 84.84] , [ 1170219600000 , 85.73] , [ 1172638800000 , 84.61] , [ 1175313600000 , 92.91] , [ 1177905600000 , 99.8] , [ 1180584000000 , 121.191] , [ 1183176000000 , 122.04] , [ 1185854400000 , 131.76] , [ 1188532800000 , 138.48] , [ 1191124800000 , 153.47] , [ 1193803200000 , 189.95] , [ 1196398800000 , 182.22] , [ 1199077200000 , 198.08] , [ 1201755600000 , 135.36] , [ 1204261200000 , 125.02] , [ 1206936000000 , 143.5] , [ 1209528000000 , 173.95] , [ 1212206400000 , 188.75] , [ 1214798400000 , 167.44] , [ 1217476800000 , 158.95] , [ 1220155200000 , 169.53] , [ 1222747200000 , 113.66] , [ 1225425600000 , 107.59] , [ 1228021200000 , 92.67] , [ 1230699600000 , 85.35] , [ 1233378000000 , 90.13] , [ 1235797200000 , 89.31] , [ 1238472000000 , 105.12] , [ 1241064000000 , 125.83] , [ 1243742400000 , 135.81] , [ 1246334400000 , 142.43] , [ 1249012800000 , 163.39] , [ 1251691200000 , 168.21] , [ 1254283200000 , 185.35] , [ 1256961600000 , 188.5] , [ 1259557200000 , 199.91] , [ 1262235600000 , 210.732] , [ 1264914000000 , 192.063] , [ 1267333200000 , 204.62] , [ 1270008000000 , 235.0] , [ 1272600000000 , 261.09] , [ 1275278400000 , 256.88] , [ 1277870400000 , 251.53] , [ 1280548800000 , 257.25] , [ 1283227200000 , 243.1] , [ 1285819200000 , 283.75] , [ 1288497600000 , 300.98] , [ 1291093200000 , 311.15] , [ 1293771600000 , 322.56] , [ 1296450000000 , 339.32] , [ 1298869200000 , 353.21] , [ 1301544000000 , 348.5075] , [ 1304136000000 , 350.13] , [ 1306814400000 , 347.83] , [ 1309406400000 , 335.67] , [ 1312084800000 , 390.48] , [ 1314763200000 , 384.83] , [ 1317355200000 , 381.32] , [ 1320033600000 , 404.78] , [ 1322629200000 , 382.2] , [ 1325307600000 , 405.0] , [ 1327986000000 , 456.48] , [ 1330491600000 , 542.44] , [ 1333166400000 , 599.55] , [ 1335758400000 , 583.98]]
|
57
|
-
}
|
58
|
-
].map(function(series) {
|
59
|
-
series.values = series.values.map(function(d) { return {x: d[0], y: d[1] } });
|
60
|
-
return series;
|
61
|
-
});
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
var selector = '#chart1',
|
68
|
-
chart = nv.models.linePlusBar(),
|
69
|
-
//data = sinAndCos(),
|
70
|
-
data = valueVsQuantity,
|
71
|
-
xTickFormat = d3.format(',r'),
|
72
|
-
y1TickFormat = d3.format(',f'),
|
73
|
-
y2TickFormat = function(d) { return '$' + d3.format(',f')(d) },
|
74
|
-
duration = 500;
|
75
|
-
|
76
|
-
nv.addGraph({
|
77
|
-
generate: function() {
|
78
|
-
var container = d3.select(selector),
|
79
|
-
width = function() { return parseInt(container.style('width')) },
|
80
|
-
height = function() { return parseInt(container.style('height')) },
|
81
|
-
svg = container.append('svg');
|
82
|
-
|
83
|
-
chart
|
84
|
-
.x(function(d,i) { return i })
|
85
|
-
.width(width)
|
86
|
-
.height(height)
|
87
|
-
.color(d3.scale.category10().range());
|
88
|
-
|
89
|
-
chart.xAxis.tickFormat(function(d) {
|
90
|
-
var dx = data[0].values[d] && data[0].values[d].x || 0;
|
91
|
-
return d3.time.format('%x')(new Date(dx))
|
92
|
-
//return d3.time.format('%x')(new Date(data[0].values[d].x))
|
93
|
-
});
|
94
|
-
|
95
|
-
chart.yAxis1
|
96
|
-
.tickFormat(y1TickFormat)
|
97
|
-
chart.yAxis2
|
98
|
-
.tickFormat(y2TickFormat)
|
99
|
-
|
100
|
-
chart.bars.forceY([0]);
|
101
|
-
//chart.lines.forceY([0]);
|
102
|
-
|
103
|
-
svg
|
104
|
-
.attr('width', width())
|
105
|
-
.attr('height', height())
|
106
|
-
.datum(data)
|
107
|
-
.transition().duration(duration).call(chart);
|
108
|
-
|
109
|
-
return chart;
|
110
|
-
},
|
111
|
-
callback: function(chart) {
|
112
|
-
var showTooltip = function(e) {
|
113
|
-
var offsetElement = document.getElementById(selector.substr(1)),
|
114
|
-
left = e.pos[0] + offsetElement.offsetLeft,
|
115
|
-
top = e.pos[1] + offsetElement.offsetTop,
|
116
|
-
formatY1 = chart.yAxis1.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc.
|
117
|
-
formatY2 = chart.yAxis2.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc.
|
118
|
-
formatX = chart.xAxis.tickFormat(),
|
119
|
-
x = formatX(chart.x()(e, e.pointIndex)),
|
120
|
-
y = e.series.bar ? formatY1(chart.y()(e.point)) : formatY2(chart.y()(e.point));
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
// uses the chart's getX and getY, you may customize if x position is not the same as the value you want
|
125
|
-
// ex. daily data without weekends, x is the index, while you want the date
|
126
|
-
var content = '<h3>' + e.series.key.replace(/\s*\(.*\)/, '') + '</h3>' + //removing the (left/right axis) note from series label in tooltip
|
127
|
-
'<p>' +
|
128
|
-
y + ' at ' + x +
|
129
|
-
'</p>';
|
130
|
-
|
131
|
-
nv.tooltip.show([left, top], content, chart.y()(e.point) < 0 ? 'n' : 's' );
|
132
|
-
};
|
133
|
-
|
134
|
-
chart.dispatch.on('tooltipShow', showTooltip);
|
135
|
-
chart.dispatch.on('tooltipHide', nv.tooltip.cleanup);
|
136
|
-
|
137
|
-
|
138
|
-
window.onresize= function() {
|
139
|
-
// now that width and height are functions, should be automatic..of course you can always override them
|
140
|
-
d3.select('#chart1 svg')
|
141
|
-
.attr('width', chart.width()()) //need to set SVG dimensions, chart is not aware of the SVG component
|
142
|
-
.attr('height', chart.height()())
|
143
|
-
.call(chart);
|
144
|
-
};
|
145
|
-
}
|
146
|
-
});
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
function sinAndCos() {
|
151
|
-
var sin = [],
|
152
|
-
cos = [];
|
153
|
-
|
154
|
-
for (var i = 0; i < 100; i++) {
|
155
|
-
sin.push({x: i, y: Math.sin(i/10) + 1});
|
156
|
-
cos.push({x: i, y: .5 * Math.cos(i/10) + .5});
|
157
|
-
}
|
158
|
-
|
159
|
-
return [
|
160
|
-
{
|
161
|
-
values: sin,
|
162
|
-
key: "Sine Wave",
|
163
|
-
bar: true
|
164
|
-
},
|
165
|
-
{
|
166
|
-
values: cos,
|
167
|
-
key: "Cosine Wave"
|
168
|
-
}
|
169
|
-
];
|
170
|
-
}
|
171
|
-
|
172
|
-
|
173
|
-
</script>
|