require(rCharts)
df <- read.csv("runChase.csv", stringsAsFactors=F)
df$tt <-sprintf("
| %1$s %2$s |
|---|
%3$s %4$s
%5$s %6$s Target %7$s |
",
df$Team,
df$Opposition,
df$Ground,
df$startDate,
df$Score,
df$Result,
df$Chasing
)
df <- arrange(df,desc(Runs+Margin))
b <- rCharts:::Highcharts$new()
b$series(data=df$Margin, type = "column", name="Runs Short")
b$series(data=df$Runs, type = "column", name="Score")
b$yAxis(plotLines=list(list(value=311)))
b$yAxis(title=list(text='Runs Required'))
b$xAxis(categories = df$Year,labels=list(rotation=45,style=list(fontSize=9, fontFamily='Arial')))
b$plotOptions(series = list(stacking = 'normal',marker=list(enabled = F)))
b$colors('red','green')
b$tooltip(useHTML = T, formatter = "#! function() { return this.point.tt; } !#") # this and other options do not work ? poss if split into losses draws and wins?
b$chart(zoomType="x")
b
b$set(dom = 'chart')