4 <title>Plotters demo
</title>
5 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
6 <script type=
"text/javascript" src=
"../extras/smooth-plotter.js"></script>
8 <style type=
"text/css">
26 <p>This plotter draws smooth lines between points using bezier curves.
</p>
27 <p class=
"smoother">Smoothing:
<input type=
"range" id=
"smoothing-amount" min=
0 max=
0.7 step=
0.01 value=
0.33> <span id=
"smoothing-param">0.33</span></p>
28 <div id=
"smooth-line" class=
"chart"></div>
30 <p>View source to see how this works. You'll have to source
<code>extras/smooth-plotter.js
</code> in addition to dygraphs to get this feature. See the
<a href=
"https://github.com/danvk/dygraphs/pull/469">pull request
</a> that introduced this plotter to learn more about how it smooths your curves.
</p>
32 <script type=
"text/javascript">
33 // Smooth line plotter
34 var functionData = [];
35 var vs = [
10,
20,
40,
0,
30,
15,
25,
60,
35,
45];
36 for (var i =
0; i <
10; i++) {
38 functionData.push([i, v, v]);
42 function drawSmoothPlot() {
43 g6 = new Dygraph(document.getElementById('smooth-line'),
46 labels: ['Year', 'Straight', 'Smoothed'],
49 color: 'rgba(
0,
0,
0,
0.33)',
55 plotter: smoothPlotter,
66 var smoothRangeEl = document.getElementById('smoothing-amount');
67 smoothRangeEl.addEventListener('input', function() {
68 var param = parseFloat(smoothRangeEl.value);
69 smoothPlotter.smoothing = param;
70 document.getElementById('smoothing-param').innerHTML = param;