I am interested in plotting JVM GC events using thin vertical bars using nvd3 and rCharts. The example data is like this. The time taken is in seconds.
Event Date TimeTakenforEvent
FullGC 1/1/2014 10
GCType1 1/1/2014 30
GCType2 1/1/2014 60
GCType3 1/1/2014 20
GCType4 1/1/2014 70
The events will be dynamically added to a R data frame as and when they happen. The chart is cumulative but every event type will cause a bar of a certain color to be plotted. So, for example, Full GC events will plot blue bars. Date is plotted on x-axis and the time taken is plotted on the y-axis.
I know how to use R and add data to a data frame. So this is a question about the rChart plotting function.
I think the solution could be something like this
p2$chart(color = "#! function(d){ return d.y > 12 ? 'red':'blue'} !#")
p2$chart(color = "#! d3.selectAll('rect.nv-bar').style('fill', function(d, i){return d.y > 12 ? 'red':'blue;} !#")
Can someone guide me ?
Update: I have determined that this example code works.
p2 = nPlot(x = "Var1", y = "Freq", data = bpf3, type = "discreteBarChart")
p2$chart(color = "#! function(d){ return d.Freq > 12.0 ? 'red':'blue'} !#")
But the 'Event' is what determines color in my case.