require 'charty'
charty = Charty::Plotter.new(:google_chart)
nil
curve = charty.curve do
function {|x| Math.sin(x) }
range x: 0..10, y: -1..1
xlabel 'foo'
ylabel 'bar'
end
IRuby.display(IRuby.html(curve.render))
nil
curve2 = charty.curve do
series [0,1,2,3,4], [10,40,20,90,70]
series [0,1,2,3,4], [90,80,70,60,50]
series [0,1,2,3,4,5,6,7,8], [50,60,20,30,10, 90, 0, 100, 50]
range x: 0..10, y: 1..100
xlabel 'foo'
ylabel 'bar'
end
IRuby.display(IRuby.html(curve2.render))
nil
bar = charty.bar do
series [0,1,2,3,4], [10,40,20,90,70]
series [0,1,2,3,4], [90,80,70,60,50]
series [0,1,2,3,4,5,6,7,8], [50,60,20,30,10, 90, 0, 100, 50]
range x: 0..10, y: 1..100
xlabel 'foo'
ylabel 'bar'
title 'bar plot'
end
IRuby.display(IRuby.html(bar.render))
nil
barh = charty.barh do
series [123412341234,1234523452345,234563456345634,3456745674567,"4"], [10,40,20,90,70]
series ["a","b","c","d","e"], [90,80,70,60,50]
series ["0","1","2","3","4","5","6","7","8"], [50,60,20,30,10, 90, 0, 100, 50]
range x: 0..10, y: 1..100
xlabel 'foo'
ylabel 'bar'
title 'bar plot'
end
IRuby.display(IRuby.html(barh.render))
nil
scatter = charty.scatter do
series 0..10, (0..1).step(0.1), label: 'sample1'
series 0..5, (0..1).step(0.2), label: 'sample2'
series [0, 1, 2, 3, 4], [0, -0.1, -0.5, -0.5, 0.1]
ylabel 'y label'
title 'scatter sample'
end
IRuby.display(IRuby.html(scatter.render))
nil
bubble = charty.bubble do
series 0..10, (0..1).step(0.1), [10, 100, 1000, 20, 200, 2000, 5, 50, 500, 4, 40], label: 'sample1'
series 0..5, (0..1).step(0.2), [1, 10, 100, 1000, 500, 100], label: 'sample2'
series [0, 1, 2, 3, 4], [0, -0.1, -0.5, -0.5, 0.1], [40, 30, 200, 10, 5]
range x: 0..10, y: -1..1
xlabel 'x label'
ylabel 'y label'
title 'bubble sample'
end
IRuby.display(IRuby.html(bubble.render))
nil