Bokeh Charts: Custom HoverTool variables for Bar Charts - plot

If I make a bar chart like this:
bar = Bar(data,labels,tools='Hover')
I can make tooltips like this:
hover = bar.select(dict(type=HoverTool))
hover.tooltips = [
('Grade',' $x'),
('Students',' #Students'),
]
However, when I do variables with '#variable' in the tooltips, I am limited to those specified in data. In normal Bokeh plots, I can have custom variables associated with data points by using a ColumnDataSource. Bar does not support ColumnDataSources. Is there another way to make custom variables available in Bokeh chart tooltips (hover)?

There's is an open PR to add this feature to the charts interface.
It's going to be part of the next bokeh release and also be available through the dev builds (or in the master branch of course) as soon as it gets merged if you need it sooner.

I had the same problem. The trick here is to use GlyphRenderer to make the bar chart aware of the data source. For e.g., you can add a line
bar.select(dict(type=GlyphRenderer)) before hover = bar.select(dict(type=HoverTool)). You can then refer your custom variables using #cat, #zero etc. See the following link for more information and a working example.
https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/-aDPTqDPA3M

Related

How to display items that make up a slice of a pie chart in Kibana?

I am attempting to create a pie chart that will display the health status of various systems. This is what the chart currently looks like:
Each data point, in addition to the possible errors messages, has a name in its data.
Is it possible to configure the chart so the system names are shown in the pie chart? In the tooltip for each slice would be preferable, but any solution will work.
You can Add (button at the buttom of the configuration) a second visualization, which will then add another layer around your first visualization.
This is an example for log.level and around it labels.url.full:

Adding tooltips in Gvis timeline through R

I'm looking for a solution in R (if possible) to add a custom tooltip content to a timeline chart built with the googlevis package in R.
Specifically, I have a dataset that looks as follows:
Content1 StartDate EndDate Content2 GroupingVariable GroupingVariable2
I can build the timeline out using the R package using the function gvisTimeline, but I want to know how I can build a custom tooltip for the timeline using the field content2.
The solutions I've seen involve changing the javascript code itself, which I am very unfamiliar with. The reason I am hesistant to do this is that the amount of different content I have would be very timeconsuimg to manually add to the JS code(hundreds of different content) - if I could create the vector in R and use that to populate the tooltip it would be viable.
Further, would it be possible to color the chart based on the a third variable as well?
I figured out a possible way to do this. In the bar label argument of timechart, if I pass an array of strings such as barlabel = c("Content1", "Content2.tooltip") it replaces the tooltip with the custom content. The column must end in the .tooltip for it to work.

How to plot a large number of vbar in a Bokeh figure

Hi I am trying to modify the example code here
https://docs.bokeh.org/en/latest/docs/gallery/bar_mixed.html
I removed the toolbar_location=None so that the Bokeh toolbar can show, also I made factors array very large.
I would like to see a figure that I can pan/scroll to view more data rather than it is doing right now-congested all the bars in the fixed width.
How to do that?
As of version 0.12.16 Bokeh only supports initially showing all the factors. There is no mechanism to show only some subset. You can open a GitHub issue if you would like to discuss adding this as a feature.

How to show a plot in a tooltip with Shiny

I'm building a Shiny app using ggvis, and I need to show a plot (a bar chart, for example) in a tooltip.
So basically, when a user clicks one of the points in the main plot I want a tooltip (or something of the sort) to display a new plot with extra information.
Is it possible to do this with Shiny?
The shiny demo at: http://shiny.rstudio.com/gallery/plot-interaction-selecting-points.html shows code where clicking on (or near) a point produces text output, you could modify that to create the second graph instead. I don't know how to do it like a tool tip, but this would produce the graph next to, or just below the graph being clicked on. The example uses ggplot2 rather than ggvis, so I don't know how that would change things.

Can R create a barplot image with clickable bars to insert on a webpage?

I know how to create a barplot, and how to stick it on a webpage; e.g, using hwriteImage in the hwriter package.
What I'd like is for each bar to be a region which highlights on mouseover, and where each bar has a different link when clicked. Similar to this map of the U.S. using the jQuery maphilight plugin, but for a barplot rather than a map. I imagine R could calculate the coordinates of the regions around each bar, generate the HTML AREA tag etc and pass this to maphilight quite easily. Has it been done already? I searched but no luck so far.
Have a look here, which summarises a couple of methods: rggobi and iplots. rggobi looks pretty promising, though maybe the installation looks a bit involved. iplots is only good for scatter plots.
Some other options (I think these are strongest ones at the moment):
googleVis
The googleVis package interfaces with the google charts API: try demo(googleVis) and the third & fourth one are bar chart (there could be more). It has the advantage of being pretty simple to get started with, although these are not R graphics:
df=data.frame(country=c("US", "GB", "BR"), val1=c(10,13,14), val2=c(23,12,32))
Column <- gvisColumnChart(df)
plot(Column)
gridSVG
The gridSVG exports the current grid graphics to an .svg file that can be included into a webpage. Unlike googleVis, it's R graphics (so you can use grid/ggplot2 which are more familiar). It looks like you may have to know some Javascript to further embellish your plots though (e.g. to animate on mouse over, you use grid.garnish(...,onmouseover=...)).
There's some example code you can try here (The really awesome ones are here - usually clicking on the "SVG file" link will have the full interactivity/animation.) (This one is a scatterplot where the points highlight when you move your mouse over them).
As I said - have a look at the package pages, demos, examples, etc to see which suits you.

Resources