okfn/openspendingjs — Issue #9: Provide common interface for all view widgets
Author: nickstenning
Created: 2012-02-28 15:13:45+00:00
State: open

At the moment, instantiation and state serialisation for view widgets (explorer, treemap, bubbles) is inconsistent, which means hard-coding custom to each visualisation in OpenSpending (see okfn/openspending.plugin.treemap for an example).

We should have a front-end interface class defining how we expect view widgets to behave.

Current proposal:

```coffee
class OpenSpending.IWidget
# Parameters:
# element: a DOM node in which to instantiate the widget
# context: a JSON object defining the OpenSpending context (see details below) [optional]
# state: a JSON serialisation of the state of the widget
constructor: (element, context={}, state={}) ->
throw "Not Implemented"

# Serialize the current widget state to a JSON object
serialize: () ->
throw "Not Implemented"
```