Skip to content

GigaOM/go-graphing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-graphing

Open Source graphing library plugin

Libraries

This plugin allows for the enqueuing of d3, d3 parsets, and Rickshaw for use in WordPress plugins and themes.

Usage

Registering and enqueuing

Registering styles and scripts is done simply by calling the go_graphing() singleton. The resources that get registered are as follows:

  • d3 (script)
  • d3-parsets (script)
  • d3-layout (script)
  • rickshaw (script)
  • d3-parsets (styles)
  • rickshaw (styles)

If you wish to use those libraries, simply set dependencies on your JS files:

wp_register_script(
  'bacon',
	'js/bacon.js',
	array( 'rickshaw' ),
	1,
	TRUE
);

Note: Dependencies between the above libraries is set up as part of the go-graphing plugin: rickshaw has a dependency on d3-layout which has a dependency on d3.

Helpers

array_to_series( $array )

You can convert an array of key/value pairs to a series array (an array of x, y values)

$data = array(
	'New York' => 20,
	'Boston' => 5001,
	'Las Vegas' => 8008,
);

$data = go_graphing()->array_to_series( $data );

Results in:

array(
  array(
    x => 'New York',
    y => 20
  ),
  array(
    x => 'Boston',
    y => 5001
  ),
  array(
    x => 'Las Vegas',
    y => 8008
  )
)

About

Open Source graphing library plugin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •