toggle buttons to control rgl 3d scatterplot not working - html

We are working on a meta analysis about lizard niches and convergent evolution, and created a 3d plot with PCA scores, were dots are lizard species from 24 different families.
We decided to use our 3d plots as supplementary material for our manuscript because there are very interesting patterns that are obscured when plotted in 2 dimensions. For example, all nocturnal species stick together, and are separated from the rest in the third plane.
So, to make the figures really useful, I wanted to include some controls to turn some objects on/off (like lizard families, or ellipsoids, or functional groups). I tried using Plotly, that gives you very nice and interactive plots, but symbols in Plotly are limited to only five for 3D plots.
I finally did it with R using the rgl package. I had to create new symbols by overlapping pre-existent ones, but and at the end I got what I needed.
I followed an online tutorial to create interactive controls (https://cran.r-project.org/web/packages/rgl/vignettes/WebGL.html) that can be embedded in html, and with a lot of effort I got those controls working. The problem is that it only works in my computer, only in Chrome (does not work in Firefox, nor Safari). I asked one of the creators of the package and he told me that the tutorial was intended to be use with markdown, and given I changed the html code, the weird behavior was not surprising.
After that I learn some Rmarkdown and html to better understand the tutorial, and re-do the code. Now I have the plots and I have the buttons, but when I compile the script using Knitr, the buttons don't work. Some of them do nothing, some others turn on different set of points.
I am sorry for the length of this post, but I really tried everything and I can't find a solution.
Here is a link to a sample of my dataset, my R script, and the HTML generated using Knitr: https://drive.google.com/open?id=0B-fCxMGN3utrbWgtZzhWYVpxSjg
Thank you so much in advance!

The issue is that there are at least two different schemes for embedding rgl scenes in a web page and for linking a button to the rgl scene, and you're mixing them without providing the "glue" to make them work together.
An rglwidget() always has an elementId. Normally it's some random string, but if you want to refer to that scene, you should specify one.
The toggleButton() function uses the older scheme for inserting the scene into your web page. So you need to translate the elementId to the prefix that it uses.
So try something like this:
```{r results='asis'}
library(rgl)
x <- plot3d(rnorm(10), rnorm(10), rnorm(10))
rglwidget(elementId = "theplot")
elementId2Prefix("theplot")
toggleButton(x["data"], prefix = "theplot")
```

Related

Chrome not rendering SVG properly

Working on a D3, React, Redux web app and running into an interesting bug when rendering an SVG containing a bunch of rectangles.
Application Summary
We use a D3 Partition Layout to generate a huge (~3000) list of nodes to set the appropriate layout attributes (x, y, dx, dy).
We use React/Redux for the rest of the application to store this state and ultimately render an SVG for the chart.
Problem
Some nodes (rendered as rects) in the rendered SVG simply don't show up!
Theories
Originally, we thought we had a bug with how we were generating the rectangles, but this turned out not being the case (Rects exist in the dom with the right attributes).
We are rendering other things in addition to the rects, so we thought those were conflicting when the browser painted everything. That seemed to not be the case since we disabled all of these other items and we're still seeing the issues.
It could be a browser bug when it comes to rendering rects. Our app currently doesn't even render properly when on Firefox, so it may be something to do with how we are generating the SVG.
Example
Here are some examples of what we are talking about.
Here's an example of the chart being rendered properly with all of its nodes.
Here's an example of the chart rendering with part of its nodes missing:
Here's an example of the same chart magically breaking after we alt tabbed a few times:
Questions
What we're looking for is any ideas from people more experienced with SVG rendering for what we could be looking into. There are a bunch of possibilities, but we're not sure which direction we should be looking into.
Thanks!

Plotting tools for dashboard

After browsing for a while for available solutions, it is really hard to choose the most appropriate tool for creating dashboard & populating it with plots. I would want to have an html page with multiple plots and tables depicted. I'm thinking to have data input stored in csv files, appropriately formatted.
The requirements are:
plot coordinates are showing on mouse hover
ability to show coordinates of points on a plotted line (points in
scatter plot or bar values for bar chart) 'sticking' to the nearest
lines on hover, with appropriate handling of multiple lines (show several y values for same x)
ability to interactively switch plotted data on/off
easily embeddable into html page, doesn't require additional plugins installed
a good variety of plot types
not too slow to load and stable, there could be ~50 plots on one page
(this is for internal use only, so quickness is not that important)
does it all with minimal effort
So far I checked out (by no means a final opinion, correct me if I'm wrong):
gnuplot+canvas - looks good, but samples on their page fail to work
well for me, not always getting mouse clicks right
python+matplotlib+mplh5canvas - feels a bit raw, as I understand
some of the stuff above I'd need to implement in Python myself
RGraph looks awesome at first glance, not sure if it is good since never heard of
it and don't have any experience in js, hard to customize(?)
some other random stuff which seemed bad enough
Suggestions?
RGraph looks awesome, and is awesome. It's not difficult to use and there are a lot of examples online.
Rgraph Example page
They've got 22types of graphs, correct me if I'm wrong, and as I already said, easy to use.
Documentation about possibilities and stuff for each type of graph is also available on the website.
I end up using Highcharts because of its very advance features and ready-to-use templates (in addition to the things mentioned in the question).

HTML5 Framework for a custom product editor

I'm looking into several html5 frameworks for a project that would be in some ways similar to the iMakeMyCase editor.
The main features that have to be implemented:
choosing a predefined background
placement of multiple pre-defined elements with drag and drop
elements have to be resizable, rotatable
undo/redo
elements have to have ability to bring them forward/backwards (like layers)
zooming of the whole canvas (that one could be tricky ... any suggestions?)
ability to save the elements placement
get a .png preview of the finished product (can you somehow capture the canvas to a regular image)
The frameworks that I have been loooking so far:
cappuccino
Looks promising and the projects that have been made with it cover 90% of functionality that I need. I'm not sure about ObjectiveJ though ...
sproutcore
I didn't see lots of examples, but if apple made the whole iCloud with it, then it sure has to be powerful. But I have a feeling that a lot of implementation would be needed to get the required features covered. Correct me if I'm wrong.
easeljs
The examples look cool and if you combine them, you almost have everything covered. Probably my favourite at the moment.
What's your opinion on these frameworks and are they suitable for the project? Any others that I have missed? Any suggestions are really welcome to help me choose the right tool for the job.
Thx.
For your zooming Functionality i found same question here
and for a png preview of your image you can do something like that
var canvas = document.getElementById("canvas");
var img = canvas.toDataURL("image/png");
//here you got the png image show just create an element and show this preview there
document.write('<img src="'+img+'"/>');

power point to html 5

I'm looking for a tool/solution that would allow me to convert a power point presentation into a fully html5 website. I've seen solutions like iSpring and html5point which just make each slide as an img or iSpring whihc is good for simple slides. In my case the slides contain graphics and shapes (no animation or video though). Any adivce ?
I don't know of any of the solutions you mention, but the last time I had to do this I found it easiest to export (Save As ...) the .ppt as a single webpage and then copy and paste chunks of it into a template I had created previously.

Heatmap Tools For Web Apps

I have a client that want to have a web app I'm building for them display heat maps of the data.
I haven't worked with heat maps at all and I was wondering if anyone knew of some good tools for generating them.
Thanks.
Heat maps are often used in place of a more conventional term: kernel density estimators. If you need to compute these on the fly, consider GRASS GIS- specifically, the v.kernel or v.neighbors modules. These will generate a continuous estimate (i.e. raster surface) of density, at some target resolution (defined by the current region settings). GRASS GIS can be controlled via Python code, so it would be a simple matter to write a Python wrapper around the underlying modules, that could export the results to your web application.
For small datasets, the R project has several functions for reading/writing spatial data, and computing kernel density estimates.
I realize this is an old, old post -- but the next guy to stumble across this page might try gheat for heatmaps in webapps. There are ports for Django and Google App Engine, if you happen to be using those backends.
I'll assume this is data with three values per data-point - we'll call them x, y and z.
It would really help if x and y were spatial coordinates as that makes things easier.
Anyway, generate a bitmap of x by y (scaled appropriately).
For each x and y pair in the data, scale z to between 0 and 1 (or 0 and however many colours you have in your map), and plot z as a colour represented by that value.
E.g. a simple map could just use the R portion of RGB, in which case you'd have 256 graduations for your red.
Most likely, you'd want something more fancy, but you should be able to get the idea.
If your datapoints are spread apart, you can either plot them as rectangles that take up the space, or smoothly interpolate between them.
NOTE: THere is a web-based tool that does it here. I found it linked from the Wikipedia article on heatmaps. There's a java one too linked from there too.
If you want to generate heatmaps on the clientside (with JavaScript) I can recommend heatmap.js to you. It uses the HTML5 Canvas element to generate dynamic web heatmaps, you can new add data at any time and the heatmaps refresh.
Pyheat is another good library in python for building heatmaps.
Gheat is already mentioned in a reply by J.J.
I have a compelling heatmaps tool for both PC and mobile web pages to recommend: http://miapex.com
Might I suggest my own jQuery plugin?
jQuery Hottie makes it easy to take normal markup and add a background color like so:
<!-- Coloring elements is easy! -->
<ul id="example1">
<li>1<li>
<li>2<li>
<li>3<li>
<li>4<li>
<li>5<li>
</ul>
$('ul#example1 li').hottie();