Title: | Radar Chart from 'Chart.js' |
---|---|
Description: | Create interactive radar charts using the 'Chart.js' 'JavaScript' library and the 'htmlwidgets' package. 'Chart.js' <http://www.chartjs.org/> is a lightweight library that supports several types of simple chart using the 'HTML5' canvas element. This package provides an R interface specifically to the radar chart, sometimes called a spider chart, for visualising multivariate data. |
Authors: | Doug Ashton [aut, cre], Shane Porter [aut], Adeel Khan [ctb], Nick Downie [ctb] (chart.js library), Tanner Linsley [ctb] (chart.js library), William Entriken [ctb] (chart.js library) |
Maintainer: | Doug Ashton <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.1.9000 |
Built: | 2024-11-21 03:05:04 UTC |
Source: | https://github.com/mangothecat/radarchart |
R bindings to the radar plot in the chartJS library
chartJSRadar(scores, labs, width = NULL, height = NULL, main = NULL, maxScale = NULL, scaleStepWidth = NULL, scaleStartValue = 0, responsive = TRUE, labelSize = 18, showLegend = TRUE, addDots = TRUE, colMatrix = NULL, polyAlpha = 0.2, lineAlpha = 0.8, showToolTipLabel = TRUE, ...)
chartJSRadar(scores, labs, width = NULL, height = NULL, main = NULL, maxScale = NULL, scaleStepWidth = NULL, scaleStartValue = 0, responsive = TRUE, labelSize = 18, showLegend = TRUE, addDots = TRUE, colMatrix = NULL, polyAlpha = 0.2, lineAlpha = 0.8, showToolTipLabel = TRUE, ...)
scores |
Data frame or named list of scores for each axis.
If |
labs |
Labels for each axis. If left unspecified labels are taken from the scores data set. If set to NA then labels are left blank. |
width |
Width of output plot |
height |
Height of output plot |
main |
Character: Title to be displayed |
maxScale |
Max value on each axis |
scaleStepWidth |
Spacing between rings on radar |
scaleStartValue |
Value at the centre of the radar |
responsive |
Logical. whether or not the chart should be responsive and resize when the browser does |
labelSize |
Numeric. Point label font size in pixels |
showLegend |
Logical whether to show the legend |
addDots |
Logical. Whether to show a dot for each point |
colMatrix |
Numeric matrix of rgb colour values. If |
polyAlpha |
Alpha value for the fill of polygons |
lineAlpha |
Alpha value for the outlines |
showToolTipLabel |
Logical. If |
... |
Extra options passed straight to chart.js. Names must match existing options http://www.chartjs.org/docs/#getting-started-global-chart-configuration |
# Using the data frame interface chartJSRadar(scores=skills) # Or using a list interface labs <- c("Communicator", "Data Wangler", "Programmer", "Technologist", "Modeller", "Visualizer") scores <- list("Rich" = c(9, 7, 4, 5, 3, 7), "Andy" = c(7, 6, 6, 2, 6, 9), "Aimee" = c(6, 5, 8, 4, 7, 6)) # Default settings chartJSRadar(scores=scores, labs=labs) # Fix the max score chartJSRadar(scores=scores, labs=labs, maxScale=10) # Fix max and spacing chartJSRadar(scores=scores, labs=labs, maxScale=12, scaleStepWidth = 2) # Change title and remove legend chartJSRadar(scores=scores, labs=labs, main = "Data Science Radar", showLegend = FALSE) # Add pass through settings for extra options chartJSRadar(scores=scores, labs=labs, maxScale =10, scaleLineWidth=5)
# Using the data frame interface chartJSRadar(scores=skills) # Or using a list interface labs <- c("Communicator", "Data Wangler", "Programmer", "Technologist", "Modeller", "Visualizer") scores <- list("Rich" = c(9, 7, 4, 5, 3, 7), "Andy" = c(7, 6, 6, 2, 6, 9), "Aimee" = c(6, 5, 8, 4, 7, 6)) # Default settings chartJSRadar(scores=scores, labs=labs) # Fix the max score chartJSRadar(scores=scores, labs=labs, maxScale=10) # Fix max and spacing chartJSRadar(scores=scores, labs=labs, maxScale=12, scaleStepWidth = 2) # Change title and remove legend chartJSRadar(scores=scores, labs=labs, main = "Data Science Radar", showLegend = FALSE) # Add pass through settings for extra options chartJSRadar(scores=scores, labs=labs, maxScale =10, scaleLineWidth=5)
Tell htmltools where to output the chart
chartJSRadar_html(id, style, class, width, height, ...)
chartJSRadar_html(id, style, class, width, height, ...)
id |
The id of the target object |
style |
css stylings |
class |
class of the target |
width |
width of target |
height |
height of target |
... |
extra arguments currently unused |
Widget output function for use in Shiny
chartJSRadarOutput(outputId, width = "450", height = "300")
chartJSRadarOutput(outputId, width = "450", height = "300")
outputId |
output variable to read from |
width |
Must be valid CSS unit |
height |
Must be valid CSS unit |
Check and prep the colour matrix
colourMatrix(colMatrix)
colourMatrix(colMatrix)
colMatrix |
A 3 x n matrix of integers between 0-255 |
The checked and prepped matrix of the same size
radarchart:::colourMatrix(diag(255, nrow=3))
radarchart:::colourMatrix(diag(255, nrow=3))
Widget render function for use in Shiny
renderChartJSRadar(expr, env = parent.frame(), quoted = FALSE)
renderChartJSRadar(expr, env = parent.frame(), quoted = FALSE)
expr |
expression passed to shinyRenderWidget |
env |
environment in which to evaluate expression |
quoted |
Logical. Is expression quoted? |
The radarchart package contains a number of demo Shiny apps to illustrate how
to use the plots. The code is in inst/shiny-examples/
and running this
function will allow quick access to the apps.
runExampleApp(example)
runExampleApp(example)
example |
the name of the example. Choose from "basic" or "options". |
## Not run: runExample("basic") ## End(Not run)
## Not run: runExample("basic") ## End(Not run)
Autoscale the radar plot
setRadarScale(maxScale = NULL, scaleStepWidth = NULL, scaleStartValue = 0)
setRadarScale(maxScale = NULL, scaleStepWidth = NULL, scaleStartValue = 0)
maxScale |
Numeric length 1. Desired max limit |
scaleStepWidth |
Numeric length 1. Spacing between rings |
scaleStartValue |
Numeric length 1. Value of the centre |
A list containing the scale options for chartjs
## Not run: setRadarScale(15, 3) setRadarScale(15, 5, 2) ## End(Not run)
## Not run: setRadarScale(15, 3) setRadarScale(15, 5, 2) ## End(Not run)
A dataset containing the skills vectors for three people
skills
skills
A data frame with 6 rows and 4 columns
The axis label for chartJSRadar
Vector of skills for Aimee
Vector of skills for Andy
Vector of skills for Rich
Simulated
A dataset containing the skills vectors for three people but by row rather
than column. This data set is used to show how to rotate the data into a
format accepted by chartJSRadar
.
skillsByName
skillsByName
A data frame with 6 rows and 4 columns
Name of the team member
Their Communicator score: 0-10
Their Data Wangler score: 0-10
Their Modeller score: 0-10
Their Programmer score: 0-10
Their Technologist score: 0-10
Their Visualizer score: 0-10
Simulated