Create a chart only with Applescript

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

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

Thanks! But it sounds a bit too complicated …

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

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.

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

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.

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:

L.

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.

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.

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.

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

Thanks !