Skip to content

Instantly share code, notes, and snippets.

@reinholdsson
reinholdsson / code.R
Last active December 18, 2015 08:39
BUG: rCharts/Highcharts. Incorrect axis names, see hPlot.
library(rCharts)
data <- read.csv2("testData.csv")
hPlot(V1 ~ namn, data = data, type = "column", group = "parti")
@reinholdsson
reinholdsson / code.R
Last active December 18, 2015 08:39
Issue: create_chart() doesn't work with data.table
#require(XLConnect)
require(data.table)
require(rCharts)
require(reshape2)
require(plyr)
# wb1 <- loadWorkbook("nuvarande_ledamoter_RLK.xls")
# wb2 <- loadWorkbook("personroster_per_valkrets_R.xls")
# ws1 <- as.data.table(readWorksheet(wb1, sheet = 1))
# ws2 <- as.data.table(readWorksheet(wb2, sheet = 1))
@reinholdsson
reinholdsson / index.html
Created June 11, 2013 11:55
Highcharts Test
<!doctype HTML>
<html>
<head>
<link rel='stylesheet' href="http://netdna.bootstrapcdn.com/bootswatch/2.3.1/cosmo/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" >
<link rel='stylesheet' href="http://twitter.github.io/bootstrap/assets/js/google-code-prettify/prettify.css">
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://code.jquery.com/jquery-1.9.1.min.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts.js' type='text/javascript'></script>
<script src='http://code.highcharts.com/highcharts-more.js' type='text/javascript'></script>
<style>
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://tenxer.github.io/xcharts/css/master.css'>
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script>
<script src='http://tenxer.github.io/xcharts/js/xcharts.min.js' type='text/javascript'></script>
<style>
@reinholdsson
reinholdsson / code.R
Created June 21, 2013 07:22
tooltip example
require(reshape2)
require(rCharts)
df_orig <- read.csv("~/Desktop/df_orig.csv")
b <- rCharts:::Highcharts$new()
invisible(sapply(c("W", "D", "L"), function(res){
df <- df_orig[df_orig$result == res,]
df.lst <- lapply(1:nrow(df), function(i) as.list(df[i,]))
b$series(data=df.lst, type = "column", name = res)
a <- rCharts:::Highcharts$new()
a$chart(type = "spline")
a$series(list(
list(data = c(1, 3, 2, 4, 5, 4, 6, 2, 3, 5, NA), dashStyle = "longdash"),
list(data = c(NA, 4, 1, 3, 4, 2, 9, 1, 2, 3, 4), dashStyle = "shortdot")
))
a$legend(symbolWidth = 80)
a
@reinholdsson
reinholdsson / code.R
Created June 22, 2013 20:28
rCharts: Highcharts - Stacked and grouped column
require(rCharts)
df <- data.frame(
name = c("John", "John", "Joe", "Joe", "Jane", "Jane", "Janet", "Janet"),
data = sample(1:10, 8, replace = T),
stack = c(rep("male", 4), rep("female", 4))
)
a <- rCharts:::Highcharts$new()
a <- rCharts:::Highcharts$new()
a$yAxis(title=list(text='Series 1', style = list(color = "blue")))
a$yAxis(title=list(text='Series 2', style = list(color = "red")), opposite = T, replace = F)
a$series(data = sample(1:100, 12), type = "column", yAxis = 0, color = "blue")
a$series(data = sample(1:100, 12), type = "line", yAxis = 1, color = "red")
a$tooltip(shared=T)
a <- rCharts:::Highcharts$new()
a$yAxis(title=list(text='Series 1', style = list(color = "blue")))
a$yAxis(title=list(text='Series 2', style = list(color = "red")), opposite = T, replace = F)
a$series(data = sample(1:100, 12), type = "column", yAxis = 0, color = "blue")
a$series(data = sample(1:100, 12), type = "line", yAxis = 1, color = "red")
a$tooltip(shared=T)