You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <title>Demonstration of how CurvedLines creates additional 'Helper Points' to plot line | CurvedLines</title>
  4. <style>
  5. .chart-style {
  6. width: 600px;
  7. height: 260px;
  8. }
  9. </style>
  10. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  11. <script type="text/javascript" src="https://cdn.rawgit.com/flot/flot/v0.8.3/jquery.flot.js"></script>
  12. <script type="text/javascript" src="https://rawgit.com/MichaelZinsmaier/CurvedLines/master/curvedLines.js"></script>
  13. <script type="text/javascript">
  14. $(function() {
  15. //random data
  16. var d1 = []; var last = 0;
  17. for (var i = 0; i <= 40; i += (2 + parseInt(Math.random() * 5))) {
  18. last = last + ((Math.random() * 3) - 1.5)
  19. d1.push([i, parseInt(last)]);
  20. }
  21. //flot options
  22. var options = {
  23. series: {
  24. curvedLines: {
  25. active: true,
  26. nrSplinePoints: 20 // <- control nr of helper points
  27. } // between two poins
  28. }
  29. };
  30. //plotting
  31. $.plot($("#flotContainer"),[
  32. { //curved line
  33. data: d1,
  34. lines: {show: true, lineWidth: 3},
  35. curvedLines: {apply: true } // <- curve line
  36. }, { //original data points
  37. data: d1,
  38. points: {show: true}
  39. }
  40. ], options);
  41. $.plot($("#flotContainer2"),[
  42. { // <- helper points that are used to curve the lines
  43. data: d1,
  44. color: '#CC0000',
  45. points: {show: true},
  46. curvedLines: {apply: true} //<- "curve" points
  47. }
  48. ], options);
  49. });
  50. </script>
  51. </head>
  52. <h3>Demonstration of how CurvedLines creates additional 'Helper Points' to plot line</h3>
  53. <body>
  54. <h4>CurvedLines: random data points </h4>
  55. <div id="flotContainer" class="chart-style"></div>
  56. <h4>CurvedLines: internally created helper points</h4>
  57. <div id="flotContainer2" class="chart-style"></div>
  58. <a href="index.html">Return to CurvedLines Examples list</a>
  59. </body>
  60. </html>