{"id":13789065,"url":"https://github.com/ramnathv/rCharts","last_synced_at":"2025-05-12T03:31:17.437Z","repository":{"id":7953570,"uuid":"9349217","full_name":"ramnathv/rCharts","owner":"ramnathv","description":"Interactive JS Charts from R","archived":false,"fork":false,"pushed_at":"2016-10-19T05:31:52.000Z","size":9343,"stargazers_count":1192,"open_issues_count":377,"forks_count":655,"subscribers_count":133,"default_branch":"master","last_synced_at":"2024-11-18T02:39:23.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rcharts.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ramnathv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-10T15:25:41.000Z","updated_at":"2024-11-14T05:15:18.000Z","dependencies_parsed_at":"2022-09-15T02:42:32.590Z","dependency_job_id":null,"html_url":"https://github.com/ramnathv/rCharts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnathv%2FrCharts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnathv%2FrCharts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnathv%2FrCharts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramnathv%2FrCharts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramnathv","download_url":"https://codeload.github.com/ramnathv/rCharts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253668000,"owners_count":21944958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T21:00:58.148Z","updated_at":"2025-05-12T03:31:15.926Z","avatar_url":"https://github.com/ramnathv.png","language":"JavaScript","funding_links":[],"categories":["HTML Widgets","Graphic Displays","Interactive plots"],"sub_categories":["Miscellaneous"],"readme":"# rCharts\n\nrCharts is an R package to create, customize and publish interactive javascript visualizations from R using a familiar lattice style plotting interface.\n\n## Installation\n\nYou can install `rCharts` from `github` using the `devtools` package\n\n```coffee\nrequire(devtools)\ninstall_github('ramnathv/rCharts')\n```\n\n## Features\n\nThe design philosophy behind rCharts is to make the process of creating, customizing and sharing interactive visualizations easy. \n\n### Create\n\n`rCharts` uses a formula interface to specify plots, just like the `lattice` package. Here are a few examples you can try out in your R console.\n\n```coffee\nrequire(rCharts)\n\n## Example 1 Facetted Scatterplot\nnames(iris) = gsub(\"\\\\.\", \"\", names(iris))\nrPlot(SepalLength ~ SepalWidth | Species, data = iris, color = 'Species', type = 'point')\n\n## Example 2 Facetted Barplot\nhair_eye = as.data.frame(HairEyeColor)\nrPlot(Freq ~ Hair | Eye, color = 'Eye', data = hair_eye, type = 'bar')\n```\n\n### Customize\n\nrCharts supports multiple javascript charting libraries, each with its own strengths. Each of these libraries has multiple customization options, most of which are supported within rCharts. More documentation is underway on how to use rCharts with each of these libraries.\n\n#### [Polychart](https://github.com/Polychart/polychart2).\n\nWe will create our first chart using Polychart, a javascript charting library based on the grammar of graphics, and inspired by ggplot2.\n\n```coffee\nr1 \u003c- rPlot(mpg ~ wt | am + vs, data = mtcars, type = 'point', color = 'gear')\nr1\n```\n\n![polychart](screenshots/polychart.png)\n\nThere, we have our first embedded chart with nice tooltips! Let me add some interactivity to this chart now using javascript.\n\n```js\ngraph_chart1.addHandler(function(type, e){\n  var data = e.evtData;\n  if (type === 'click'){\n    return alert(\"You clicked on car with mpg: \" + data.mpg.in[0]);\n  }\n})\n```\n\n---\n\n#### [Morris](https://github.com/oesmith/morris.js)\n\nThe next library we will be exploring is Morris.\n\n```coffee\ndata(economics, package = 'ggplot2')\necon \u003c- transform(economics, date = as.character(date))\nm1 \u003c- mPlot(x = 'date', y = c('psavert', 'uempmed'), type = 'Line',\n  data = econ)\nm1$set(pointSize = 0, lineWidth = 1)\nm1\n```\n\n![morris](screenshots/morris.png)\n\nHurray! There we have our second chart!\n\n---\n\n#### [NVD3](https://github.com/novus/nvd3)\n\nNext, I will demonstrate my all time favorite d3js library, NVD3, which produces amazing interactive visualizations with little customization.\n\n```coffee\nhair_eye_male \u003c- subset(as.data.frame(HairEyeColor), Sex == \"Male\")\nn1 \u003c- nPlot(Freq ~ Hair, group = \"Eye\", data = hair_eye_male, \n  type = 'multiBarChart')\nn1\n```\n\n![nvd3](screenshots/nvd3.png)\n\nSee the interactivity that comes at zero cost! \n\n---\n\n#### [xCharts](https://github.com/tenXer/xcharts/)\n\nThe next library to demo would be xCharts, a slick looking charting library using d3js, made by TenXer.\n\n```coffee\nrequire(reshape2)\nuspexp \u003c- melt(USPersonalExpenditure)\nnames(uspexp)[1:2] = c('category', 'year')\nx1 \u003c- xPlot(value ~ year, group = 'category', data = uspexp, \n  type = 'line-dotted')\nx1\n```\n\n![xchart](screenshots/xcharts.png)\n\nThere is your xChart\n\n---\n\n#### [Highcharts](http://www.highcharts.com/)\n\n```coffee\nh1 \u003c- Highcharts$new()\nh1$chart(type = \"spline\")\nh1$series(data = c(1, 3, 2, 4, 5, 4, 6, 2, 3, 5, NA), dashStyle = \"longdash\")\nh1$series(data = c(NA, 4, 1, 3, 4, 2, 9, 1, 2, 3, 4), dashStyle = \"shortdot\")\nh1$legend(symbolWidth = 80)\nh1\n```\n\n![highcharts](screenshots/highcharts.png)\n\n---\n\n#### [Leaflet](http://leafletjs.com/)\n\n```coffee\nmap3 \u003c- Leaflet$new()\nmap3$setView(c(51.505, -0.09), zoom = 13)\nmap3$marker(c(51.5, -0.09), bindPopup = \"\u003cp\u003e Hi. I am a popup \u003c/p\u003e\")\nmap3$marker(c(51.495, -0.083), bindPopup = \"\u003cp\u003e Hi. I am another popup \u003c/p\u003e\")\nmap3\n```\n\n![leaflet](screenshots/leaflet.png)\n\n---\n\n#### [Rickshaw](https://github.com/shutterstock/rickshaw)\n\n```coffee\nusp = reshape2::melt(USPersonalExpenditure)\np4 \u003c- Rickshaw$new()\np4$layer(value ~ Var2, group = 'Var1', data = usp, type = 'area')\np4\n```\n\n![rickshaw](screenshots/rickshaw.png)\n\n### Share\n\nrCharts allows you to share your visualization in multiple ways, as a standalone page, embedded in a shiny application, or in a tutorial/blog post.\n\n#### Standalone\n\nYou can publish your visualization as a standalone html page using the `publish` method. Here is an example. Currently, you can publish your chart as a `gist` or to `rpubs`.\n\n```coffee\n## \nnames(iris) = gsub(\"\\\\.\", \"\", names(iris))\nr1 \u003c- rPlot(SepalLength ~ SepalWidth | Species, data = iris, \n  color = 'Species', type = 'point')\nr1$publish('Scatterplot', host = 'gist')\nr1$publish('Scatterplot', host = 'rpubs')\n```\n\n#### Shiny Application\n\nrCharts is easy to embed into a Shiny application using the utility functions `renderChart` and `showOutput`. Here is an example of an [rCharts Shiny App](http://glimmer.rstudio.com/ramnathv/rChartApp/).\n\n```coffee\n## server.r\nrequire(rCharts)\nshinyServer(function(input, output) {\n  output$myChart \u003c- renderChart({\n    names(iris) = gsub(\"\\\\.\", \"\", names(iris))\n    p1 \u003c- rPlot(input$x, input$y, data = iris, color = \"Species\", \n      facet = \"Species\", type = 'point')\n    p1$addParams(dom = 'myChart')\n    return(p1)\n  })\n})\n\n## ui.R\nrequire(rCharts)\nshinyUI(pageWithSidebar(\n  headerPanel(\"rCharts: Interactive Charts from R using polychart.js\"),\n  \n  sidebarPanel(\n    selectInput(inputId = \"x\",\n     label = \"Choose X\",\n     choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'),\n     selected = \"SepalLength\"),\n    selectInput(inputId = \"y\",\n      label = \"Choose Y\",\n      choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'),\n      selected = \"SepalWidth\")\n  ),\n  mainPanel(\n    showOutput(\"myChart\", \"polycharts\")\n  )\n))\n```\n\n#### Blog Post\n\nrCharts can also be embedded into an Rmd document using `knit2html` or in a blog post using `slidify`. Here are a few examples of tutorials written using `rCharts` and `slidify`.\n\n1. [Parallel Coordinate Plots](http://rcharts.io/gallery/#visualizationType=parallel%20coordinates)\n2. [NY Times Graphics Tutorial](http://rcharts.io/nytinteractive/)\n\nMore in the [rCharts website](http://rcharts.io) and the [Gallery](http://rcharts.io/gallery/).\n\n## More\n\n### Credits\n\nMost of the implementation in `rCharts` is inspired by [rHighcharts](https://github.com/metagraf/rHighcharts) and [rVega](https://github.com/metagraf/rVega). I have reused some code from these packages verbatim, and would like to acknowledge the efforts of its author [Thomas Reinholdsson](https://github.com/reinholdsson).\n\n### License\n\nrCharts is licensed under the MIT License. However, the JavaScript charting libraries that are included with this package are licensed under their own terms. All of them are free for non-commercial and commercial use, with the exception of __Polychart__ and __Highcharts__, both of which require paid licenses for commercial use. For more details on the licensing terms, you can consult the `License.md` file in each of the charting libraries.\n\n### See Also\n\nThere has been a lot of interest recently in creating packages that allow R users to make use of Javascript charting libraries. \n\n- [gg2v](https://github.com/hadley/gg2v) by [Hadley Wickham](https://github.com/hadley)\n- [clickme](https://github.com/nachocab/clickme) by [Nacho Caballero](https://github.com/nachocab)\n- [rVega](https://github.com/metagraf/rVega) by [Thomas Reinholdsson](https://github.com/reinholdsson)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framnathv%2FrCharts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framnathv%2FrCharts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framnathv%2FrCharts/lists"}