-
Notifications
You must be signed in to change notification settings - Fork 130
Modular Design (v2) DRAFT
The following are ideas for created a more modular API to the Google Chart functionality. I believe these modularizations bring the element more in-line with web-component design paradigm. They will add a great deal of functionality while at the same time reducing code complexity.
See the next sections for more information on the new elements and properties as well as examples.
- Charts will be drawn via a
ChartWrapper
. This alleviates needing to load the libraries and map the constructors. It is also required for adding charts to a Dashboard. - Charts no longer load URLs.
If data is needed from the network, loading separately is now required (e.g. with an
iron-ajax
). This gives more flexibility and removes complexity from the<google-chart>
element. - Charts now only draw
DataTable
orDataView
objects (i.e. no longer parse data). Include a<google-chart-data>
element to parse data with more flexibility and efficiency. - The new
<google-chart-data>
element listens for slice events on its properties. This allows for using the normal Polymer array manipulations and have the changes reflected. (these manipulations to be debounced) - Charts can now be drawn in a
Dashboard
. Multiple charts can be put into one<google-chart-dashboard>
element to share data. This allows for sharing oneDataTable
and also enables controls. - In order to facilitate data sharing, a new
view
attribute is added to<google-chart>
and<google-chart-data>
to filter theDataTable
. - A
viewTransformer
property has also been added to<google-chart>
and<google-chart-data>
. This function allows the user to manipulate the usedDataView
as they see fit. - Charts can now be controlled!
Adding a
<google-chart-control>
to a<google-chart-dashboard>
will control charts in the same<google-chart-dashboard>
. - A new
<google-chart-query>
element is available. This element allows for working with servers that implement the Chart Tools DataSource Protocol.
- Properties
- type: The type of chart to draw
- options
- data: A DataTable or DataView to draw
- view: The result of one or more calls to DataView.toJSON
- viewTransformer: A function provided with one parameter, a DataView
- Children: google-chart-data
- Listens for: google-chart-data-changed
- Properties
- rows
- cols
- value: A DataTable in 2D-Array format.
- view
- viewTransformer
For working with servers that implement the Chart Tools DataSource Protocol.
- Properties: url, query, refresh
- Fires: google-chart-error, google-chart-warning
- Properties: data
- Children
- google-chart
- google-chart-control
- Listens for: google-chart-data-changed
- Required Parent: google-chart-dashboard
- Properties
- type
- filter-index, filter-label
- options
- state
- ui
Chart listens for the data
changed event from the DataTable to update.
<google-chart>
<google-chart-data rows="[[rows]]" cols="[[cols]]"></google-chart-data>
</google-chart>
<google-chart>
<google-chart-data value="[[data]]"></google-chart-data>
</google-chart>
<google-chart>
<iron-ajax auto url="[[url]]" handle-as="json" last-response="{{data}}"></iron-ajax>
<google-chart-data value="[[data]]"></google-chart-data>
</google-chart>
Chart listens for the data
changed event from the Query to update.
<google-chart>
<google-chart-query url="[[url]]" query="[[query]]"></google-chart-query>
</google-chart>
A DataView transforming function can be invoked to manipulate the data shown (e.g. add calculated columns or filters).
<google-chart>
<google-chart-data value="[[data]]" view-transformer="_createView"></google-chart-data>
</google-chart>
The DataTable is drawn via the Dashboard, which will distribute the data to each contained Chart.
<google-chart-dashboard>
<google-chart-data value="[[data]]"></google-chart-data>
<google-chart type="bar"></google-chart>
<google-chart type="column"></google-chart>
</google-chart>
The same will work with a properly configured Control, as well.
<google-chart-dashboard>
<google-chart-data value="[[data]]"></google-chart-data>
<google-chart></google-chart>
<google-chart-control filter="[[columnName]]"></google-chart-control>
</google-chart>