The D3.js module provides better integration for Drupal and the D3.js - Data-Driven Documents visualization library.
There are three major ways to integrate Drupal and D3:
- basic views integration
- views integration with custom D3 library
- custom D3 library with direct calls to database or other way of adding data (headless Drupal :) )
There is no direct upgrade from the version of the module before April 2015 release.
Installation
- Install module via web interface, drush or upload and enable d3 modules
- Upload d3 library into folder sites/all/libraries/d3. Source libraries are in https://github.com/mbostock/d3, you can use d3 or d3.min or get version 3 http://d3js.org/d3.v3.js. Although READEME says to use latest version of D3, many have found that using version works best, especially for the examples module.
- After these steps you should be able to see examples at url d3/examples
Configuring views to work with existing libraries
If you want to use d3 to display your data, you first need to configure data in the way that is consistent with provided types of charts.
Configuring column chart
View this Google Presentation for step by step configuration.
Other video documentation
- old videos do not apply anymore
Upgrading from 7.x-1.x-dev to 7.x-1.0-alpha1 version
Version 7.x-1.0-alpha1 has changes in d3 views interface configuration and in .info file for a custom library
Changes to .info file
- line "views = 3.0" has to be added to
- mapping for fields is not required anymore in .info file and is now done through interface
- you can use numeric array or associative array by adding line
views[fields][rows][__data_type] = 2dnav ;
for associative
views[fields][rows][__data_type] = 2dnnv ;
for numeric
details are described in file sites/all/modules/d3/modules/d3_views/ d3_views.api.php
Attachment | Size |
---|---|
Interface for mapping fields | 106.57 KB |
Comments
some clarification needed
some clarification needed
If there is no mapping in .info file of custom library then view mapping form don't show up.
From d3_views.api.php
what is the difference between "field value1" of 1dn vs "field row value 1" of 1dnv in views rows perspective? when should we use those different _data_type?
there is no definition for functions map1DNV($row) , map1DA($row) . Do you Forgot to push code to repository?
From d3.linegraph.libraries.info (related to label)
what do you mean by each different line, could we make multi-line chart from the views tabular data? I tried creating one but when checks the code for map1DN in D3ViewsDataMapping.inc it is mapping label. Shouldn't it be field value instead?
Demonstration
Example of d3 Force directed graph using Drupal 7 with relation module, graph api and views:
https://jsfiddle.net/svorad/ecwryk58/