4 <link rel=
"stylesheet" href=
"../dist/dygraph.css">
5 <title>Plotters demo
</title>
6 <script type=
"text/javascript" src=
"../dist/dygraph.js"></script>
7 <script type=
"text/javascript" src=
"../src/extras/smooth-plotter.js"></script>
9 <style type=
"text/css">
27 <p>This plotter draws smooth lines between points using bezier curves.
</p>
28 <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>
29 <div id=
"smooth-line" class=
"chart"></div>
31 <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>
33 <script type=
"text/javascript">
34 // Smooth line plotter
35 var functionData = [];
36 var vs = [
10,
20,
40,
0,
30,
15,
25,
60,
35,
45];
37 for (var i =
0; i <
10; i++) {
39 functionData.push([i, v, v]);
43 function drawSmoothPlot() {
44 g6 = new Dygraph(document.getElementById('smooth-line'),
47 labels: ['Year', 'Straight', 'Smoothed'],
50 color: 'rgba(
0,
0,
0,
0.33)',
56 plotter: smoothPlotter,
67 var smoothRangeEl = document.getElementById('smoothing-amount');
68 smoothRangeEl.addEventListener('input', function() {
69 var param = parseFloat(smoothRangeEl.value);
70 smoothPlotter.smoothing = param;
71 document.getElementById('smoothing-param').innerHTML = param;