This is an exmaple of resuable components using d3. They are described as 'closures (i.e. functions) with setters and getters'.
In this example, _table
is the closure.
To make the component responsive, we add a dispatcher
which broadcasts events happening inside the component to all listeners.
In this example, a div listens to highlight
and select
events from the table, and changes its text accordingly.
Notice that I didn't assume anything about the data other that its structure. Also, I didn't hardcode any data-specific attributes.
forked from ahmohamed's block: Create a reusable table using d3 and jquery DataTables
Modified http://d3js.org/d3.v3.min.js to a secure url
Modified http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js to a secure url
Updated missing url https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js to https://cdn.datatables.net/1.10.9/js/jquery.datatables.min.js
https://d3js.org/d3.v3.min.js
https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js
https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js