score:1
after several years, i have an answer.
it seems like these wrapper functions like hplot()
does not support additional tooltip variables even with a simple custom formatter function. see working example below based on the dataset from the question.
require(rcharts)
# create data frame
df <- data.frame(x = c(1:5), y = c(5:1),
z = c("a", "b", "c", "d", "e"),
name = c("k", "l", "m", "n", "o"))
# plot using hplot() approach
h1 <- hplot(x = "x", y = "y", data = df, type = "scatter", group = "z")
h1$tooltip(borderwidth=0, followpointer=true, followtouchmove=true, shared = false,
formatter = "#! function(){return 'x: ' + this.point.x + '<br>y: ' + this.point.y + '<br>z: ' + this.point.z + '<br>name: ' + this.point.name;} !#")
h1
tooltips do not work in the above example because the variables in the array are not named. see str(h1)
.
# plot using manual build
h1 <- rcharts:::highcharts$new()
dlev <- levels(factor(as.character(df$z)))
for(i in 1:length(dlev))
{
h1$series(data = tojsonarray2(df[df$z==dlev[i],,drop=f], json = f,names=t), name = dlev[i],type = c("scatter"), marker = list(radius = 3))
}
h1$tooltip(borderwidth=0, followpointer=true, followtouchmove=true, shared = false,
formatter = "#! function(){return 'x: ' + this.point.x + '<br>y: ' + this.point.y + '<br>z: ' + this.point.z + '<br>name: ' + this.point.name;} !#")
h1
this works because the array variables are named using names=t
in the line starting h1$series...
. see str(h1)
.
this sort of solves the tooltip issue, but there might be other problems with the named arrays. for example, it breaks things in a shiny-app environment. there must be a reason why hplot()
does not use the named arrays.
score:3
rcharts
is a great package. but it still not well documented(maybe i miss this point). i think you need to redefine new js function for tooltip
attribute.
any js literals need to be wrapped between #! and !# . here a beginning but it doesn't work as i imagine ( i think is a good start):
h1$tooltip( formatter = "#! function() { return 'x: ' + this.point.x +
'y: ' + this.point.y +
'name: ' + this.point.group; } !#")
Source: stackoverflow.com
Related Query
- Add values to rCharts hPlot tooltip
- add to tooltip additional values from array
- rCharts Highcharts Add extra data to tooltip
- hPlot pie chart - show percentage in tooltip instead of absolute values
- highcharts pass multiple values to tooltip
- Add tooltip to legend in highcharts when hovering
- Add additional data to Pie Tooltip on Highcharts
- How do I add a tooltip to the x-axis labels in highcharts?
- Display multiple time series with rCharts hPlot
- Highcharts add tooltip that has a small arrow pointing toward the series
- how to pass values to tooltip which not in x and y axis in highcharts
- Highcharts : Shared Tooltip for non-matching x values
- Highcharts JS- add third variable to tooltip for two series
- How to add % symbol to Y axis values in HighChart graph?
- Highchart: add own calculation to tooltip
- How do i add mouse wheel code in Angular2 highcharts in typescript
- Add extra tooltip in Highcharts
- Unable to apply custom pipe to high chart tooltip values
- How to edit tooltip in Highcharts C# code
- Get values formatted on tooltip
- passing json values to highcharts from .net code behind
- Highcharts variation (%) between yaxis values in tooltip
- how to use highcharts tooltip formatter in python code
- Add a custom text tooltip that differs from point to point in Highcharts
- HighCharts: Category values are repeated. Tooltip not showing the correct date
- add vertical and horizontal lines in hplot (rcharts)
- How to add a second tooltip to highcharts
- High Charts add variance instead of values
- Highcharts - Highcharter in R - Getting Tooltip values from df rather than map
- Add more than 3 y-axis in Highcharts. 4th y-axis values aren't displayed
More Query from same tag
- Highcharts, multiple parts chart
- Chart area exceeding series length
- Plugin to convert JSON object from API to Highcharts format
- Highcharts error when add and shift data to hidden series
- Local Angular library using Highcharts breaks in production mode
- HighCharts SyntaxError: missing ] after element list
- How to use a multi-layer map with countries and lakes with Highmaps?
- Highchart with background should be Dots instead of Grid
- Highcharts - svg vs digital
- How can I draw Highcharts horizontal stacked bar with date-time duration
- highcharts change smoothing setting on polar areaspline chart
- Highcharts how to customize enableMouseTracking?
- What is the highcharts-more file needed for?
- Multiple y-axes for column graph categories in highcharts
- Run Highcharts on Server side code to add to Word document
- VB.net 2 dimensional array with data from a list
- Disable highcharts tooltip on certain lines, leave it enabled on others?
- Highchart don't show line if Y.axis is the same
- Highcharts series visibility with csv data source
- Convert JQuery Data into HighChart Format
- How to align HighCharts (bar chart) bars to the top/front?
- How to add additional labels to base of columns in Highcharts?
- Highcharts: why do the point events not work here?
- Highcharts - Assign a color to a specific value when data is dynamic
- Tooltip descriptions hidden beneath buttons and tables
- Does highcharts support displaying groups of columns at different x values?
- Highcharts columns - fixed border width, remove spacing between the bars
- Set Dynamic x-axis range in Highcharts
- Highcharts datalabels getting scrambled on drilldown
- Highcharts losing smooth zoom effect