score:1
You can make a chart with custom names in highcharts like so: http://jsfiddle.net/zh65suhm/. That is, changing your tooltip to the following:
'<b>{point.percentage:.1f}%</b><br>Custom point: <b>{point.customData}</b>'
Where each point has its own customData
value.
I have not used highcharter, but looking at the API it might be possible to some work with this:
hc_add_series(favorite_bars, "pie", hcaes(name = bar, y = percent), name = "Bars") %>%
Potentially this could work:
hc_add_series(favorite_bars, "pie", hcaes(name = bar, y = percent, customData = variable_with_customdata), name = "My pie") %>%
Hopefully this will help you out.
score:3
To my knowledge, the solution proposed by @ewolden does not work in highcharter
.
A simple and flexible solution for setting additional information to the tooltip of a highcharter
pie is the following:
library(highcharter)
A <- c("a", "b", "c", "d")
B <- c(4, 6, 9, 2)
C <- c(23, 26, 13, 15)
df <- data.frame(A, B, C)
# A modified version of the "hc_add_series_labels_values" function
# The "text" input is now available
myhc_add_series_labels_values <- function (hc, labels, values, text, colors = NULL, ...)
{
assertthat::assert_that(is.highchart(hc), is.numeric(values),
length(labels) == length(values))
df <- dplyr::data_frame(name = labels, y = values, text=text)
if (!is.null(colors)) {
assert_that(length(labels) == length(colors))
df <- mutate(df, color = colors)
}
ds <- list_parse(df)
hc <- hc %>% hc_add_series(data = ds, ...)
hc
}
# Set the "text" input in myhc_add_series_labels_values
# point.text is now available inside pointFormat of hc_tooltip
highchart() %>%
hc_chart(type = "pie", data=df) %>%
myhc_add_series_labels_values(labels=A, values=B, text=C) %>%
hc_tooltip(crosshairs=TRUE, borderWidth=5, sort=TRUE, shared=TRUE, table=TRUE,
pointFormat=paste('<br><b>A: {point.percentage:.1f}%</b><br>C: {point.text}')) %>%
hc_title(text="ABC", margin=20, style=list(color="#144746", useHTML=TRUE))
With this solution we can print the content of two or more variables inside the tooltip.
Below we add a variable D
to the df
dataset and visualize it in the tooltip:
D <- c("Mars", "Jupiter", "Venus", "Saturn")
df <- data.frame(A, B, C, D)
txt <- paste("C:",C," <br>D:", D)
highchart() %>%
hc_chart(type="pie", data=df) %>%
myhc_add_series_labels_values(labels=A, values=B, text=txt) %>%
hc_tooltip(crosshairs=TRUE, borderWidth=5, sort=TRUE, shared=TRUE, table=TRUE,
pointFormat=paste('<br><b>A: {point.percentage:.1f}%</b><br>{point.text}')) %>%
hc_title(text = "ABC", margin = 20, style = list(color = "#144746", useHTML = TRUE))
Source: stackoverflow.com
Related Query
- pie chart highcharter R
- Highcharts display label for pie chart using html table as data source
- 3D Pie Chart using Highcharter
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- HighCharts - Make the pie chart 100% of the div
- Place text in center of pie chart - Highcharts
- highcharts: dynamically define colors in pie chart
- Highcharts - labels inside and outside a pie chart
- highcharts: pie chart - reduce number of slice
- Highcharts Pie Chart ignores percentageDecimals tooltip setting and has floating point inaccuracy issue
- Highcharts pie chart dynamically changes size
- Highcharts not displaying data labels for Pie chart in arabic
- Total of values in HighCharts Pie Chart
- Dealing with pie chart label overlap [Highcharts]
- HighCharts Pie Chart - Add text inside each slice
- highcharts - chart names for multiple pie chart series in one chart
- Highcharts Pie Chart Drilldown not showing on third drill
- Highchart's Pie Chart Opacity Changes on Hover
- Symbol-outline with pie chart -or- custom legend symbols
- Highcharts: Updating a Pie Chart with setData()
- Highcharts Pie Chart Label Threshold
- How do I make each row in a HTML table a pie chart in Highcharts?
- HighCharts - Pie chart drilldown for multilevel (3 to 4 level)
- chart shows very small pie
- Nested/multi-level/drill-down Pie Chart in Javascript?
- Grand Totals in HighCharts Pie Chart Legend
- How to remove white space from pie chart in highchart.js?
- HighCharts Pie Chart Legend value alignment
- How get data name in Highcharts pie chart legend instead of "Slice" using array of values?
- Rotating dataLabels in a Highcharts pie chart
More Query from same tag
- Is there any option in Highcharts for simplifyng a line graph?
- Rendering the charts as columnrange type
- Highcharts- How to modify tooltip texts in drilldown pie chart
- Set distance between labels and chart in Highcharts
- HighCharts column chart populated with series data from a function
- Parse an array in js
- Simultaneous actions on action event on one graph
- How to set width limitation for text in highcharts?
- How to represent hour to hour Highcharts tooltip - Time series?
- How to change selected point styles in Highcharts?
- HighMaps: Change the size/width of ColorAxis
- Display of plotted point labels not appearing properly on X Range Chart for the first date of month - Highcharts
- Adding a series dynamically with HighCharts Stock Charts
- Highchart, bar chart with multiple series
- Draw a exrta line at specific angle in high chart
- Javascript Highcharts Mapping multiple values without showing them all in the chart
- highcharts - make one column dynamic average?
- Highcharts tickinterval set to one minute shows only one date
- Highstock/chart - On resize, don't crop chart
- Highchart Treemap colorindex for fixed color values
- change color of highcharts legend page navigation buttons
- Divide X axis by Clickable Zones in HIghchart
- Highcharts/Highstock : Auto scroll on the graph with overflow-x, instead of a scrollbar
- How to pass the database data and display it in yii2 highCharts?
- Is it possible to set Highcharts to hide tooltip when the mouse pointer is 30px away
- Highcharts: How to exempt a series from redraw zoom calculations?
- How can i use arrays in Highcarts?
- Highcharts with Google Analytics Oauth 2.0
- How do I set the background color of a Highcharts HTML label?
- Getting data from Postgres in JSON format in ROR into a Highcharts javascript