Displaying a multiple-plot graph using r_fun_plot - opencpu

I am having trouble displaying a multiple-plot graph using the ocpu javascript function r_fun_plot(). The R function that is called creates two or more plots use the par() function to lay them out in a matrix. If I call my R function locally (from within RStudio) I will get the correct result. However, when called remotely using r_fun_plot() and with a target of an empty DIV element, no plots are displayed - only the "pdf svg png" pointers are displayed. Clicking these pointers gives a page with the following text:
attempt to select less than one element
In call:
myplots[[index]]
myplots is not in my javascript code or in opencpu.js Does anyone know what I might be doing wrong?
Thanks.

Related

Using svelte actions to manipulate an html element with d3

this is somewhat related to my previous post where I learned a bit more about actions.
I have been trying to figure out how to work with this nifty feature but I seem to be a bit stuck in the past few hours.
In my Component I create an SVG viewbox like so:
<svg id="pitch" viewBox={`0 0 ${width} ${height}`} use:foo>
</svg>
then drawPitch is this function:
function foo(node) {
// the node has been mounted in the DOM
let g = node.append('h1');
g.text("This is the text I'd like to render to check that it works");
return {
destroy() {
// the node has been removed from the DOM
}
};
}
From what I've understood in the docs, the use:foo will pass the calling node to foo, so I thought directly appending svg elements to it should work.
Do I need to update it somehow?
Here is a repl with reproducible code.
I get the following error:
Missing "./types/runtime/internal/keyed_each.js" export in "svelte" package
Thank you!
I would expect the code in foo to start with d3.select(node), and everything to work based off that. Otherwise the DOM tree generated by d3 will not be connected to your document at all. Alternatively the resulting element (selection.node()) has to be appended to node at some point.
The error sounds highly unrelated and probably would require more context.
Note: You cannot add HTML directly to SVGs, SVGs are for canvas-like vector graphics, not document layouts. If you want to insert text, use the <text> element.

How to select a specific element inside editor (tinymce 4.x)

I have an image inside the editor using plugin 'imagetools' and added an additional image operation on it (that works fine). After this custom operation is done I'm loosing the selection of the image, that I try to select again.
Since the image is initally selected I would have the chance to capture some information to select it again after custom image operation. But whatever I try it doesn't work:
Before operation (while the image is selected by user):
var node = tinymce.activeEditor.selection.getNode();
After operation:
tinyMCE.activeEditor.dom.select(node);
-> nothing selected
tinyMCE.activeEditor.selection.select(node);
-> Error: Argument 1 ('refNode') to Range.setStart must be an instance of Node
I assume the solution is pretty simple. I just don't get it and tinymce documentation is not really helpful on this.
Found it: You can set a bookmark before doing any changes on or inside the element:
var bookmark = tinymce.activeEditor.selection.getBookmark();
After element processing you set back the bookmark:
tinymce.activeEditor.selection.moveToBookmark(bookmark);
Now your previously selected element should will be selected again.

All XPaths return a non-existent error in CasperJS?

Just to be clear I am using SpookyJS which is a library that allows for a headless CasperJS.
I am able to click and select other XPaths just fine on all other pages,the problem is only on a particular page, the page loads perfectly but all of the XPaths return this error.
Cannot dispatch mousedown event on nonexistent selector
I have a screenshot taken before the function attempts to click the xPath and the screenshot shows that the page is loaded perfectly.
if I trying using the waitForSelector function I get the timeout error, I've tried different XPaths on different pages and none of them work.
Here is my code in CoffeeScript don't mind the spooky.then just think of it as casper.then:
// 3 steps occur before this and they work perfectly
spooky.then([{x:selectXPath}, () ->
#wait(3000, () ->
eval(x) // This loads the xPath function
#capture('server/components/spooky/img.png')
#click(xPath('//*[#id="wp-page-header-middle"]/table/tbody/tr/td[1]/a'))
)
])
The table I'm interested in is inside of an iframe.
The problem is that the element is inside of an iframe. The element can be selected, but you first need to switch into the context of the iframe to run operations on it. This is done through withFrame(). You can either select the iframe by index or name. Here is an example by index (first iframe):
#withFrame(0, () ->
#click(xPath('//*[#id="wp-page-header-middle"]/table/tbody/tr/td[1]/a'))
)
You may also need to adjust your XPath, because the tbody may not be present in the markup initially. PhantomJS 1.x doesn't add it like modern browsers do, so you may need to do this dynamically:
'//*[#id="wp-page-header-middle"]/table//tr/td[1]/a'

Trying to dynamically change width of hidden column leads to error "to many recursions"

unfortunately I can't find any help concerning to my specific problem.
I try to simplify it:
My grid consists of a shown column (A) and a hidden column (B) and other shown columns as well (C,D). With a custom button I can switch between these two columns, so that A is hidden and B is shown and vice versa.
My aim is as follows:
If the width of (shown) A has been changed, the width of (hidden) B should also be changed.
My current way to realize this this:
resizeStop: function () {
var $self = $(this);
shrinkToFit = $self.jqGrid("getGridParam", "shrinkToFit");
$self.jqGrid("setGridWidth", this.grid.newWidth, shrinkToFit);
var a = $self.jqGrid("getGridParam","colModel");
$self.jqGrid("setColWidth", "customers.name_short",a[2].width);
},
I works, but I have to wait for a wile and in addition to that I get the following log: "too much recursion". It seems that the function setColWidth is called more than 300 times.
I analyzed the code of setColWidth but I could not find any hint where it would call itself.
Can anybody help me?
Thanks in advance!
I suppose that you use my method setColWidth from here and the answer. It's wrong to use it inside of resizeStop callback.
You wrote: "With a custom button I can switch between these two columns, so that A is hidden and B is shown and vice versa." It seems to me that you need place one call of setColWidth method directly after you makes the column A or the column B visible (in the click event handle of your custom button). It should solve the problem.
UPDATED: The following demo http://jsfiddle.net/OlegKi/m7f9ghwq/18/ demonstrates the approach.

google.setOnLoadCallback(drawChart);

I have google chart on my page, but right now chart is drawn when Google Visualization library is loaded on the page load, and I have to give data dynamically through ajax, so is it possible to change the callback method, or is there any alternative?
I managed with it as i wanted, It can be helpful for someone, and if there is better solution for this please do suggest.
I removed this setOnLoadCallback function - google.setOnLoadCallback(drawChart);
This call back will call the drawChart() as soon as the visulization library is loaded,
(but I didn't wanted it, i wanted to call it on button click).
so I called drawChart(); function directily in the button click function code.
Then I faced problem with rendering the dynamic data to the datatable, when I was putting hard coded values, the chart drawn fine, but as I put variables instead of those values, it was unable to generate chart.
so i parsed the variable into integer by parseInt(doc_pre),
And it worked fine.
You can check this :
Jquery Charts

Resources