123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 |
- smalltalk.addPackage('GoogleCharts', {});
- smalltalk.addClass('ChartApp', smalltalk.Object, [], 'GoogleCharts');
- smalltalk.ChartApp.comment="A chart app is an example App which loads the google JSAPI and visualization API."
- smalltalk.addMethod(
- "_begin",
- smalltalk.method({
- selector: "begin",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "begin\x0a\x09\x22Start the executiong of the ChartApp\x22\x0a\x09^self",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartApp);
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- smalltalk.send(smalltalk.send(self,"_class",[]),"_loadGoogleLoader_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_class",[]),"_loadVisualization_",[(function(){
- return smalltalk.send(self,"_begin",[]);
- })]);
- })]);
- return self},
- args: [],
- source: "initialize\x0a\x09\x22Load my external JS\x22\x0a self class loadGoogleLoader:[self class loadVisualization:[self begin]]\x0a ",
- messageSends: ["loadGoogleLoader:", "loadVisualization:", "begin", "class"],
- referencedClasses: []
- }),
- smalltalk.ChartApp);
- smalltalk.addMethod(
- "_loadGoogleLoader_",
- smalltalk.method({
- selector: "loadGoogleLoader:",
- category: 'not yet classified',
- fn: function (callback){
- var self=this;
- $.ajax({url:"https://www.google.com/jsapi",dataType:"script",success:callback});;
- ;
- return self},
- args: ["callback"],
- source: "loadGoogleLoader: callback\x0a\x09\x22Load the Google JSAPI - Use JQuery.ajax() since that is available\x22\x0a\x09<$.ajax({url:\x22https://www.google.com/jsapi\x22,dataType:\x22script\x22,success:callback});>",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartApp.klass);
- smalltalk.addMethod(
- "_loadVisualization_",
- smalltalk.method({
- selector: "loadVisualization:",
- category: 'not yet classified',
- fn: function (callback){
- var self=this;
- var packages;
- packages=smalltalk.send(self,"_neededVisualizationPackages",[]);
- google.load("visualization","1",{"callback" : callback , "packages":packages});;
- ;
- return self},
- args: ["callback"],
- source: "loadVisualization: callback\x0a\x09\x22Use google.load() to load visualization and load the needed packages\x22\x0a |packages|\x0a packages := self neededVisualizationPackages.\x0a <google.load(\x22visualization\x22,\x221\x22,{\x22callback\x22 : callback , \x22packages\x22:packages});>",
- messageSends: ["neededVisualizationPackages"],
- referencedClasses: []
- }),
- smalltalk.ChartApp.klass);
- smalltalk.addMethod(
- "_neededVisualizationPackages",
- smalltalk.method({
- selector: "neededVisualizationPackages",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- var $1;
- $1=[];
- return $1;
- },
- args: [],
- source: "neededVisualizationPackages\x0a\x22This is a hook for subclasses to define which visualization packages to load.\x22\x0a\x09^{}",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartApp.klass);
- smalltalk.addClass('ChartButton', smalltalk.Object, ['element', 'clickBlock'], 'GoogleCharts');
- smalltalk.addMethod(
- "_activate",
- smalltalk.method({
- selector: "activate",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- var button;
- button=smalltalk.send(smalltalk.send(self,"_element",[]),"_asJQuery",[]);
- smalltalk.send(button,"_click_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_clickBlock",[]),"_value",[]);
- })]);
- return self},
- args: [],
- source: "activate\x0a\x09|button|\x0a\x09button := self element asJQuery.\x0a button click:[self clickBlock value]",
- messageSends: ["asJQuery", "element", "click:", "value", "clickBlock"],
- referencedClasses: []
- }),
- smalltalk.ChartButton);
- smalltalk.addMethod(
- "_clickBlock",
- smalltalk.method({
- selector: "clickBlock",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- return self["@clickBlock"];
- },
- args: [],
- source: "clickBlock\x0a\x09^clickBlock",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartButton);
- smalltalk.addMethod(
- "_clickBlock_",
- smalltalk.method({
- selector: "clickBlock:",
- category: 'not yet classified',
- fn: function (aBlock){
- var self=this;
- self["@clickBlock"]=aBlock;
- return self},
- args: ["aBlock"],
- source: "clickBlock: aBlock\x0a\x09clickBlock := aBlock",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartButton);
- smalltalk.addMethod(
- "_element",
- smalltalk.method({
- selector: "element",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- return self["@element"];
- },
- args: [],
- source: "element\x0a\x09^element",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartButton);
- smalltalk.addMethod(
- "_element_",
- smalltalk.method({
- selector: "element:",
- category: 'not yet classified',
- fn: function (aSymbol){
- var self=this;
- self["@element"]=aSymbol;
- return self},
- args: ["aSymbol"],
- source: "element: aSymbol\x0a\x09element := aSymbol",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.ChartButton);
- smalltalk.addMethod(
- "_element_clickBlock_",
- smalltalk.method({
- selector: "element:clickBlock:",
- category: 'not yet classified',
- fn: function (elementSymbol,clickBlock){
- var self=this;
- var $2,$3,$1;
- $2=smalltalk.send(self,"_new",[]);
- smalltalk.send($2,"_element_",[elementSymbol]);
- smalltalk.send($2,"_clickBlock_",[clickBlock]);
- smalltalk.send($2,"_activate",[]);
- $3=smalltalk.send($2,"_yourself",[]);
- $1=$3;
- return $1;
- },
- args: ["elementSymbol", "clickBlock"],
- source: "element: elementSymbol clickBlock: clickBlock\x0a\x09^self new element: elementSymbol; clickBlock: clickBlock; activate;yourself",
- messageSends: ["element:", "new", "clickBlock:", "activate", "yourself"],
- referencedClasses: []
- }),
- smalltalk.ChartButton.klass);
- smalltalk.addMethod(
- "_popUpChart_atDom_",
- smalltalk.method({
- selector: "popUpChart:atDom:",
- category: 'not yet classified',
- fn: function (chart,element){
- var self=this;
- var $1;
- $1=smalltalk.send(self,"_element_clickBlock_",[element,(function(){
- return smalltalk.send(chart,"_drawChart",[]);
- })]);
- return $1;
- },
- args: ["chart", "element"],
- source: "popUpChart: chart atDom: element\x0a\x09\x22Make the chart popup on click of an element\x22\x0a ^self element: element clickBlock:[chart drawChart]\x0a\x09",
- messageSends: ["element:clickBlock:", "drawChart"],
- referencedClasses: []
- }),
- smalltalk.ChartButton.klass);
- smalltalk.addClass('GoogleChart', smalltalk.Object, ['chartId', 'chartType'], 'GoogleCharts');
- smalltalk.addMethod(
- "_arrayToDataTable_",
- smalltalk.method({
- selector: "arrayToDataTable:",
- category: 'data table',
- fn: function (array){
- var self=this;
- var $1;
- $1=google.visualization.arrayToDataTable(array);
- ;
- return $1;
- },
- args: ["array"],
- source: "arrayToDataTable: array\x0a\x0a\x09^ <google.visualization.arrayToDataTable(array)>",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_chartId",
- smalltalk.method({
- selector: "chartId",
- category: 'accessor',
- fn: function (){
- var self=this;
- return self["@chartId"];
- },
- args: [],
- source: "chartId\x0a\x09^chartId",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_chartId_",
- smalltalk.method({
- selector: "chartId:",
- category: 'accessor',
- fn: function (aString){
- var self=this;
- self["@chartId"]=aString;
- return self},
- args: ["aString"],
- source: "chartId: aString\x0a\x09chartId := aString",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_chartType",
- smalltalk.method({
- selector: "chartType",
- category: 'accessor',
- fn: function (){
- var self=this;
- return self["@chartType"];
- },
- args: [],
- source: "chartType\x0a\x09^ chartType",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_chartType_",
- smalltalk.method({
- selector: "chartType:",
- category: 'accessor',
- fn: function (aString){
- var self=this;
- self["@chartType"]=aString;
- return self},
- args: ["aString"],
- source: "chartType: aString\x0a\x09chartType := aString",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_drawChart",
- smalltalk.method({
- selector: "drawChart",
- category: 'chart',
- fn: function (){
- var self=this;
- var chart;
- var data;
- var options;
- data=smalltalk.send(self,"_makeData",[]);
- chart=smalltalk.send(self,"_makeChart_",[smalltalk.send(self,"_chartId",[])]);
- options=smalltalk.send(self,"_makeOptions",[]);
- chart.draw(data,options);
- ;
- return self},
- args: [],
- source: "drawChart\x0a | chart data options|\x0a data := self makeData.\x0a chart :=self makeChart:self chartId.\x0a options :=self makeOptions.\x0a <chart.draw(data,options)>\x0a",
- messageSends: ["makeData", "makeChart:", "chartId", "makeOptions"],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_getElementById_",
- smalltalk.method({
- selector: "getElementById:",
- category: 'DOM',
- fn: function (id){
- var self=this;
- var $1;
- $1=document.getElementById(id);
- ;
- return $1;
- },
- args: ["id"],
- source: "getElementById: id\x0a\x09\x22Find element by the id in the DOM\x22\x0a\x09^ <document.getElementById(id)>",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'init',
- fn: function (){
- var self=this;
- return self;
- },
- args: [],
- source: "initialize\x0a\x09^self",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_makeChart_",
- smalltalk.method({
- selector: "makeChart:",
- category: 'chart',
- fn: function (id){
- var self=this;
- var $1;
- var e;
- var t;
- e=smalltalk.send(self,"_getElementById_",[id]);
- t=smalltalk.send(self,"_chartType",[]);
- $1=new google.visualization[t](e);
- ;
- return $1;
- },
- args: ["id"],
- source: "makeChart: id\x0a\x22build a chart at specific element id in the DOM and return\x22\x0a\x09|e t|\x0a e := self getElementById:id.\x0a t := self chartType.\x0a ^ <new google.visualization[t](e)>",
- messageSends: ["getElementById:", "chartType"],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_makeData",
- smalltalk.method({
- selector: "makeData",
- category: 'abstraction',
- fn: function (){
- var self=this;
- var $1;
- $1=smalltalk.send(self,"_subclassresponsibility",[]);
- return $1;
- },
- args: [],
- source: "makeData\x0a\x09\x22abstraction - return the data for a google chart\x22\x0a \x09 ^self subclassresponsibility",
- messageSends: ["subclassresponsibility"],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_makeOptions",
- smalltalk.method({
- selector: "makeOptions",
- category: 'abstraction',
- fn: function (){
- var self=this;
- var $1;
- $1=smalltalk.send(self,"_subclassresponsibility",[]);
- return $1;
- },
- args: [],
- source: "makeOptions\x0a\x09\x22Abstract method - return options for a Google Chart\x22\x0a ^\x09 self subclassresponsibility",
- messageSends: ["subclassresponsibility"],
- referencedClasses: []
- }),
- smalltalk.GoogleChart);
- smalltalk.addMethod(
- "_chartId_",
- smalltalk.method({
- selector: "chartId:",
- category: 'not yet classified',
- fn: function (aString){
- var self=this;
- var $2,$3,$1;
- $2=smalltalk.send(self,"_new",[]);
- smalltalk.send($2,"_chartId_",[aString]);
- $3=smalltalk.send($2,"_yourself",[]);
- $1=$3;
- return $1;
- },
- args: ["aString"],
- source: "chartId: aString\x0a\x09^self new chartId:aString;yourself",
- messageSends: ["chartId:", "new", "yourself"],
- referencedClasses: []
- }),
- smalltalk.GoogleChart.klass);
- smalltalk.addClass('GaugeChart', smalltalk.GoogleChart, [], 'GoogleCharts');
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_initialize",[],smalltalk.GoogleChart);
- smalltalk.send(self,"_chartType_",["Gauge"]);
- return self;
- },
- args: [],
- source: "initialize\x0a\x09\x22 Create a Guage with the chartId that identifies the chart graphic placement and the chartType to be created at that id.\x22\x0a super initialize.\x0a self chartType:'Gauge'.\x0a\x09^self",
- messageSends: ["initialize", "chartType:"],
- referencedClasses: []
- }),
- smalltalk.GaugeChart);
- smalltalk.addClass('GeoChart', smalltalk.GoogleChart, [], 'GoogleCharts');
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_initialize",[],smalltalk.GoogleChart);
- smalltalk.send(self,"_chartType_",["GeoChart"]);
- return self;
- },
- args: [],
- source: "initialize\x0a\x09\x22 Create a Geo Chart\x22\x0a super initialize.\x0a self chartType:'GeoChart'.\x0a\x09^self",
- messageSends: ["initialize", "chartType:"],
- referencedClasses: []
- }),
- smalltalk.GeoChart);
- smalltalk.addClass('PieChart', smalltalk.GoogleChart, [], 'GoogleCharts');
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_initialize",[],smalltalk.GoogleChart);
- smalltalk.send(self,"_chartType_",["PieChart"]);
- return self;
- },
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a self chartType:'PieChart'.\x0a\x09^self",
- messageSends: ["initialize", "chartType:"],
- referencedClasses: []
- }),
- smalltalk.PieChart);
- smalltalk.addClass('ScatterChart', smalltalk.GoogleChart, [], 'GoogleCharts');
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- category: 'not yet classified',
- fn: function (){
- var self=this;
- smalltalk.send(self,"_initialize",[],smalltalk.GoogleChart);
- smalltalk.send(self,"_chartType_",["ScatterChart"]);
- return self;
- },
- args: [],
- source: "initialize\x0a\x09super initialize.\x0a self chartType:'ScatterChart'.\x0a\x09^self",
- messageSends: ["initialize", "chartType:"],
- referencedClasses: []
- }),
- smalltalk.ScatterChart);
|