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.

52 lines
1.3 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. ### html ###
  2. <h4>CurvedLines: random data points </h4>
  3. <div id="flotContainer" class="chart-style"></div>
  4. <h4>CurvedLines: internally created helper points</h4>
  5. <div id="flotContainer2" class="chart-style"></div>
  6. ### css ###
  7. .chart-style {
  8. width: 600px;
  9. height: 260px;
  10. }
  11. ### javascript ###
  12. //random data
  13. var d1 = []; var last = 0;
  14. for (var i = 0; i <= 40; i += (2 + parseInt(Math.random() * 5))) {
  15. last = last + ((Math.random() * 3) - 1.5)
  16. d1.push([i, parseInt(last)]);
  17. }
  18. //flot options
  19. var options = {
  20. series: {
  21. curvedLines: {
  22. active: true,
  23. nrSplinePoints: 20 // <- control nr of helper points
  24. } // between two poins
  25. }
  26. };
  27. //plotting
  28. $.plot($("#flotContainer"),[
  29. { //curved line
  30. data: d1,
  31. lines: {show: true, lineWidth: 3},
  32. curvedLines: {apply: true } // <- curve line
  33. }, { //original data points
  34. data: d1,
  35. points: {show: true}
  36. }
  37. ], options);
  38. $.plot($("#flotContainer2"),[
  39. { // <- helper points that are used to curve the lines
  40. data: d1,
  41. color: '#CC0000',
  42. points: {show: true},
  43. curvedLines: {apply: true} //<- "curve" points
  44. }
  45. ], options);