Views Charts implements a new View style: charts. With it the use can
present view data as charts.
Dependencies
Views Charts depends on
Charts and Graphs and
Views.
The Views GroupBy
module provides important functionality that greatly enhances Views
Charts usage. Please consider installing it with Views Charts.
Usage
This usage instructions were shamelessly stolen from Views GroupBy
project page:
- Create a new View
- Add following fields:
- Taxonomy: Term Term
- Taxonomy: Vocabulary Name
- Node: Nid Nid (and rename its label to Nid Count)
- SQL Aggregation: Group By Fields Group By Fields (must be last field!)
- Click on the "SQL Aggregation: Group By Fields" and configure its settings as follows:
- Fields to Group On = 'Taxonomy: Term' and 'Taxonomy: Vocabulary Name' (both fields)
- SQL Aggregation Function = Count
- Fields to Aggregate with the SQL function = Node: Nid
- Field to Sort Resultset On (after SQL Function is applied) = Node: Nid
- Sorting Direction: Descending
- Add a filtering criteria for the node type if you need to.
- Add a page display to the view. Set the page path to
views_charts_example_view
Test this view. You should get aggregated data per taxonomy term.
Lastly you only have to set the charting options:
- In Basic settings change the Style to Charts
and click the Update button
- In the settings page choose:
- For Fields to be used in Chart Series choose Node: Nid (Nid
Count)
- For Fields to be used as X axis labels choose Taxonomy: Term
(Term)
That's it. Save the view. Views with Charts style can't be previewed. Open
<http://www.example.org/views_charts_example_view> to see the
chart.
Customizing charts
The presented charts can be customized through the
hook_views_charts_graph_alter() hook.
- hook_views_charts_graph_alter(&$canvas);
- The hook_views_charts_graph_alter() hook is called just
before actual chart draw. You can freely change $canvas to
customize any chart property. To understand how to customize
$canvas please see the
Charts and Graphs
module documentation.