Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JohnCoene/peity
Inline charts for R
https://github.com/JohnCoene/peity
htmlwidgets inline-graph peity rmarkdown
Last synced: 3 months ago
JSON representation
Inline charts for R
- Host: GitHub
- URL: https://github.com/JohnCoene/peity
- Owner: JohnCoene
- License: other
- Created: 2017-02-14T11:31:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-28T15:26:15.000Z (over 5 years ago)
- Last Synced: 2024-05-01T15:29:54.403Z (6 months ago)
- Topics: htmlwidgets, inline-graph, peity, rmarkdown
- Language: R
- Homepage:
- Size: 42 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - peity - Peity htmlwidget for R. (Visualization / Sparkline)
- jimsghstars - JohnCoene/peity - Inline charts for R (R)
README
[![Build Status](https://travis-ci.org/JohnCoene/peity.svg?branch=master)](https://travis-ci.org/JohnCoene/peity)
[![saythanks](https://img.shields.io/badge/say-thanks-ff69b4.svg)](https://saythanks.io/to/JohnCoene)# peity
[Peity](http://benpickles.github.io/peity/) htmlwidget for R.
> Peity (sounds like deity) is a jQuery plugin that converts an element's content into a mini pie donut line or bar chart and is compatible with any browser that supports : Chrome, Firefox, IE9+, Opera, Safari.
## Install
```R
devtools::install_github("JohnCoene/peity")
```## Basics
```R
library(peity)peity("1/5", type = "pie")
# pass options as list
peity(c(1,5), type = "donut", options = list(fill = I(c("green", "red")), radius = 100))
peity(c(1,5), type = "donut", options = list(fill = c("#845422", "#ead61c"), radius = 50, innerRadius = 40))
peity(rnorm(50, 2, 1), type = "line", options = list(width = 100))
peity(c(1,5,3), type = "bar", options = list(fill = I("green")))
```## Set colors dynamically
```R
peity(c(4,-2,3, -4), type = "bar", options = list(fill = htmlwidgets::JS('function(value) {
return value > 0 ? "green" : "red"
}')))
js_fun <- htmlwidgets::JS('function(_, i, all) {
var g = parseInt((i / all.length) * 255)
return "rgb(255, " + g + ", 0)"
}')peity(c(0,-3,-6,-4,-5,-4,-7,-3,-5,-2), type = "bar", options = list(fill = js_fun))
```## Rmarkdown
Use in rmarkdown in-line like so ``r peity(c(1,4,2), type = "pie")``, or in blocks like so:
```R
peity(c(1,4,2), type = "pie")
```