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.

49 lines
1.2 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. ### html ###
  2. <h4>CurvedLines: with standard settings (shows effects of tension parameter)</h4>
  3. <div id="flotContainer" class="chart-style"></div>
  4. <h4>CurvedLines: with monotonicFit (no overshooting/wiggles) </h4>
  5. <div id="flotContainer2" class="chart-style"></div>
  6. ### css ###
  7. .chart-style {
  8. width: 400px;
  9. height: 240px;
  10. }
  11. ### javascript ###
  12. //data
  13. var d1 = [[20, 20], [25, 50], [27.5, 35], [30, 20], [35, 20]];
  14. //flot options
  15. var options = {
  16. series: {
  17. curvedLines: {active: true}
  18. }
  19. };
  20. //plotting
  21. $.plot($("#flotContainer"),[
  22. {
  23. data: d1, color: '#2b8cbe',
  24. lines: {show: true, lineWidth: 3},
  25. //choose tension from [0,1] to see overshooting effects (0.5 is default)
  26. curvedLines: {apply: true, tension: 1}
  27. }, {
  28. data: d1, color: '#f03b20',
  29. points: {show: true}
  30. }
  31. ], options);
  32. $.plot($("#flotContainer2"),[
  33. {
  34. data: d1, color: '#2b8cbe',
  35. lines: {show: true, lineWidth: 3},
  36. //monotonicFit enforces monotonicity
  37. curvedLines: {apply: true, monotonicFit: true}
  38. }, {
  39. data: d1, color: '#f03b20',
  40. points: {show: true}
  41. }
  42. ], options);