highcharter (version 0.7.0)

hc_add_series_labels_values: Shortcut for add series for pie, bar and columnn charts

Description

This function add data to plot pie, bar and columnn charts.

Usage

hc_add_series_labels_values(hc, labels, values, colors = NULL, ...)

Arguments

hc

A highchart htmlwidget object.

labels

A vector of labels.

values

A numeric vector. Same length of labels.

colors

A not required color vector (hexadecimal format). Same length of labels.

...

Additional shared arguments for the data series (http://api.highcharts.com/highcharts#series).

Examples

Run this code
# NOT RUN {
data("favorite_bars")
data("favorite_pies")

highchart() %>% 
  hc_title(text = "This is a bar graph describing my favorite pies
                   including a pie chart describing my favorite bars") %>%
  hc_subtitle(text = "In percentage of tastiness and awesomeness") %>% 
  hc_add_series_labels_values(favorite_pies$pie, favorite_pies$percent, name = "Pie",
                             colorByPoint = TRUE, type = "columnn") %>% 
  hc_add_series_labels_values(favorite_bars$bar, favorite_bars$percent,
                             colors = substr(terrain.colors(5), 0 , 7), type = "pie",
                             name = "Bar", colorByPoint = TRUE, center = c('35%', '10%'),
                             size = 100, dataLabels = list(enabled = FALSE)) %>% 
  hc_yAxis(title = list(text = "percentage of tastiness"),
           labels = list(format = "{value}%"), max = 100) %>% 
  hc_xAxis(categories = favorite_pies$pie) %>% 
  hc_legend(enabled = FALSE) %>% 
  hc_tooltip(pointFormat = "{point.y}%")
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace