Skip to content

midas/g_flot

Repository files navigation

g_flot

github.com/midas/g_flot/tree/master

DESCRIPTION:

A Guilded (github.com/midas/guilded/tree/master) Rails component that facilitates creating jQuery Flot graphs.

FEATURES:

  • Low level wrapper view helper that accepts the same options as the jQuery Flot plugin

INSTALL:

sudo gem install midas-g_flot

In Rails environment.rb file:

config.gem 'midas-g_flot', :version => '1.0.0', :lib => 'g_flot', :source => 'http://gems.github.com'

Run the assets generator:

script/generate flot_assets_generator

USAGE:

Simple case (creates a bar graph with 2 bars):

<%= g_flot_graph :id => 'graph', :data => [ { :label => 'One Thing', :data => [[1,10] }, 
      { :label => 'Second Thing', :data => [[2,17] } ] %>

The view helper simply passes through all options to the initialization of the flot graph (the plot method). The view helper uses to_json method to convert the options hash to valid JavaScript syntax. So, for example, an options hash in Ruby:

options = { :id => 'graph', :data => [ { :label => 'One Thing', :data => [[1,10] }, { :label => 'Second Thing', :data => [[2,17] } ] }

In JavaScript would become an object literal:

var options = { id: 'graph', data: [ { label: 'One Thing', data: [[1,10]] }, { label: 'Second Thing', data: [[2,17]] } ] }

See code.google.com/p/flot/ for more infromation about flot and it’s options / functionality.

REQUIREMENTS:

LICENSE:

(The MIT License)

Copyright © 2009 C. Jason Harrelson (midas), excluding jQuery plugins copyrighted by others.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A Guilded component facilitating the creation of flot graphs.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages