On 31/10/2020 02:28, Roger Guay via use-livecode wrote:

Lots of clever ideas here, Alex, but I think you’re missing the point of what I 
ultimately want to do. I'm building a plotting program for which I want to plot 
any equation including those that have multiple values of y for a given x. An 
equation might branch at any point and might even have multiple branches both 
of which are unknown before plotting.

Of course, there’s always the possibility that I’m not fully comprehending your 
suggestions??? What does NB stand for? Are you suggesting creating a new 
polygon every time a branch is detected? That just might work?!

Hi Roger. You're right - I missed the point; I jumped to the assumption that you were asking about a fairly small, specific issue - so leapt too quickly to a code sample. But before I address the general question(s), let me get the little points out of the way :-)

NB - sorry, kind of common usage in British English. Actually, it's from a Latin phrase - "Nota Bene" - meaning "note well". So basically just 'take note of'.

"a new polygon every branch" - yes, perfectly possible. Also possible is what I did in the first case of the code sample -  a new 'sequence of points' for each branch, and then stitch those together (with blank lines between) into a single polygon; but that's, for now, a detail.

The essence of the problem is that your app will (somehow) develop a number of 'sequences of *data* points' - and then those need to be translated into equivalent sets of *display* points (by either a plotting library, or by your own code) to allow it to be displayed appropriately.

There are at least two possible plotting libraries that might do what you want (or do something close enough that they could be useful). By coincidence, they were both discussed at the San Jose LC conference in 2019.If you have access to the video / papers from that you might already have some of the info you need; I don't know if the conference papers are ever put out for more general usage later.

Option A. Monte described a wrapper for the JSPlot library. It's a very powerful library capable of many kinds of graphs / plots, and very quick and capable. The most obvious downside is that it needs to be used within a browser widget - but well worth looking at it if you can.

Option B. I did a library called "GraphMaker" - a pure-Livecode plotting library. It is (I think) fairly easy to use - but that may not be the case for someone else coming to it new. I know it can handle this case of bifurcating plots (using multiple sequences of data points). The conference slides were a decent, if very brief, introduction; the lengthier documentation was, maybe, not quite complete. However, it does come with a demo app that uses the library to draw a variety of graph types. Main advantage is it's pure LC, and hopefully easy to use - both in understanding and in ease of integration into an app (you just create a suitable group to contain the graph, set its rect properly and pass in all the point data along with various parameters.  It has nowhere near the coverage of different graph types that JSPlot does - it's basically line, bar and scatter plots, with primary X-axis, and can have shading, etc.

Option C. Roll your own.

I'd certainly suggest investigating the use of an existing library first. There's quite a lot of effort needs to go into determining how to scale the data to the space available, how to label the axes, how to add tick marks, grid lines and (perhaps) multiple Y-axes. That stuff probably accounted for 90% of the effort of creating the library.

If you'd like to try out my library, the latest version can be found at

https://www.tweedly.org/lcms.lc/GraphMaker

(sorry - I haven't formatted it into my usual download structure - so this is simply a page that gives links that allow you to download the 2 files you need and 2 more files you don't need.)

Of course, I'll be happy to help out in any way I can with it.

Alex.

P.S. the demo app includes an example of a 'branching' plot (Graph 3).


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to