GoogleChartsExamples.st 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. Smalltalk current createPackage: 'GoogleChartsExamples' properties: #{}!
  2. GaugeChart subclass: #GaugeChartExample
  3. instanceVariableNames: ''
  4. package: 'GoogleChartsExamples'!
  5. !GaugeChartExample methodsFor: 'not yet classified'!
  6. makeData
  7. "Example Gauge Data"
  8. ^ self arrayToDataTable: { {'Label'.'Value'}.
  9. {'Memory' . 80}.
  10. {'CPU' . 55}.
  11. {'Network' . 68}}
  12. !
  13. makeOptions
  14. "Example Gauge options"
  15. ^<{width:400, heigth:120,
  16. redFrom:90,redTo:100,
  17. yellowFrom:75,yellowTo:90,
  18. minorTicks:5}>
  19. ! !
  20. GeoChart subclass: #GeoChartExample
  21. instanceVariableNames: ''
  22. package: 'GoogleChartsExamples'!
  23. !GeoChartExample methodsFor: 'not yet classified'!
  24. makeData
  25. "Example Geo Data"
  26. ^ self arrayToDataTable: {
  27. {'City'. 'Population' . 'Area'}.
  28. {'Rome'. 2761477 . 1285.31}.
  29. {'Milan'. 1324110 . 181.76}.
  30. {'Naples'. 959574 . 117.27}.
  31. {'Turin'. 907563 . 130.17}.
  32. {'Palermo'. 655875 . 158.9}.
  33. {'Genoa'. 607906 . 243.60}.
  34. {'Bologna'. 380181 . 140.7}.
  35. {'Florence'. 371282 . 102.41}.
  36. {'Fiumicino'. 67370 . 213.44}.
  37. {'Anzio'. 52192 . 43.43}.
  38. {'Ciampino'. 38262 . 11}
  39. }
  40. !
  41. makeOptions
  42. "Example Geo Options"
  43. ^<{
  44. region: 'IT',
  45. displayMode: 'markers',
  46. colorAxis: {colors: ['green', 'blue']}
  47. }>
  48. ! !
  49. ChartApp subclass: #IndexChartApp
  50. instanceVariableNames: ''
  51. package: 'GoogleChartsExamples'!
  52. !IndexChartApp methodsFor: 'not yet classified'!
  53. begin
  54. "Start the executiong of the ExampleChartApp by connecting each button/graphic pair"
  55. PieChartExample new chartId:'pie_chart_div';drawChart.
  56. ^super begin
  57. ! !
  58. !IndexChartApp class methodsFor: 'not yet classified'!
  59. neededVisualizationPackages
  60. "This App only needs a corechart package."
  61. ^{'corechart'}
  62. ! !
  63. PieChart subclass: #PieChartExample
  64. instanceVariableNames: ''
  65. package: 'GoogleChartsExamples'!
  66. !PieChartExample methodsFor: 'not yet classified'!
  67. makeData
  68. "return a DataTable of example Pie Chart data"
  69. ^ self arrayToDataTable: { {'Task'.'Hours per Day'}.
  70. {'Work' . 11}.
  71. {'Eat'.2}.
  72. {'Commute'.2}.
  73. {'Watch TV'.2}.
  74. {'Snooze'.7}}
  75. !
  76. makeOptions
  77. "Return a Dictionary of the options in this case only a title"
  78. ^#{'title' -> 'My Daily Activities'}
  79. ! !
  80. ChartApp subclass: #PopupChartApp
  81. instanceVariableNames: ''
  82. package: 'GoogleChartsExamples'!
  83. !PopupChartApp methodsFor: 'not yet classified'!
  84. begin
  85. "Start the executiong of the ExampleChartApp by connecting each button/graphic pair"
  86. ChartButton popUpChart:(PieChartExample chartId:'pie_chart_div') atDom:'#popPieChart' .
  87. ChartButton popUpChart:(ScatterChartExample chartId:'scatter_chart_div') atDom:'#popScatterChart'.
  88. ChartButton popUpChart:(GaugeChartExample chartId:'gauge_chart_div') atDom:'#popGaugeChart'.
  89. ChartButton popUpChart:(GeoChartExample chartId:'geo_markers_chart_div') atDom: '#popGeoMarkersChart'.
  90. ^super begin
  91. ! !
  92. !PopupChartApp class methodsFor: 'not yet classified'!
  93. neededVisualizationPackages
  94. "This is a hook for subclasses to define which visualization packages to load."
  95. ^{'corechart'.'gauge'.'geochart'}
  96. ! !
  97. ScatterChart subclass: #ScatterChartExample
  98. instanceVariableNames: ''
  99. package: 'GoogleChartsExamples'!
  100. !ScatterChartExample methodsFor: 'not yet classified'!
  101. makeData
  102. "Return the example dataset"
  103. ^ self arrayToDataTable: {
  104. {'Age'.'Weight'}.
  105. {8 . 11} .
  106. { 4 . 5.5} .
  107. { 11 . 14 } .
  108. { 4 . 5}.
  109. {3 . 3} .
  110. {6.5 . 7}}
  111. !
  112. makeOptions
  113. "options for example dataset"
  114. ^<{
  115. title: 'Age vs. Weight comparison',
  116. hAxis: {title: 'Age', minValue: 0, maxValue: 15},
  117. vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
  118. legend: 'none'
  119. }>
  120. ! !