Skip to content

tbecker/spark_pr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

spark_pr is a Ruby class to generate sparkline and bullet graphs with PNG or ASCII output.

It only depends on zlib and generates PNGs with pure Ruby code.
The line-graph outputs antialised lines.

Sparkline Example for PNG output:

File.open( 'test.png', 'wb' ) do |png|
  png << Spark.plot( [47, 43, 24, 47, 16, 28, 38, 57, 50, 76, 42, 20, 98, 34, 53, 1, 55, 74, 63, 38, 31, 98, 89], :has_min => true, :has_max => true, 'has_last' => 'true', 'height' => '40', :step => 10, :normalize => 'logarithmic' )
end

Sparkline Example ASCII output:

puts Spark.smooth( [47, 43, 24, 47, 16, 28, 38, 57, 50, 76, 42, 1, 98, 34, 53, 97, 55, 74, 63, 38, 31, 98, 89], :has_min => true, :has_max => true, :height => 14, :step => 4 ).to_ascii

Bullet <example for PNG output:

File.open( 'testbullet.png', 'wb' ) do |png|
  png << Spark.plot( 85 , {    :type => :bullet, :target => 90, :bad => 60, :satisfactory => 80, :good => 100,:height => 15,
      :bad_color => [168, 255, 255, 0xAA],:satisfactory_color => [128, 128, 128, 0x90], :good_color => [192, 192, 192, 0x70],
                                    :bullet_color => [0x00, 0x00, 0x00, 0xAA]})
end


The SparkCanvas class can also be used for other drawing operations,
it provides drawing canvas with alpha blending and some primitive graphics
operations and PNG output in just about 100 lines of Ruby code.

About

Pure Ruby sparklines and bullet graphs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%