#269 Use OOP Javascript for canvas terminal


Currently it is difficult to use several plot (made from canvas terminal) in a html project with lots of other javascript.

I would suggest encapsulating the static as well as the dynamic javascript code into real javascript objects and the removal of all the global variables (makeing them object variables).

Something along the following structure might be a useful object model:
One object gnuplot which contains all the static helper functions and constructors to generate plots which keep ther own local state (e.g. each plot has its own zoom state).

BTW: What was the reason not to use fillText() to draw text?


  • Ethan Merritt

    Ethan Merritt - 2010-09-02

    > [remove global variables]

    Sounds like a good idea to me. It would be nice if someone who understands javascript scoping would contribute a patch.

    > BTW: What was the reason not to use fillText() to draw text?

    Very simple, no such operator existed at the time :-)
    In fact, even though fillText() has recently been added to the HTML5 draft proposal, I don't think the distributed version of any existing browser implements it yet. According to the HTML working group web site, as of June 2010 none of the Opera, Firefox, Chromium nightly builds from source could successfully pass a text rendering test.

  • Ethan Merritt

    Ethan Merritt - 2010-09-02
    • priority: 5 --> 7
  • Ethan Merritt

    Ethan Merritt - 2010-11-25
    • status: open --> open-accepted
  • Ethan Merritt

    Ethan Merritt - 2010-11-25

    OK. The first part of this is now in CVS - all the methods and support variables are in a single object declared in gnuplot_common.js. As before, the scripts that generate the on-line demos serve as an example of usage.

    Maintaining separate state variables for each plot is of course possible, but not yet implemented. Higher priority in my mind is working out how to make the hotkeys work for individual plots rather than for the whole document. Anyone have a pointer to some URL that has an example of local rather than global scoping for "onkeypress=event_handler"?

  • Ethan Merritt

    Ethan Merritt - 2011-04-09
    • status: open-accepted --> closed-accepted

Log in to post a comment.