Hi All,
I wrote a easy sample graphing application using “AmCharts” framework on OS X 10.11.
Xcode based ASOC app could draw chart and display animation perfectly.
Same graphing script on Script Editor could not draw the graph (I made a Window dynamically for debugging ). Exported applet version could not draw graph, too.
Script Editor version have to install “AmCharts.framework” in your "~/Library/Frameworks” folder. And it have to be run by control-command-R.
What is the essential difference among these runtime environment?
<Xcode version> on applicationWillFinishLaunching_(aNotification)
--Make pieChart set pieChart to current application's AmPieChart's alloc()'s init() set pieChart's |type| to "pie" set pieChart's theme to "none"
set aRecList to {{country:"Lithuania", |liters|:(501.9)}, {country:"Czech Republic", |liters|:(301.9)}, {country:"Ireland", |liters|:(201.1)}} set dataProvider to current application's NSMutableArray's arrayWithArray:aRecList
set pieChart's dataProvider to dataProvider set pieChart's valueField to "liters" set pieChart's titleField to "country"
amChartV's setChart:pieChart amChartV's drawChart()
end applicationWillFinishLaunching_ </Xcode version>
<Script Editor version> -- Created 2015-10-15 by Takaaki Naganoya -- 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "AppKit" use framework "Quartz"
set aWidth to 400.0 set aHeight to 400.0 set outPath to "~/Desktop/test.png"
--Make pieChart set pieChart to current application's AmPieChart's alloc()'s init() set pieChart’s type to "pie" set pieChart's theme to "none"
set aRecList to {{country:"Lithuania", |liters|:(501.9)}, {country:"Czech Republic", |liters|:(301.9)}, {country:"Ireland", |liters|:(201.1)}} set dataProvider to current application's NSMutableArray's arrayWithArray:aRecList
set pieChart's dataProvider to dataProvider set pieChart's valueField to "liters" set pieChart's titleField to "country"
--Make AmChartView set amChartV to current application's AmChartView's alloc()'s initWithFrame:{origin:{x:0, y:0}, |size|:current application's NSMakeSize(aWidth, aHeight)} amChartV's setChart:pieChart set amChartV's bodyBackgroundColor to "#ffffff" set amChartV's isLoadingIncrementally to false amChartV's drawChart()
repeat 10 times set cStat to (amChartV's isReady()) as boolean if cStat = true then exit repeat delay 1 end repeat
--Visual Debug set aWin to my makeWinWithView(amChartV) my closeWin:aWin
--make Window for debug on makeWinWithView(aView)
set aScreen to current application's NSScreen's mainScreen() set aFrame to {{0, 0}, {800, 800}} set aBacking to current application's NSTitledWindowMask --NSBorderlessWindowMask set aDefer to current application's NSBackingStoreBuffered
-- Window set aWin to current application's NSWindow's alloc() (aWin's initWithContentRect:aFrame styleMask:aBacking backing:aDefer defer:false screen:aScreen) aWin's setBackgroundColor:(current application's NSColor's whiteColor())
aWin's setTitle:"Visual Debug" aWin's setDelegate:me aWin's setDisplaysWhenScreenProfileChanges:true aWin's setHasShadow:true aWin's setIgnoresMouseEvents:false aWin's setLevel:(current application's NSNormalWindowLevel) aWin's setOpaque:false aWin's setReleasedWhenClosed:true aWin's |center|() aWin's makeKeyAndOrderFront:(me)
-- Set Custom View aWin's contentView's addSubview:aView
return aWin
end makeWinWithView
--close win on closeWin:aWindow delay 5 repeat with n from 10 to 1 by -1 (aWindow's setAlphaValue:n / 10) delay 0.02 end repeat aWindow's |close|() end closeWin:
</Script Editor version> |