Tuesday, August 20, 2019

#1 2019-07-10 12:09:07 pm

ldicroce
Member
Registered: 2017-11-25
Posts: 124

Create a chart only with Applescript

Is there any way to make a plot (line graph) without invoking Excel, Numbers etc...?

Offline

 

#2 2019-07-10 09:22:24 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 425

Re: Create a chart only with Applescript

No, but AppleScriptObjC can create a chart with NSRects and NSBezierPaths.

Last edited by KniazidisR (2019-07-10 09:23:47 pm)


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#3 2019-07-11 08:50:23 am

ldicroce
Member
Registered: 2017-11-25
Posts: 124

Re: Create a chart only with Applescript

Thanks! But it sounds a bit too complicated ....

KniazidisR wrote:

No, but AppleScriptObjC can create a chart with NSRects and NSBezierPaths.

Offline

 

#4 2019-07-11 10:24:04 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 425

Re: Create a chart only with Applescript

ldicroce wrote:

Thanks! But it sounds a bit too complicated ....

KniazidisR wrote:

No, but AppleScriptObjC can create a chart with NSRects and NSBezierPaths.



Yes, you create NSWindow, then put in it NSFrame, then put in it some content as NSImage. No sense, as it will be very slow code


macOS Mojave -- version 10.14.4
Safari -- version 12.1

Offline

 

#5 2019-07-11 11:04:56 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 411

Re: Create a chart only with Applescript

It depends on exactly what you're trying to avoid when you say "not invoking Excel, Numbers, Etc."

If you mean "not invoking any external software," then I think the extremely complicated method of using AsObjC to draw your graphs would be your only choice.

However, I'm not totally clear on what you want to avoid - if you just want to generate plots in a "headless" fashion from Applescript - ie, not actively controlling some app that might need to be a foreground app - then you could use a shell or python graphing solution and control it from Applescript.

For example, gnuplot http://www.gnuplot.info/
or Matplotlib: https://matplotlib.org/

There are others.

These could generate a plot entirely in the background and save it as a file without appearing to control any user applications while running.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#6 2019-07-11 11:45:25 am

kerflooey
Member
Registered: 2011-07-07
Posts: 164

Re: Create a chart only with Applescript

An SVG graphic is composed entirely of text, so you could use only Applescript to construct one.

Offline

 

#7 2019-07-11 08:50:35 pm

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 411

Re: Create a chart only with Applescript

kerflooey - You could probably figure out a way to write out the raw data to comprise any graphics format with Applescript. I had assumed we were restricting answers to something that could be coded in less than a year. He'd have to write the code to generate the graph and convert it into an image format and save it... I assumed he'd be looking for a graphing tool that generates graphs from data.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#8 2019-07-12 02:55:16 am

ldicroce
Member
Registered: 2017-11-25
Posts: 124

Re: Create a chart only with Applescript

Thanks for the feedback to all.

I was hoping for something similar to "Image Events", but for plotting ...
to avoid "watching" Applescript "creating" the graph in the foreground.

SVG is interesting (I dint know it is a "pure" text. But I would need to learn it ...

I will doble check the two other options you suggested:
- gnuplot http://www.gnuplot.info/
- Matplotlib: https://matplotlib.org/

L.

Offline

 

#9 2019-07-12 08:03:44 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 411

Re: Create a chart only with Applescript

Yes, if you just want to avoid watching Applescript create the graphs in the foreground, then using a CLI graph generation utility should work fine for you.

Another good option besides those already mentioned is R

https://cran.r-project.org/bin/macosx/

- Tom.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#10 2019-07-12 10:43:59 am

kerflooey
Member
Registered: 2011-07-07
Posts: 164

Re: Create a chart only with Applescript

SVG is basically xml, so I was thinking it would be relatively easy to do one typical chart in Illustrator or whatever, and then use that as a template where he could simply substitute the new data points with a search/replace operation. Limited, but doable without having to learn much at all about SVG.




t.spoon wrote:

kerflooey - You could probably figure out a way to write out the raw data to comprise any graphics format with Applescript. I had assumed we were restricting answers to something that could be coded in less than a year. He'd have to write the code to generate the graph and convert it into an image format and save it... I assumed he'd be looking for a graphing tool that generates graphs from data.

Offline

 

#11 2019-07-12 10:55:50 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 411

Re: Create a chart only with Applescript

Yes, that seems doable. It depends on how general purpose he needs it.

Now that we know he just wants it headless (he's not trying to avoid dependencies), I think a CLI Graphing program is definitely the way to go.

One more option, instead of a CLI graphing program, is a graphing API.

https://developers.google.com/chart/

So you could run a headless browser like Chrome Headless, Firefox Headless, or Phantom JS and use the Google Charts API to make your graph and then download it.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

#12 2019-07-14 11:53:09 am

ldicroce
Member
Registered: 2017-11-25
Posts: 124

Re: Create a chart only with Applescript

R is a good idea.
I actually always wanted to learn the basics of R.

Thanks !


t.spoon wrote:

Yes, if you just want to avoid watching Applescript create the graphs in the foreground, then using a CLI graph generation utility should work fine for you.

Another good option besides those already mentioned is R

https://cran.r-project.org/bin/macosx/

- Tom.

Last edited by ldicroce (2019-07-14 11:53:31 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)