Area select event for R leaflet in shiny - r

I've played with the mouse click event in leaflet using the following code:
mymap=leaflet()
selected_site=eventReactive(input$mymap_marker_click,{
event <- input$mymap_map_marker_click
return(mydt[Long==event$lng & Lat==event$lat,get("sites")])
})
to display a plot from a data.table after a click on a point of the map.
Now, I'd like to select an entire area then display data binding to it.
In other terms, I'd like to select not a couple of (Lat,Long) but a series of (Lat1, Long1)....(Latn,Longn)
Is there a mean to do it in leaflet ?
Thanks in advance,

You just have to instantiate a L.Polygon per area, and attach an event handler to it: http://playground-leaflet.rhcloud.com/zab/edit?html,console,output
Keep in mind that you can make areas transparent (zero opacity but fill option still set to true) and still get mouse events from them.

Related

Hide/show multiple graphs in qcustomplot

I am making a data logger for a couple of Arduino sensors in Qt. The problem is that I want to log the data in 3 different graphs, each of one having one specific scale, and then I'll choose what graph I will show (just one of the 3 graphs will be displayed at one time).
I tried something like this:
QCPGraph *sensorXGraph = ui->graph->addGraph();
QCPGraph *sensorYGraph = ui->graph->addGraph();
sensorXGraph->setVisible(false);
sensorYGraph->setVisible(false);
And then, in a slot call from a RadioButton clicked event I did:
sensorXGraph->setVisible(true);
sensorYGraph->setVisible(false);
And the inverse for another RadioButton. But the graph seems to keep the axis of the last graph created. So, if I try to see the sensorXGraph, the data will change accordingly but y axis range will be the one of the sensorYGraph.
I also tried to make a single QCPAxis for each graph, but it started to be a mess because I had to make QCPAxisRect for each graph as well and the result was worse than the first trial.
How do I achieve to change from one graph to another properly?
Thank you in advance.
You can call clearGraphs() on your QCustomPlot and then add whatever graphs you want to display by calling addGraph() and then call replot() on your QCustomPlot. So it would be something like this:
ui->graph->clearGraphs();
ui->graph->addGraph();
// Do whatever you need to do to edit your graph.
ui->graph->replot();
Since you are using a radio button I think that it would be easier to draw one graph and add the necessary data and labels based on whatever radio button has been selected. Hopefully that helps!

Get data from mouse events in plot.ly or ggvis within r (not shiny)

I want to use interactive plots in R to be able to select x intervals in plots, i have tried plot.ly and ggvis and it seems that the mouse click on the plot followed by horizontal drag, used for zooming is exactly what i want, but zoom would have to be disabled and the [x start, x end] values must be returned to R. Any ideas if this is possible, and if so, how?
I tried to make tooltip function available with static_output (without shiny).
You can check my fork (https://github.com/lujiacn/ggvis
), enable the tooltip by default, in Rstudio and output html widget.
The way is put tooltip content in one variable called "tooltip". If no "tooltip" variable, wills show the all values linked to the data.

IcCube - How can I Make The Histogram (AMCHARTS/ Serial) Hidden

my report contain a PieChar and a Histogram , at first i'm need that just The PieChart is shown and the Histogram is hidden, what i'm need is when I click on the pieChart the Histogram must be shown.
I change Behavior-> "Pop-up" but it's still shown
I try to apply this demo Demo but the histogram still shown, i don't know why??
Any one can help me on that ???. THX,B.Marwen
Behavior -> "Pop-up" won't be applied in Editing mode. It works only in reporting mode.
You have to tie them to each other with event (e.g. set "onCellClick" event value in Pie Chart and filter by this value in histogram).

iplot.setExtendedQuery: How to display custom mouse over information?

Concerning the superb iplots package in R:
By default, pressing CTRL and moving the mouse over a point in a scatter plot shows the x and y values of this point. How can I extend this to also show other attributes, which are not part of the plot, as shown here (see Mondrian screenshot) and as asked here, too?
In Mondrian, this works perfectly well by selecting any attributes within the data overview window and then pressing CTRL + SHIFT on a data point in a scatter plot for example. In iPlots, there is no way to select the attributes like this. I thought iplot.setExtendedQuery() is the key. However, there are no examples on how to use the query string.
Selecting a point plus printing the attributes using sth in the veins of mydata[iset.selected(), ] can't be the only way to go...

Sikuli Image differentiaton

I have a case where there is an OK button on two windows. I want to click the OK button on the former window but using Sikuli I am unable to do it. I tried using Python script getting the nearest button using Y co-ordinates. But I guess its not working.
Find something that's in the window you're interested in but not in the other (e.g. part of the title), extend the matched area to contain the button you want but not the other one, then search for the button within that area.
A couple of options come to mind:
Restrict your search to a particular area of the screen either by pre-defining a region, (region.click(okButton1), or
you can try using sorted() to sort the y coordinates (if they appear left-and-right of each other) or x coordinates (if they appear above-and-below each other) of the two OK buttons, and then click on the one of interest like so--
#to find top-most OK Button
def byY(match):
return match.y
okButtons = list([x for x in findAll(OkButtonPic)]) #make a list of the OK Buttons
TopOkButton = sorted(okButtons, key=byY)[0] #sort them according to Y values
click(topOkButton)
#to find left-most OK button
def byX(match):
return match.x
okButtons = list([x for x in findAll(OkButtonPic)])
leftOkButton = sorted(okButtons, key=byX)[0]
click(leftOkButton)
If there is anything distinct that reliably appears near the OK button that you want to click, you can click(uniqueThing).targetOffset(pixelsX,pixelsY).
If the OK button you want to click is in a window that is now covered, there are other issues to deal with, making the window visible first, but that's not what it sounds like your question is really asking...

Resources