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,163 +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
|
-
/*
|
7
|
-
* {
|
8
|
-
margin: 0;
|
9
|
-
padding: 0;
|
10
|
-
border: 0;
|
11
|
-
}
|
12
|
-
*/
|
13
|
-
|
14
|
-
|
15
|
-
body {
|
16
|
-
font-family: sans-serif;
|
17
|
-
}
|
18
|
-
|
19
|
-
svg {
|
20
|
-
top: 10px;
|
21
|
-
left: 10px;
|
22
|
-
position: absolute;
|
23
|
-
}
|
24
|
-
|
25
|
-
svg > g > path {
|
26
|
-
pointer-events: none;
|
27
|
-
}
|
28
|
-
|
29
|
-
.nv-horizonBackground {
|
30
|
-
fill: none;
|
31
|
-
stroke: none;
|
32
|
-
pointer-events: all;
|
33
|
-
}
|
34
|
-
|
35
|
-
#horizon-controls {
|
36
|
-
position: absolute;
|
37
|
-
width: 940px;
|
38
|
-
padding: 10px;
|
39
|
-
z-index: 1;
|
40
|
-
}
|
41
|
-
|
42
|
-
#horizon-bands {
|
43
|
-
float: right;
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
</style>
|
48
|
-
<body>
|
49
|
-
|
50
|
-
<div id="wrap">
|
51
|
-
|
52
|
-
<div id="horizon-controls">
|
53
|
-
<input name="mode" type="radio" value="mirror" id="horizon-mode-mirror" checked><label for="horizon-mode-mirror"> Mirror</label>
|
54
|
-
<input name="mode" type="radio" value="offset" id="horizon-mode-offset"><label for="horizon-mode-offset"> Offset</label>
|
55
|
-
<span id="horizon-bands"><span id="horizon-bands-value">1</span> <button class="first">−</button><button class="last">+</button></span>
|
56
|
-
</div>
|
57
|
-
<div><svg id="chart1"></svg></div>
|
58
|
-
|
59
|
-
</div>
|
60
|
-
|
61
|
-
|
62
|
-
<script src="../lib/d3.v2.js"></script>
|
63
|
-
<script src="../lib/horizon.js"></script>
|
64
|
-
<script src="../nv.d3.js"></script>
|
65
|
-
<script src="../src/utils.js"></script>
|
66
|
-
<script>
|
67
|
-
|
68
|
-
|
69
|
-
//TODO: create a nv.models.horizonChart model
|
70
|
-
// (if need be an nv.models.horizon model as well, but might get away with just using d3.horizon)
|
71
|
-
// the horizontChart model should have a "tooltip" like functionality that shows a point over the
|
72
|
-
// current value based on the mouse's x position
|
73
|
-
|
74
|
-
var width = 960,
|
75
|
-
height = 300;
|
76
|
-
|
77
|
-
nv.addGraph(function() {
|
78
|
-
var data = sine();
|
79
|
-
|
80
|
-
var chart = d3.horizon()
|
81
|
-
.width(width)
|
82
|
-
.height(height)
|
83
|
-
.bands(1)
|
84
|
-
.mode("mirror")
|
85
|
-
.interpolate("basis");
|
86
|
-
|
87
|
-
var svg = d3.select('#chart1').attr('width', width).attr('height', height);
|
88
|
-
|
89
|
-
var bg = svg.append('rect').attr('class', 'nv-horizonBackground').attr('height', height).attr('width', width);
|
90
|
-
|
91
|
-
svg.datum(data).call(chart);
|
92
|
-
|
93
|
-
var point = svg.append('circle').attr('class', 'nv-hoverPoint')
|
94
|
-
.attr('r', '4')
|
95
|
-
.attr('cx', -3)
|
96
|
-
.attr('cy', -3);
|
97
|
-
|
98
|
-
// Enable mode buttons.
|
99
|
-
d3.selectAll("#horizon-controls input[name=mode]").on("change", function() {
|
100
|
-
svg.call(chart.duration(0).mode(this.value));
|
101
|
-
});
|
102
|
-
|
103
|
-
// Enable bands buttons.
|
104
|
-
d3.selectAll("#horizon-bands button").data([-1, 1]).on("click", function(d) {
|
105
|
-
var n = Math.max(1, chart.bands() + d);
|
106
|
-
d3.select("#horizon-bands-value").text(n);
|
107
|
-
svg.call(chart.duration(1000).bands(n).height(height / n));
|
108
|
-
|
109
|
-
//just updating point temporarily here to have it not be visible on band change until user moves his mouse over the chart
|
110
|
-
point
|
111
|
-
.attr('cx', -3)
|
112
|
-
.attr('cy', -3)
|
113
|
-
});
|
114
|
-
|
115
|
-
|
116
|
-
//****THE CHANGES MADE TO THIS EXAMPLE BY ME ARE VERY UGLY.... TODO: Fix/Clean up after all functionality is correct
|
117
|
-
bg.on('mousemove', function() {
|
118
|
-
var m1 = d3.mouse(this);
|
119
|
-
var x = m1[0];
|
120
|
-
var scales = svg.node().__chart__;
|
121
|
-
var i = Math.round( scales.x.invert(x) );
|
122
|
-
//var y = (data[i][1] < 0 || chart.mode() == 'mirror' ? height : 0) - scales.y(chart.mode() == 'mirror' ? Math.abs(data[i][1]) : data[i][1] );
|
123
|
-
var y = height - scales.y(chart.mode() == 'mirror' ? Math.abs(data[i][1]) : data[i][1] ) - (chart.mode() == 'offset' && data[i][1] < 0 ? height : 0 );
|
124
|
-
var t = scales.t(data[i][1]);
|
125
|
-
var bandRange = scales.y.range()[1];
|
126
|
-
|
127
|
-
y = y % (height / chart.bands());
|
128
|
-
//nv.log(y, height, y % height);
|
129
|
-
|
130
|
-
//nv.log(scales.y.range(), scales.y.domain());
|
131
|
-
|
132
|
-
//nv.log( x, i, data[i], y )
|
133
|
-
//nv.log(scales);
|
134
|
-
|
135
|
-
point
|
136
|
-
.attr('cx', scales.x(i))
|
137
|
-
.attr('cy', y)
|
138
|
-
.attr('transform',
|
139
|
-
'translate(0,' + chart.bands + ')'
|
140
|
-
);
|
141
|
-
|
142
|
-
//var m2 = d3.mouse(d3.select('body').node());
|
143
|
-
//nv.log(m1, m2);
|
144
|
-
//nv.log(d3.event, this, d3.mouse(this));
|
145
|
-
});
|
146
|
-
|
147
|
-
return chart;
|
148
|
-
});
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
function sine() {
|
153
|
-
var sin = [];
|
154
|
-
|
155
|
-
for (var i = 0; i < 200; i++) {
|
156
|
-
sin.push([ i, Math.sin(i/10) + .2 ]);
|
157
|
-
}
|
158
|
-
|
159
|
-
return sin;
|
160
|
-
}
|
161
|
-
|
162
|
-
|
163
|
-
</script>
|
Binary file
|
Binary file
|
@@ -1,126 +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
|
-
body {
|
7
|
-
overflow-y:scroll;
|
8
|
-
}
|
9
|
-
|
10
|
-
</style>
|
11
|
-
<body>
|
12
|
-
|
13
|
-
<div id="example1" style="width:600px"></div>
|
14
|
-
|
15
|
-
|
16
|
-
<script src="../lib/d3.v2.js"></script>
|
17
|
-
<script src="../nv.d3.js"></script>
|
18
|
-
<script src="../src/models/indentedTree.js"></script>
|
19
|
-
<script>
|
20
|
-
|
21
|
-
// THIS API WILL BE CHANGING!! this was ported from a different graphing collection, its only been halfway ported to the nvd3 style
|
22
|
-
|
23
|
-
var testTree = [{
|
24
|
-
key: 'NVD3',
|
25
|
-
url: 'http://novus.github.com/nvd3',
|
26
|
-
values: [
|
27
|
-
{
|
28
|
-
key: "Charts",
|
29
|
-
_values: [
|
30
|
-
{
|
31
|
-
key: "Simple Line",
|
32
|
-
type: "Historical",
|
33
|
-
url: "http://novus.github.com/nvd3/ghpages/line.html"
|
34
|
-
},
|
35
|
-
{
|
36
|
-
key: "Scatter / Bubble",
|
37
|
-
type: "Snapshot",
|
38
|
-
url: "http://novus.github.com/nvd3/ghpages/scatter.html"
|
39
|
-
},
|
40
|
-
{
|
41
|
-
key: "Stacked / Stream / Expanded Area",
|
42
|
-
type: "Historical",
|
43
|
-
url: "http://novus.github.com/nvd3/ghpages/stackedArea.html"
|
44
|
-
},
|
45
|
-
{
|
46
|
-
key: "Discrete Bar",
|
47
|
-
type: "Snapshot",
|
48
|
-
url: "http://novus.github.com/nvd3/ghpages/discreteBar.html"
|
49
|
-
},
|
50
|
-
{
|
51
|
-
key: "Grouped / Stacked Multi-Bar",
|
52
|
-
type: "Snapshot / Historical",
|
53
|
-
url: "http://novus.github.com/nvd3/ghpages/multiBar.html"
|
54
|
-
},
|
55
|
-
{
|
56
|
-
key: "Horizontal Grouped Bar",
|
57
|
-
type: "Snapshot",
|
58
|
-
url: "http://novus.github.com/nvd3/ghpages/multiBarHorizontal.html"
|
59
|
-
},
|
60
|
-
{
|
61
|
-
key: "Line and Bar Combo",
|
62
|
-
type: "Historical",
|
63
|
-
url: "http://novus.github.com/nvd3/ghpages/linePlusBar.html"
|
64
|
-
},
|
65
|
-
{
|
66
|
-
key: "Cumulative Line",
|
67
|
-
type: "Historical",
|
68
|
-
url: "http://novus.github.com/nvd3/ghpages/cumulativeLine.html"
|
69
|
-
},
|
70
|
-
{
|
71
|
-
key: "Line with View Finder",
|
72
|
-
type: "Historical",
|
73
|
-
url: "http://novus.github.com/nvd3/ghpages/lineWithFocus.html"
|
74
|
-
}
|
75
|
-
]
|
76
|
-
},
|
77
|
-
{
|
78
|
-
key: "Chart Components",
|
79
|
-
_values: [
|
80
|
-
{
|
81
|
-
key: "Legend",
|
82
|
-
type: "Universal",
|
83
|
-
url: "http://novus.github.com/nvd3/examples/legend.html"
|
84
|
-
}
|
85
|
-
]
|
86
|
-
}
|
87
|
-
]
|
88
|
-
}];
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
var testColumns = [
|
93
|
-
{
|
94
|
-
key: 'key',
|
95
|
-
label: 'Name',
|
96
|
-
showCount: true,
|
97
|
-
width: '75%',
|
98
|
-
type: 'text',
|
99
|
-
classes: function(d) { return d.url ? 'clickable name' : 'name' },
|
100
|
-
click: function(d) {
|
101
|
-
if (d.url) window.location.href = d.url;
|
102
|
-
}
|
103
|
-
},
|
104
|
-
{
|
105
|
-
key: 'type',
|
106
|
-
label: 'Type',
|
107
|
-
width: '25%',
|
108
|
-
type: 'text'
|
109
|
-
}
|
110
|
-
];
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
nv.addGraph(function() {
|
115
|
-
var chart = nv.models.indentedTree()
|
116
|
-
.columns(testColumns);
|
117
|
-
|
118
|
-
d3.select('#example1')
|
119
|
-
.datum(testTree)
|
120
|
-
.call(chart);
|
121
|
-
});
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
</script>
|
@@ -1,75 +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
|
-
<body>
|
8
|
-
|
9
|
-
<svg id="test1"></svg>
|
10
|
-
|
11
|
-
<script src="../lib/d3.v2.js"></script>
|
12
|
-
<script src="../nv.d3.js"></script>
|
13
|
-
<script src="../src/models/legend.js"></script>
|
14
|
-
<script>
|
15
|
-
|
16
|
-
|
17
|
-
//Format A
|
18
|
-
nv.addGraph({
|
19
|
-
generate: function() {
|
20
|
-
var width = 500,
|
21
|
-
height = 20;
|
22
|
-
|
23
|
-
var chart = nv.models.legend()
|
24
|
-
.width(width)
|
25
|
-
.height(height);
|
26
|
-
|
27
|
-
chart.dispatch.on('legendClick', function(d,i) { console.log(d,i) });
|
28
|
-
|
29
|
-
//chart.xaxis.tickFormat(d3.format(".02f"))
|
30
|
-
|
31
|
-
d3.select('#test1')
|
32
|
-
.attr('width', width)
|
33
|
-
.attr('height', height)
|
34
|
-
.datum(sinAndCos())
|
35
|
-
.call(chart);
|
36
|
-
|
37
|
-
return chart;
|
38
|
-
},
|
39
|
-
callback: function(graph) {
|
40
|
-
var chart = graph,
|
41
|
-
height = chart.height();
|
42
|
-
|
43
|
-
d3.select('#test1')
|
44
|
-
.attr('height', height)
|
45
|
-
.call(chart)
|
46
|
-
}
|
47
|
-
});
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
function sinAndCos() {
|
52
|
-
return [
|
53
|
-
{
|
54
|
-
key: "Sine Wave"
|
55
|
-
},
|
56
|
-
{
|
57
|
-
key: "A Very Long Series Label"
|
58
|
-
},
|
59
|
-
{
|
60
|
-
key: "A Very Long Series Label"
|
61
|
-
},
|
62
|
-
{
|
63
|
-
key: "A Very Long Series Label"
|
64
|
-
},
|
65
|
-
{
|
66
|
-
key: "Cosine Wave"
|
67
|
-
},
|
68
|
-
{
|
69
|
-
key: "Another test label"
|
70
|
-
}
|
71
|
-
];
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
</script>
|
@@ -1,95 +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
|
-
body {
|
7
|
-
overflow-y:scroll;
|
8
|
-
}
|
9
|
-
|
10
|
-
</style>
|
11
|
-
<body>
|
12
|
-
|
13
|
-
<svg id="test1"></svg>
|
14
|
-
|
15
|
-
<script src="../lib/d3.v2.js"></script>
|
16
|
-
<script src="../nv.d3.js"></script>
|
17
|
-
<script src="../src/models/legend.js"></script>
|
18
|
-
<script src="../src/models/line.js"></script>
|
19
|
-
<script>
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
//Format A
|
24
|
-
nv.addGraph({
|
25
|
-
generate: function() {
|
26
|
-
var width = nv.utils.windowSize().width - 40,
|
27
|
-
height = nv.utils.windowSize().height - 40;
|
28
|
-
|
29
|
-
var chart = nv.models.line()
|
30
|
-
.width(width)
|
31
|
-
.height(height)
|
32
|
-
.margin({top: 20, right: 20, bottom: 20, left: 20})
|
33
|
-
|
34
|
-
|
35
|
-
d3.select('#test1')
|
36
|
-
.attr('width', width)
|
37
|
-
.attr('height', height)
|
38
|
-
.datum(sinAndCos())
|
39
|
-
.call(chart);
|
40
|
-
|
41
|
-
return chart;
|
42
|
-
},
|
43
|
-
callback: function(graph) {
|
44
|
-
window.onresize = function() {
|
45
|
-
var width = nv.utils.windowSize().width - 40,
|
46
|
-
height = nv.utils.windowSize().height - 40,
|
47
|
-
margin = graph.margin();
|
48
|
-
|
49
|
-
|
50
|
-
if (width < margin.left + margin.right + 20)
|
51
|
-
width = margin.left + margin.right + 20;
|
52
|
-
|
53
|
-
if (height < margin.top + margin.bottom + 20)
|
54
|
-
height = margin.top + margin.bottom + 20;
|
55
|
-
|
56
|
-
|
57
|
-
graph
|
58
|
-
.width(width)
|
59
|
-
.height(height);
|
60
|
-
|
61
|
-
d3.select('#test1')
|
62
|
-
.attr('width', width)
|
63
|
-
.attr('height', height)
|
64
|
-
.call(graph);
|
65
|
-
};
|
66
|
-
}
|
67
|
-
});
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
function sinAndCos() {
|
72
|
-
var sin = [],
|
73
|
-
cos = [];
|
74
|
-
|
75
|
-
for (var i = 0; i < 100; i++) {
|
76
|
-
sin.push({x: i, y: Math.sin(i/10)});
|
77
|
-
cos.push({x: i, y: .5 * Math.cos(i/10)});
|
78
|
-
}
|
79
|
-
|
80
|
-
return [
|
81
|
-
{
|
82
|
-
values: sin,
|
83
|
-
key: "Sine Wave",
|
84
|
-
color: "#ff7f0e"
|
85
|
-
},
|
86
|
-
{
|
87
|
-
values: cos,
|
88
|
-
key: "Cosine Wave",
|
89
|
-
color: "#2ca02c"
|
90
|
-
}
|
91
|
-
];
|
92
|
-
}
|
93
|
-
|
94
|
-
|
95
|
-
</script>
|