Skip to content

Instantly share code, notes, and snippets.

@mmterpstra
Last active February 18, 2023 22:10
Show Gist options
  • Save mmterpstra/fc432033204c3fe4ebc2696c1863730e to your computer and use it in GitHub Desktop.
Save mmterpstra/fc432033204c3fe4ebc2696c1863730e to your computer and use it in GitHub Desktop.
Use R to generate your Burndown Charts
#!/usr/bin/env R
#maye add commandline to script
#Yeah, it is a little low I know.
scrum.points=4
scrum.startdate="2016/10/24"
scrum.sprint="93"
scrum.days=19
scrum.pdf=paste('scrum',scrum.sprint,'.pdf')
#now with added weekends
d <- as.POSIXlt(as.Date(scrum.startdate) + seq(from=0,to=scrum.days-1))
d <- as.Date(subset(d,d$wday < 6 & d$wday > 0))
scrum.guide=scrum.points-seq(from=0,to=length(d)-1)/(length(d)-1)*scrum.points
pdf(file=scrum.pdf)
#more room for axis
par(mar=(c(7, 4, 4, 2) + 0.1))
#initial plot for setting the plot limits and labels
plot(d,scrum.guide,type="l",lty=2, lwd=3,xaxt="n", col = 'gray',ylab="Scrum Points",xlab="", main=paste('Burndown for sprint ',scrum.spri$
#grid over plot for easy manual drawing
abline(v = d, col = 'lightgray', lty = 3, lwd=2)
abline(h = seq(0, scrum.points,0.25), col = 'gray', lty = 3, lwd=c(3,1,1,1))
#redraw lines because of ugly overlapping elements.
#note that the settings below should be changed in the plot function also
lines(d,scrum.guide,type='l', lty=2, lwd=3, col = 'gray')
axis.Date(1, at = seq(d[1], d[length(d)],1), labels = seq(d[1], d[length(d)],1), format= "%d/%m", las = 2)
#make dev.off() go silent
scrum.null <- dev.off()
@mmterpstra
Copy link
Author

Latest example (output coverted with pdftocairo from poppler-utils):
scrum 93 -1

@samuelsaldanav
Copy link

samuelsaldanav commented Aug 31, 2022

Hi, this line is OK?

plot(d,scrum.guide,type="l",lty=2, lwd=3,xaxt="n", col = 'gray',ylab="Scrum Points",xlab="", main=paste('Burndown for sprint ',scrum.spri$

Or i need change to:

plot(d, scrum.guide,type="l", lty=2, lwd=3, xaxt="n", col='gray', ylab="Scrum Points", xlab="", main=paste('Burndown for sprint', scrum.sprint))

By other side, i need this file: scrum.pdf? this is so, do you have the link?

@mmterpstra
Copy link
Author

mmterpstra commented Sep 1, 2022

Use your suggestion

plot(d, scrum.guide,type="l", lty=2, lwd=3, xaxt="n", col='gray', ylab="Scrum Points", xlab="", main=paste('Burndown for sprint', scrum.sprint))

When the code is ok it should produce a pdf file called scrum 93 .pdf set on line 11 and used on line 18.
A better way is to edit line 11 to the example below

#this will result in an output file name scrum.93.pdf
scrum.pdf=paste(sep='.', 'scrum',scrum.sprint,'pdf')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment