From: <pl...@pi...> - 2008-12-30 21:06:07
|
Ethan A Merritt wrote: > On Tuesday 30 December 2008, Ethan A Merritt wrote: >> On Tuesday 30 December 2008, pl...@pi... wrote: >>> Ethan A Merritt wrote: >>>> On Tuesday 30 December 2008, pl...@pi... wrote: >>>>> OK I've added set key clickable/noclickable cleaned up a bit and done >>>>> trivial testing. >>>>> >>>>> Here's the patch. Though I probably missed something out. ;) >>>>> >>>>> Thanks to Bill for the idea and the perl hack to do it. >>>>> >>>>> regards, Peter. >>>>> >>>>> gnuplot_svg_interactive.patch >>>> Please upload it to the SourceForge site: >>>> >>>> https://sourceforge.net/tracker/?group_id=2055&atid=302055 >>>> >>> Patches item #2477391, was opened at 2008-12-30 17:29 >>> Message generated for change (Tracker Item Submitted) made by Item Submitter >>> You can respond by visiting: >>> https://sourceforge.net/tracker/?func=detail&atid=302055&aid=2477391&group_id=2055 >>> >>> >>> It probably needs tidying up a bit but could you make sure it applies >>> OK? Made against currect CVS. >> > > > More comments: > > - "set key clickable" works, but the current setting needs to be reported by > "show key" and saved by save_set_all(). > > - Coding style. Please make new code conform to the surrounding coding style. > Rather than > > /* Draw key text in black */ > (*t->linetype)(LT_BLACK); > +//*** add legend id and onclick > + if ( (key->clickable) && (term->set_id_click) ) (term->set_id_click) ("legend#","line#"); > > Please use > > /* Draw key text in black */ > (*t->linetype)(LT_BLACK); > + /* add legend id and onclick */ > + if (key->clickable && (*t->set_id_click)) > + (*t->set_id_click)("legend#", "line#"); > > - Thinking out loud here ... > As I understand it, the curent patch associates the action specifically with > the text of the key title. What if the plot has no title? > Maybe it would be better to associate the action with the rectangular block > that bounds the key title and associated key sample. That would at least > hypothetically allow associated the action with an image-mapped *.png plot > in addition to the more obviously interactive terminal types. Maybe adding a wrapper element would be useful if you want to add an href but that was not the aim of this patch. Like I said this needs some top down thinking before it expands, as it surely will. The sample line is also active with this patch but you need to be a good shot with the mouse. A larger target would be good. > > - I'd like to hear more suggestions or brainstorming about a generalized > framework. This patch associates a specific action (toggle on/off) with > a click on the key title. My earlier href patch associated a different > action (link to URL) with a click on the key title. Another suggestion from > the first round of comments was to also allow the click to trigger various > other actions (highlight the plot, erase other plots, grey out the plot). > > All of these options sound reasonable, but it means that "set key clickable" > is not sufficient to specify the desired result. OK, fine, we could make > that "set key click=toggle" or "set key click=URL". But do we need a > new set of terminal entry points for each option, or can we share a single > entry that handles all of the various options that apply to that terminal? > > Maybe we need a structure that describes the desired actions, and a > corresponding set of keywords to instantiate one. > > struct action { > int type; /* toggle, cycle, highlight, hyperlink, ... */ > char *url; /* NULL unless action type is hyperlink */ > t_colorspec highlight_color; > } I'd like to bring the function name onclick=toogleVisible out to a string that could be "set". Your *url should be free to set anything. This allows the user to add his own js functions in svg.js and link them in this way. This way he has the freedom to do window.parent.location="....." to break out of frames or whatever. Or pop up an alert() with some info about the plot. This is very powerful. It also circumvents the problem of trying to code the <a></a> pair and leave it dangling while diverse possible code paths happen and then hope to close it again properly. > > struct legend_key { > ... > struct action *action; > } > > # default action is to toggle the plot on/off > set key title action TOGGLE > # but individual plots can do something else, > # e.g. cycle grey/off/on/highlight > plot foo title "foo" action cycle, > baz title "baz" action link "file:///data/baz.dat" > Yes I like linking to the data. The current two args are probably not enough but it shows the mechanism. It probably needs : id unique id , probably utilising plotno if in the plotting loop event [onclick , onmouseenter, ....] action [toggleVisibilty, other std, user defined] target [null,self,another id] This shows a limitation on the 'set key' approach, how to define more than one event handler (onclick , and onmouseover for coords) set key event 1 onclick set key action 1 togglevisiblity ?? The first arg will be simple an unique but the second is looking a lot like a struct* to me. If this is not flexible each new idea is going to change the code for all terminals. I'll get back to cleaning up the patch. regards. |