[R-SIG-Finance] SVG device with tooltips
Matthew Dowle
mdowle at concordiafunds.com
Mon Feb 19 17:28:40 CET 2007
Romain,
Have you used Matlab's code profiler? It has some neat features which
would be great to see in R, in case you are looking for inspiration in
your profiling project. For example: line by line timing, line
colouring according to the time spent on that line, parent/child
function call aggregation, barplots of time spent, hyperlinks from the
hit list of lines to their function's context. The line colouring is
useful as it allows you to run coverage testing as well as profiling
i.e. see the lines which did *not* execute. The profiler can also help
with debugging as the execution path is graphically observed. So it is
much more than just profiling, but achieved simply by timing line by
line.
Matthew
> -----Original Message-----
> From: r-sig-finance-bounces at stat.math.ethz.ch
> [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of
> Romain Francois
> Sent: 19 February 2007 14:48
> To: Tony Plate
> Cc: R-sig-finance
> Subject: Re: [R-SIG-Finance] SVG device with tooltips
>
>
> Hi,
>
> Thank you for that nice package. As part of my job here, we
> integrate SVG with packages such as R and it's an area of
> great interest to me due to the graphical capabilities it
> allows. I managed to use your work to produce a graphic from
> a package I'm writing about profiling R code. It is much
> nicer with the SVG interactivity than with any other format.
> The example shows a profiling graphic of one line of code,
> I'll send a Mango t-shirt to the first one that tells me what
> line of code I profiled ...
>
> http://www.mango-solutions.com/examples/profileplot.svg
>
> The idea of the graphic is that the area of a rectangle
> represents the number of times a given function was called.
>
> A couple of thoughts :
> - the package inherits the style="all kinds of stuff" from
> RSvgDevice when a use of css would help. n my example I get
> the following results:
>
> > length( gsub( '.*style="(.*)".*', '\\1', grep( 'style', rl, value =
> TRUE)) )
> [1] 173
> > length(unique( gsub( '.*style="(.*)".*', '\\1', grep( 'style', rl,
> value = TRUE))) )
> [1] 44
> and if I look deeper into the code, only the fill: field
> differ from the many style I have
>
> I think it could be good to use some CSS in the package. A
> way to do it could be to post process the file after it is
> created, that can be fun !, or generate the css as graphical
> objects are added to the svg file.
>
> - The javascript scripts are embed to the document, it could
> be useful to be able to link the javascript, could be an option ?
>
> - I believe css could be used instead of javascript for the
> tooltips, I specially think of the pseudo class "hover",
> something on the lines of :
>
> rect.*{
> display:none;
> }
> rect:hover.*{
> display:inline;
> }
>
> the downside is that using hover won't bring IE any closer to
> be able to render the file properly.
>
> - What about links, so if I click on the glm rect on my
> example, it will bring the help page of glm, ...
>
> - I've tested it with konqueror, it does not seem to work
>
> Anyway, nice package, ...
>
> Romain
>
>
> Tony Plate wrote:
> > I put experimental SVG device package, which includes the ability to
> > have popup tooltips, at
> >
> >
> http://www.cybermesa.com/~champagne/RSVGwTips/RSVGwTipsDevice_0.6.1.ta
> > r.gz
> > (source)
> >
> http://www.cybermesa.com/~champagne/RSVGwTips/RSVGwTipsDevice_
> 0.6.1.zip
> > (windows binary package)
> >
> > Examples of the plots produced are at:
> >
> > http://www.cybermesa.com/~champagne/RSVGwTips/svgplot1.svg
> > http://www.cybermesa.com/~champagne/RSVGwTips/svgplot2.svg
> > http://www.cybermesa.com/~champagne/RSVGwTips/svgplot3.svg
> >
> > (These are the first 3 examples produced by the code in the
> help file
> > --
> > I've just put them here so that people can see the SVG
> output without
> > having to get, compile and install the package.)
> >
> > This SVG device is called RSVGwTipsDevice, and is based on the
> > RSvgDevice package written by T Jake Luciani
> <jakeluciani at yahoo.com>
> > (who did express mild interest in these modifications, but
> didn't have
> > time to look at them or comment on them.)
> >
> > Limitations/features are:
> >
> > * standard graphics primitives are used (points(), rect(),
> etc), and the
> > same code should work with any device (for other devices,
> the calls
> > that specify tooltips should have no effect.)
> > * tooltips are attached to shapes: e.g., the output of
> points(), rect(),
> > and polygon(), but not lines()
> > * the tooltip is specified in a separate call to the
> drawing function
> > * only the first shape produced by an R drawing function
> will have a
> > tooltip (so, if you want each point to have a tooltip, each must be
> > drawn separately)
> > * the tooltips that have a title + 2 lines of text probably use
> > non-standard SVG code -- I wrote the SVG code by trial and
> error and
> > it's probably not correct. These tooltips display fine in
> Firefox, but
> > the Batik standalone SVG viewer doesn't like them.
> >
> > One possible approach to get around the limitation that vectorized
> > calls
> > to points() (etc) only have a tooltip on the first point is
> to allow
> > specifying in advance a vector of tooltip text. However, the whole
> > approach of having to supply the tooltip text in advance is
> not very
> > nice -- though it was the only way I could think of making
> the standard
> > graphics primitives work with tooltips (because the
> standard graphics
> > primitives don't allow optional extra arguments).
> >
> > If you try this out, please bear in mind that this really is
> > experimental code. Comments/suggestions/contributions are welcome
> > (especially from SVG experts!)
> >
> > It's probably reasonably easy to add other dynamic graphics features
> > such as zooming and x/y location readout. I just haven't
> tried, but if
> > anyone is inspired and comes up with something, I'm happy to try to
> > integrate it!
> >
> > -- Tony Plate
> >
> > _______________________________________________
> > R-SIG-Finance at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> >
> >
>
>
> --
> Mango Solutions
> Tel +44 1249 467 467
> Fax +44 1249 467 468
> Mob +44 7813 526 123
> data analysis that delivers
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
>
More information about the R-SIG-Finance
mailing list