WP Manifestindependent plugin directory
manifest / utilities / go-graphing

Gigaom Graphing

Open Source graphing library plugin

★ 2stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/gigaom/go-graphing/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

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
  )
)