trial-1.fan 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using fwt
  2. using gfx
  3. using swtChartWrapper
  4. class Trial1
  5. {
  6. public static Void main ()
  7. {
  8. // define the series of data points to display
  9. series := LineSeries
  10. {
  11. label = "line series"
  12. points = [0.0f, 0.4f, 0.7f, 0.9f, 1.0f, 0.9f, 0.7f, 0.4f, 0.0f, -0.4f, -0.7f, -0.9f, -1.0f, -0.9f, -0.7f, -0.4f]
  13. }
  14. chart := Chart
  15. {
  16. title.text = "Line Chart Example"
  17. xAxis.title.text = "Data Points"
  18. yAxis.title.text = "Amplitude"
  19. data = [series]
  20. }
  21. // define a window to display the chart in
  22. Window
  23. {
  24. title = "Example Chart"
  25. size = Size(450, 350)
  26. EdgePane
  27. {
  28. top = Button
  29. {
  30. text = "click"
  31. onAction.add |Event e|
  32. {
  33. chart.yAxis.range = [-5.0f, 10.0f]
  34. chart.xAxis.zoomInAt (20.0f)
  35. }
  36. }
  37. center = chart
  38. left = Button
  39. {
  40. text = "Zoom in"
  41. onAction.add |Event e|
  42. {
  43. chart.zoomIn
  44. }
  45. }
  46. right = Button
  47. {
  48. text = "Zoom out"
  49. onAction.add |Event e|
  50. {
  51. chart.zoomOut
  52. }
  53. }
  54. bottom = Button
  55. {
  56. text = "Info"
  57. onAction.add |Event e|
  58. {
  59. echo ("xAxis range: " + chart.xAxis.range)
  60. echo ("yAxis range: " + chart.yAxis.range)
  61. }
  62. }
  63. },
  64. }.open
  65. }
  66. }