Skip to content

akwiatkowski/technical_graph

Repository files navigation

technical_graph

Purpose of this gem is to create neat, meaningful, linear graphs for large amount of data.

When you want to:

  • create big graph using large amount of data,
  • do it offline and speed is not the most important factor,
  • minimize needed code,
  • use only linear graph,
  • RMagick / ImageMagick is ok for you,
  • tired of forgotten gems/libraries...

Then you should try this gem.

I created it because there were not available and maintained gems for that I needed. Now I use it to create hourly temperature and wind speed graphs for vast period of time (months, years), visualize measurements for HomeIO.

If you want to create candy, ultra fast, web graphs it is maybe not the best tool. If you want other graph types than linear it is definitely not the right tool for you. You can find my competitors here.

Future

  1. Curved graphs.
  2. Bug fixes, cleaning.

Quick start

Check currents test if documentation is not enough :)

  • Create 'the instance'

    tg = TechnicalGraph.new

    or

    tg = TechnicalGraph.new( options )

    where:

    • options - Hash of parameters, all parameters are described here.
  • Add layer

    tg.add_layer(layer_data)

    or

    tg.add_layer(layer_data, layer_params)

    where:

    • layer_data - Array of Hashes, like [{:x => 0, :y => 0}, {:x => 1, :y => 1}, ...]
    • layer_params - Hash of other parameters, all parameters are described here.
  • Save to file

    tg.save_to_file('image.svg')

    or

    tg.save_to_file('image.svgz')

    or

    tg.save_to_file('image.png')

    or get binary version of output using

    tg.to_format(format) # where format is 'svg', 'svgz', 'png', ...

This is the new, easiest, better and nicer approach because technical_graph render graph using appropriate drawer to file extension.

Some notes about formats and dependencies

technical_graph uses rasem for SVG and it works wery well. For PNG it uses chunky_png with oily_png if possible, but there is a lot of missing features. If you need PNG I recommend to install good, old rmagick.

An old way

Up to version 0.5.1 you had to render image before you could save it to file. It should work in current version too.

  • Render graph

    tg.render

  • Save to file

    tg.image_drawer.save_to_file('image.png')

    or get image binary content.

    tg.image_drawer.to_format(format)

Documentation

Documentation was moved here

Contributing to technical-graph

Flattr this git repo

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2011-2012 Aleksander Kwiatkowski. See LICENSE.txt for further details.

About

Simple technical graphs for Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages