Title: | Packed Bar Charts with 'plotly' |
---|---|
Description: | Packed bar charts are a variation of treemaps for visualizing skewed data. The concept was introduced by Xan Gregg at 'JMP'. |
Authors: | Adam Spannbauer [aut, cre] |
Maintainer: | Adam Spannbauer <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.2 |
Built: | 2024-10-24 03:44:04 UTC |
Source: | https://github.com/adamspannbauer/rpackedbar |
Output and render functions for using 'rPackedBar' within 'shiny' applications and interactive Rmd documents.
packedBarOutput(outputId, width = "100%", height = "400px", inline = FALSE, clickedBarInputId = paste0(outputId, "_clicked")) renderPackedBar(expr, env = parent.frame(), quoted = FALSE)
packedBarOutput(outputId, width = "100%", height = "400px", inline = FALSE, clickedBarInputId = paste0(outputId, "_clicked")) renderPackedBar(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
inline |
use an inline (span()) or block container (div()) for the output |
clickedBarInputId |
The input id to assign the label of the clicked bar.
Defaults to |
expr |
An expression that generates an rPackedBar. |
env |
The environment in which to evaluate |
quoted |
Is |
Packed bar charts are a variation of treemaps for visualizing skewed data. The concept was introduced by XanGregg at JMP (https://community.jmp.com/t5/JMP-Blog/Introducing-packed-bars-a-new-chart-form/ba-p/39972).
plotly_packed_bar(input_data, label_column, value_column, number_rows = "guess", plot_title = "", xaxis_label = "", hover_label = "", min_label_width = 0.03, color_bar_color = "steelblue", label_color = "black")
plotly_packed_bar(input_data, label_column, value_column, number_rows = "guess", plot_title = "", xaxis_label = "", hover_label = "", min_label_width = 0.03, color_bar_color = "steelblue", label_color = "black")
input_data |
data.frame with data to plot, should have a column of labels for bars and column of numbers relating to bar length |
label_column |
either the column number or quoted name in |
value_column |
either the column number or quoted name in |
number_rows |
The number of rows to occur in barchart (i.e. the number of colored bars). The default of 'guess' will attempt to find the 'elbow' in the numeric data with a min value of 3 and a max of 25. |
plot_title |
main title for plot |
xaxis_label |
label to put on xaxis |
hover_label |
text to appear by number in hover information (typically same as xaxis label) |
min_label_width |
min relative length of bar to receive a static label (too small and text will overflow sides of bar) |
color_bar_color |
color of main bars in chart (can be name or hex) remaining bars will be variations of gray |
label_color |
color of text labels that appear over colored bars |
The packed barchart currently only works for uniformly positive or uniformly negative data; negative values will be removed before plotting when mixed data is provided.
'plotly' object of the packed bar chart
## Not run: data(GNI2014, package = 'treemap') data.table::setDT(GNI2014) my_input_data = GNI2014[,sum(population), by=country] plotly_packed_bar(my_input_data, label_column = "country", value_column = "V1", plot_title = "Population 2014", xaxis_label = "Population", hover_label = "Population", min_label_width = .025, color_bar_color = "orange") ## End(Not run)
## Not run: data(GNI2014, package = 'treemap') data.table::setDT(GNI2014) my_input_data = GNI2014[,sum(population), by=country] plotly_packed_bar(my_input_data, label_column = "country", value_column = "V1", plot_title = "Population 2014", xaxis_label = "Population", hover_label = "Population", min_label_width = .025, color_bar_color = "orange") ## End(Not run)