SlideShare a Scribd company logo
D3.JS TIPS & TRICKS
(export to svg, crossfilter, maps etc.)
_by Oleksii Prohonnyi
D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)
INTRODUCTION
Introduction
D3.js is a JavaScript library for manipulating
documents based on data.
 D3 - Data-Driven Documents
 d3js.org
 github.com/mbostock/d3
 github.com/mbostock/d3/wiki/API-Reference
DATA VISUALIZATION
Overview
 Data visualization is the presentation of data in a
pictorial or graphical format.
 Reasons to use:
 helps people see things that were not obvious
to them before;
 patterns can be spotted quickly and easily;
 conveys information in a universal manner;
 answer questions like “What would happen if
we made an adjustment to that area?”.
D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)
Tools
 Charts wizards (Libre Office, MS Office, Numbers)
 Google Charts
 Modest Maps (mapping tool)
 Visual.ly
 Tableau
 RAW (from Density Design)
 D3.js
See more
 www.storytellingwithdata.com
 vizwiz.blogspot.com
 www.visualisingdata.com
 flowingdata.com
 helpmeviz.com
 plot.ly (collaboration online tool)
D3 CORE
Selections
 A selection is an array of elements pulled from the
current document. D3 uses CSS3 to select elements.
 After selecting elements, you apply operators to them
to do stuff. These operators can get or set attributes,
styles, properties, HTML and text content.
 d3.select(selector), d3.select(node)
 d3.selectAll(selector), d3.selectAll(nodes)
 See more: github.com/mbostock/d3/wiki/Selections
Demo: core/selections.html
SVG
Scalable Vector Graphics (SVG) is an XML-based
vector image format for two-dimensional graphics with
support for interactivity and animation.
 Shapes - generate geometric shapes and
primitives in SVG.
 Axes - generate standard axes for visualizations in
SVG.
 Controls - generate standard interactive
visualization controls in SVG.
Demo: core/svg.html
External resources
 d3.csv - request a comma-separated values (CSV) file.
 d3.html - request an HTML document fragment.
 d3.json - request a JSON blob.
 d3.text - request a text file.
 d3.tsv - request a tab-separated values (TSV) file.
 d3.xhr - request a resource using XMLHttpRequest.
 d3.xml - request an XML document fragment.
 See more: github.com/mbostock/d3/wiki/Requests
Demo: core/external-data.html
Scales
 Quantitative Scales - for continuous input
domains, such as numbers.
 Ordinal Scales - for discrete input domains,
such as names or categories.
 Time Scales - for time domains.
Layouts
 A layout encapsulates a strategy for laying out data elements
visually, relative to each other. Many layouts are built in to D3
itself:
 Chord - produce a chord diagram from a matrix of relationships.
 Partition - recursively partition a node tree into a sunburst or icicle.
 Pie - compute the start and end angles for arcs in a pie or donut
chart.
 Tree - position a tree of nodes tidily.
 etc.
 See more: github.com/mbostock/d3/wiki/Layouts
Demo: core/layouts.html
Transitions
 A special type of selection where the operators apply
smoothly over time rather than instantaneously.
 May have per-element delays and durations, computed
using functions of data similar to other operators.
 Multiple transitions may operate on any selection
sequentially or in parallel.
 See more: github.com/mbostock/d3/wiki/Transitions
Demo: core/transitions.html
Geography
 Paths - display geographic shapes.
 Projections - convert locations (latitude and
longitude) to pixel coordinates.
 Streams - streaming geometry transformations.
Even more
 Formatting
 Colors
 Localization
 Math
 Time
 etc.
Demo: core/other.html
Charts
Main purpose of data visualization:
 Comparison
 Composition
 Distribution
 Relationship
 See more:
www.storytellingwithdata.com/blog/2013/04/chart-chooser
 Try by yourself:
labs.juiceanalytics.com/chartchooser/index.html
Source: storytellingwithdata.com
D3 COOKBOOK
Coordinates axes
 Task:
 change chart 0,0 coordinate position to
svg left bottom corner.
 Solutions:
 y coordinate of chart bars should be
calculated depending on chart height;
 set range of the axis scale.
Demo: cookbook/coordinates.html
Multiple graphs
 Task:
 arrange more than one d3 graph on a web
page
 Solution:
 use a separate container and selector for
each of the graphs
Demo: cookbook/multi-graph.html
User actions
 Task:
 handle user’s mouse events on a graph
element and change view of groups
corresponding to them
 Solution:
 default JavaScript events should be
listened through on function
Demo: cookbook/mouse-events.html
Runtime dataset
 Task:
 change graph’s dataset in runtime on user
action
 Solution:
 request a new dataset after page load,
redraw existing svg element
Demo: cookbook/runtime-dataset.html
User-friendly graph’s API
 Task:
 create and configure the graph using user-
friendly API
 Solution:
 use dimple.js library for d3 core wrapping
and work with DOM through the API
 use c3.js library for d3 core wrapping and
work with DOM through the API
Demo: cookbook/friendly-api.html
Export to svg
 Task:
 export the graph to svg file
 Solution:
 browser build-in functionality (<img>, <canvas>)
 server-side conversion of svg data
 node.js/phantom.js for saving svg data into file
 canvas graph copy export (canvg.js)
 FileSaver.js API using
Demo: cookbook/export-to-svg.html
Export to svg – FileSaver.js API using
 Connect Blob.js and FileSaver.js scripts.
 Graph should be implemented using svg.
 Use FileSaver.js API:
Demo: cookbook/export-to-svg.html
Sankey diagram
 Task:
 visualize dataset using Sankey diagram
 Solution:
 compose d3 bar and line charts
 Sankey library
 Sankey plugin for d3
Demo: cookbook/sankey.html
Sankey diagram – About
 A specific type of flow diagram, in which the width
of the arrows is shown proportionally to the flow
quantity.
 Are typically used to visualize energy or material or
cost transfers between processes. They can also
visualize the energy accounts or material flow
accounts on a regional or national level.
 See more: www.sankey-diagrams.com
Sankey diagram – About
Source: wikimedia.org
Sankey diagram – Sankey plugin
 Connect sankey.js script.
 Dataset should contain “links” and “nodes” collections.
 Use Sankey plugin:
Demo: cookbook/sankey.html
Force layout diagram
 Task:
 visualize dataset using force layout
diagram
 Solution:
 instantiate d3.layout.force object and
extend it with configurations
Demo: cookbook/force-layout.html
Force layout diagram – About
 It’s purpose: to position the nodes of a graph in two-
dimensional or three-dimensional space so that all the
edges are of more or less equal length and there are as few
crossing edges as possible.
 It could be implemented by assigning forces among the set
of edges and the set of nodes, based on their relative
positions, and then using these forces either to simulate the
motion of the edges and nodes or to minimize their energy.
 See more: github.com/mbostock/d3/wiki/Force-Layout
Force layout diagram – About
Source: homes.cs.washington.edu
Force layout diagram – Pros & Cons
Pros:
 Good-quality results
 Flexibility
 Intuitive
 Simplicity
 Interactivity
 Strong theoretical
foundations
Cons:
 High running time
 Poor local minima
Force layout diagram – Implementation
 Dataset should contain “links” and “nodes” collections.
 Use d3.layout.force() function:
Demo: cookbook/force-layout.html
Map
 Task:
 visualize dataset using geographical
features of D3
 Solution:
 use d3.geo object for data display and it’s
manipulation
Demo: cookbook/map-simple.html
Map – Geo Paths
 For cartographic visualizations, D3 supports a handful of
components for displaying and manipulating geographic data.
 Datasets could be presented in the following formats:
 Shape file (binary format) – could be converted using
ogr2ogr utility
 GeoJSON - a standard way of representing geographic
features in JavaScript
 TopoJSON - an extension of GeoJSON that is significantly
more compact
 The primary mechanism for displaying geographic data is
d3.geo.path.
Map – Projections
Map – Projections
D3 includes several common projections by
default. All of them are presented below:
 d3.geo.albersUsa
 d3.geo.azimuthalEqualArea
 d3.geo.azimuthalEquidistant
 d3.geo.conicEqualArea
 d3.geo.conicConformal
 d3.geo.conicEquidistant
 d3.geo.equirectangular
 d3.geo.gnomonic
 d3.geo.Mercator
 d3.geo.orthographic
 d3.geo.stereographic
 d3.geo.transverseMercator
Map – Projections
 Numerous (less-commonly used) projections are
available in the extended geographic projections
plugin and the polyhedral projection plugin.
 Most projections provided by D3 are created via
d3.geo.projection and are configurable.
Map – Geo Streams
 For fast transformations of geometry without
temporary copies of geometry objects, D3 uses
geometry streams.
 The main d3.geo.stream method converts a
GeoJSON input object to a stream: a series of
method calls on a stream listener.
 See more: github.com/mbostock/d3/wiki/Geo-
Streams
Map – Implementation
 Finding Data
 Installing Tools
 Converting Data
 Loading Data
 Displaying Polygons
 Styling Polygons
 Displaying Boundaries
 Displaying Places
 Do magic
Demo: cookbook/map-advanced.html
The road to data nirvana:
 Step 1: Raw data
 Step 2: Visualize data
 Step 3: Interact with data
 Step 4: Data immersion
One more thing
Data immersion – Crossfilter
 Crossfilter is a JavaScript library for exploring large
datasets that include many variables in the browser.
 Crossfilter provides a map-reduce function to data
using “dimensions” and “groups”.
 MapReduce is a programming model for processing
large data sets with a parallel, distributed algorithm on
a cluster.
 See more: square.github.io/crossfilter
Demo: cookbook/crossfilter.html
Data immersion – Dc.js
 Dc.js is designed to be an enabler for both libraries
(Crossfilter.js and D3.js). Taking the power of
crossfilter's data manipulation capabilities and
integrating the graphical capabilities of d3.js.
 It is designed to provide access to a range of
different chart types in a relatively easy to use
fashion.
 See more: dc-js.github.io/dc.js
Demo: cookbook/dc-js.html
Data immersion – Dc.js
The different (generic) types of chart that dc.js
supports are:
 Bar Chart
 Pie Chart
 Row Chart
 Line Chart
 Bubble Chart
 Geo Choropleth Chart
 Data Table
Demo: cookbook/dc-js.html
More examples
 github.com/mbostock/d3/wiki/Tutorials
 github.com/mbostock/d3/wiki/Gallery
 bost.ocks.org/mike
 bl.ocks.org/mbostock
 christopheviau.com/d3list
 techslides.com/over-1000-d3-js-examples-and-
demos
REFERENCES
References
 “Getting Started with D3” (Mike Dewar, 2012)
 “D3.js in Action” (Elijah Meeks, 2014)
 “D3 Tips and Tricks” (Malcolm Maclean, 2013)
 “Data Visualization with d3.js Cookbook” (Ari
Lerner, Victor Powell, 2014)
 github.com/mbostock/d3/wiki/Tutorials
 dashingd3js.com
THANK YOU
FOR YOUR ATTENTION
Q&A
Oleksii Prohonnyi
 oprohonnyi@gmail.com
 fb.com/oprohonnyi
 linkedin.com/in/oprohonnyi/en
 Sources: goo.gl/gjgHwO

More Related Content

PDF
Machine Learning Platform Life-Cycle Management
PDF
Customer Data Platform 101
PDF
Knowledge Graphs as a Pillar to AI
PDF
Time to Talk about Data Mesh
PPTX
Data Privacy: What you need to know about privacy, from compliance to ethics
PDF
Introduction to Data Analytics and Visualization
PDF
Data Quality Best Practices
PPTX
Understanding the difference between Data, information and knowledge
Machine Learning Platform Life-Cycle Management
Customer Data Platform 101
Knowledge Graphs as a Pillar to AI
Time to Talk about Data Mesh
Data Privacy: What you need to know about privacy, from compliance to ethics
Introduction to Data Analytics and Visualization
Data Quality Best Practices
Understanding the difference between Data, information and knowledge

What's hot (20)

PDF
Data Quality as a prerequisite for you business success: when should I start ...
PDF
Generative AI con Amazon Bedrock.pdf
PPTX
AI, Knowledge Representation and Graph Databases -
 Key Trends in Data Science
PDF
Big data and machine learning for Businesses
PDF
Introduction to Knowledge Graphs and Semantic AI
PDF
Use Case Patterns for LLM Applications (1).pdf
PDF
Modeling Cybersecurity with Neo4j, Based on Real-Life Data Insights
PDF
Data Analytics PowerPoint Presentation Slides
PDF
Improve power bi performance
PDF
Data Ownership: Who Owns 'My Data'?
PDF
Basics of Research Data Management
PDF
Impulse ChatGPT and Generative AI Tools in Corporate Learning
PDF
Supply Chain Twin Demo - Companion Deck
PDF
PDF
Workshop - Build a Graph Solution
PDF
Self Service Analytics and a Modern Data Architecture with Data Virtualizatio...
PDF
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
PDF
Reading the IBM AI Strategy for Business
PDF
generative-ai-fundamentals and Large language models
PDF
The what, why, and how of master data management
Data Quality as a prerequisite for you business success: when should I start ...
Generative AI con Amazon Bedrock.pdf
AI, Knowledge Representation and Graph Databases -
 Key Trends in Data Science
Big data and machine learning for Businesses
Introduction to Knowledge Graphs and Semantic AI
Use Case Patterns for LLM Applications (1).pdf
Modeling Cybersecurity with Neo4j, Based on Real-Life Data Insights
Data Analytics PowerPoint Presentation Slides
Improve power bi performance
Data Ownership: Who Owns 'My Data'?
Basics of Research Data Management
Impulse ChatGPT and Generative AI Tools in Corporate Learning
Supply Chain Twin Demo - Companion Deck
Workshop - Build a Graph Solution
Self Service Analytics and a Modern Data Architecture with Data Virtualizatio...
LLMOps for Your Data: Best Practices to Ensure Safety, Quality, and Cost
Reading the IBM AI Strategy for Business
generative-ai-fundamentals and Large language models
The what, why, and how of master data management
Ad

Viewers also liked (20)

PDF
Graph (Network) Visualisation
PPTX
Cycle.js overview
PPTX
Asm.js introduction
PPTX
Moment.js overview
PPTX
Utility libraries to make your life easier
PDF
reveal.js 3.0.0
PPTX
Managing Remote Teams
PPTX
Exploradores.caroes
PPTX
Front-end rich JavaScript application creation (Backbone.js)
PPTX
Как создать сайт за 2 часа? (Wordpress)
PPTX
Dive into Angular, part 5: Experience
PPTX
Conference DotJS 2015 Paris review
PPT
Разработка веб-сайта. Сайт. Зачем он?
PPTX
Dive into Angular, part 3: Performance
PPTX
Chorme devtools
PPTX
OpenLayer's basics
PPTX
Dive into Angular, part 1: Introduction
PDF
Chrome DevTools Awesome 10 Features +1
PPTX
Bower introduction
PPTX
Google Chrome DevTools features overview
Graph (Network) Visualisation
Cycle.js overview
Asm.js introduction
Moment.js overview
Utility libraries to make your life easier
reveal.js 3.0.0
Managing Remote Teams
Exploradores.caroes
Front-end rich JavaScript application creation (Backbone.js)
Как создать сайт за 2 часа? (Wordpress)
Dive into Angular, part 5: Experience
Conference DotJS 2015 Paris review
Разработка веб-сайта. Сайт. Зачем он?
Dive into Angular, part 3: Performance
Chorme devtools
OpenLayer's basics
Dive into Angular, part 1: Introduction
Chrome DevTools Awesome 10 Features +1
Bower introduction
Google Chrome DevTools features overview
Ad

Similar to D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.) (20)

PPTX
Introduction to D3.js
PDF
D3 js in Action Data visualization with JavaScript Second Edition Elijah Meeks
PPTX
Academy PRO: D3, part 1
PDF
Learn D3.js in 90 minutes
PPT
Data Visualizations with D3
PDF
The D3 Toolbox
PDF
D3.js in Action: Data visualization with JavaScript 2nd Edition Elijah Meeks
PDF
Mongo db washington dc 2014
PDF
D3 Mapping Visualization
PDF
Data Visualization on the Web - Intro to D3
PDF
Utahjs D3
PDF
Introduction to D3
PDF
Visualization of Big Data in Web Apps
PDF
Introduction to data visualisation with D3
PPTX
Visdjango presentation django_boston_oct_2014
PDF
Charlotte Front End - D3
PDF
D3 data visualization
PDF
Data Visualizations with D3.js
PDF
Learning d3
PPTX
Dreamforce 2014 - Introduction to d3.js
Introduction to D3.js
D3 js in Action Data visualization with JavaScript Second Edition Elijah Meeks
Academy PRO: D3, part 1
Learn D3.js in 90 minutes
Data Visualizations with D3
The D3 Toolbox
D3.js in Action: Data visualization with JavaScript 2nd Edition Elijah Meeks
Mongo db washington dc 2014
D3 Mapping Visualization
Data Visualization on the Web - Intro to D3
Utahjs D3
Introduction to D3
Visualization of Big Data in Web Apps
Introduction to data visualisation with D3
Visdjango presentation django_boston_oct_2014
Charlotte Front End - D3
D3 data visualization
Data Visualizations with D3.js
Learning d3
Dreamforce 2014 - Introduction to d3.js

More from Oleksii Prohonnyi (12)

PPTX
Dive into Angular, part 4: Angular 2.0
PPTX
Dive into Angular, part 2: Architecture
PPTX
JavaScript Presentation Frameworks and Libraries
PPTX
Code review process with JetBrains UpSource
PPTX
BEM methodology overview
PPTX
Front-end development introduction (JavaScript). Part 2
PPTX
Front-end development introduction (HTML, CSS). Part 1
PPTX
Test-driven development & Behavior-driven development basics
PPTX
JavaScript Coding Guidelines
PPTX
Database Optimization (MySQL)
PPTX
PHPCS (PHP Code Sniffer)
PPTX
Usability of UI Design (motivation, heuristics, tools)
Dive into Angular, part 4: Angular 2.0
Dive into Angular, part 2: Architecture
JavaScript Presentation Frameworks and Libraries
Code review process with JetBrains UpSource
BEM methodology overview
Front-end development introduction (JavaScript). Part 2
Front-end development introduction (HTML, CSS). Part 1
Test-driven development & Behavior-driven development basics
JavaScript Coding Guidelines
Database Optimization (MySQL)
PHPCS (PHP Code Sniffer)
Usability of UI Design (motivation, heuristics, tools)

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Digital Strategies for Manufacturing Companies
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administration Chapter 2
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Migrate SBCGlobal Email to Yahoo Easily
wealthsignaloriginal-com-DS-text-... (1).pdf
Design an Analysis of Algorithms II-SECS-1021-03
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
VVF-Customer-Presentation2025-Ver1.9.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Digital Strategies for Manufacturing Companies
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administration Chapter 2

D3.JS Tips & Tricks (export to svg, crossfilter, maps etc.)

  • 1. D3.JS TIPS & TRICKS (export to svg, crossfilter, maps etc.) _by Oleksii Prohonnyi
  • 4. Introduction D3.js is a JavaScript library for manipulating documents based on data.  D3 - Data-Driven Documents  d3js.org  github.com/mbostock/d3  github.com/mbostock/d3/wiki/API-Reference
  • 6. Overview  Data visualization is the presentation of data in a pictorial or graphical format.  Reasons to use:  helps people see things that were not obvious to them before;  patterns can be spotted quickly and easily;  conveys information in a universal manner;  answer questions like “What would happen if we made an adjustment to that area?”.
  • 8. Tools  Charts wizards (Libre Office, MS Office, Numbers)  Google Charts  Modest Maps (mapping tool)  Visual.ly  Tableau  RAW (from Density Design)  D3.js
  • 9. See more  www.storytellingwithdata.com  vizwiz.blogspot.com  www.visualisingdata.com  flowingdata.com  helpmeviz.com  plot.ly (collaboration online tool)
  • 11. Selections  A selection is an array of elements pulled from the current document. D3 uses CSS3 to select elements.  After selecting elements, you apply operators to them to do stuff. These operators can get or set attributes, styles, properties, HTML and text content.  d3.select(selector), d3.select(node)  d3.selectAll(selector), d3.selectAll(nodes)  See more: github.com/mbostock/d3/wiki/Selections Demo: core/selections.html
  • 12. SVG Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.  Shapes - generate geometric shapes and primitives in SVG.  Axes - generate standard axes for visualizations in SVG.  Controls - generate standard interactive visualization controls in SVG. Demo: core/svg.html
  • 13. External resources  d3.csv - request a comma-separated values (CSV) file.  d3.html - request an HTML document fragment.  d3.json - request a JSON blob.  d3.text - request a text file.  d3.tsv - request a tab-separated values (TSV) file.  d3.xhr - request a resource using XMLHttpRequest.  d3.xml - request an XML document fragment.  See more: github.com/mbostock/d3/wiki/Requests Demo: core/external-data.html
  • 14. Scales  Quantitative Scales - for continuous input domains, such as numbers.  Ordinal Scales - for discrete input domains, such as names or categories.  Time Scales - for time domains.
  • 15. Layouts  A layout encapsulates a strategy for laying out data elements visually, relative to each other. Many layouts are built in to D3 itself:  Chord - produce a chord diagram from a matrix of relationships.  Partition - recursively partition a node tree into a sunburst or icicle.  Pie - compute the start and end angles for arcs in a pie or donut chart.  Tree - position a tree of nodes tidily.  etc.  See more: github.com/mbostock/d3/wiki/Layouts Demo: core/layouts.html
  • 16. Transitions  A special type of selection where the operators apply smoothly over time rather than instantaneously.  May have per-element delays and durations, computed using functions of data similar to other operators.  Multiple transitions may operate on any selection sequentially or in parallel.  See more: github.com/mbostock/d3/wiki/Transitions Demo: core/transitions.html
  • 17. Geography  Paths - display geographic shapes.  Projections - convert locations (latitude and longitude) to pixel coordinates.  Streams - streaming geometry transformations.
  • 18. Even more  Formatting  Colors  Localization  Math  Time  etc. Demo: core/other.html
  • 19. Charts Main purpose of data visualization:  Comparison  Composition  Distribution  Relationship  See more: www.storytellingwithdata.com/blog/2013/04/chart-chooser  Try by yourself: labs.juiceanalytics.com/chartchooser/index.html
  • 22. Coordinates axes  Task:  change chart 0,0 coordinate position to svg left bottom corner.  Solutions:  y coordinate of chart bars should be calculated depending on chart height;  set range of the axis scale. Demo: cookbook/coordinates.html
  • 23. Multiple graphs  Task:  arrange more than one d3 graph on a web page  Solution:  use a separate container and selector for each of the graphs Demo: cookbook/multi-graph.html
  • 24. User actions  Task:  handle user’s mouse events on a graph element and change view of groups corresponding to them  Solution:  default JavaScript events should be listened through on function Demo: cookbook/mouse-events.html
  • 25. Runtime dataset  Task:  change graph’s dataset in runtime on user action  Solution:  request a new dataset after page load, redraw existing svg element Demo: cookbook/runtime-dataset.html
  • 26. User-friendly graph’s API  Task:  create and configure the graph using user- friendly API  Solution:  use dimple.js library for d3 core wrapping and work with DOM through the API  use c3.js library for d3 core wrapping and work with DOM through the API Demo: cookbook/friendly-api.html
  • 27. Export to svg  Task:  export the graph to svg file  Solution:  browser build-in functionality (<img>, <canvas>)  server-side conversion of svg data  node.js/phantom.js for saving svg data into file  canvas graph copy export (canvg.js)  FileSaver.js API using Demo: cookbook/export-to-svg.html
  • 28. Export to svg – FileSaver.js API using  Connect Blob.js and FileSaver.js scripts.  Graph should be implemented using svg.  Use FileSaver.js API: Demo: cookbook/export-to-svg.html
  • 29. Sankey diagram  Task:  visualize dataset using Sankey diagram  Solution:  compose d3 bar and line charts  Sankey library  Sankey plugin for d3 Demo: cookbook/sankey.html
  • 30. Sankey diagram – About  A specific type of flow diagram, in which the width of the arrows is shown proportionally to the flow quantity.  Are typically used to visualize energy or material or cost transfers between processes. They can also visualize the energy accounts or material flow accounts on a regional or national level.  See more: www.sankey-diagrams.com
  • 31. Sankey diagram – About Source: wikimedia.org
  • 32. Sankey diagram – Sankey plugin  Connect sankey.js script.  Dataset should contain “links” and “nodes” collections.  Use Sankey plugin: Demo: cookbook/sankey.html
  • 33. Force layout diagram  Task:  visualize dataset using force layout diagram  Solution:  instantiate d3.layout.force object and extend it with configurations Demo: cookbook/force-layout.html
  • 34. Force layout diagram – About  It’s purpose: to position the nodes of a graph in two- dimensional or three-dimensional space so that all the edges are of more or less equal length and there are as few crossing edges as possible.  It could be implemented by assigning forces among the set of edges and the set of nodes, based on their relative positions, and then using these forces either to simulate the motion of the edges and nodes or to minimize their energy.  See more: github.com/mbostock/d3/wiki/Force-Layout
  • 35. Force layout diagram – About Source: homes.cs.washington.edu
  • 36. Force layout diagram – Pros & Cons Pros:  Good-quality results  Flexibility  Intuitive  Simplicity  Interactivity  Strong theoretical foundations Cons:  High running time  Poor local minima
  • 37. Force layout diagram – Implementation  Dataset should contain “links” and “nodes” collections.  Use d3.layout.force() function: Demo: cookbook/force-layout.html
  • 38. Map  Task:  visualize dataset using geographical features of D3  Solution:  use d3.geo object for data display and it’s manipulation Demo: cookbook/map-simple.html
  • 39. Map – Geo Paths  For cartographic visualizations, D3 supports a handful of components for displaying and manipulating geographic data.  Datasets could be presented in the following formats:  Shape file (binary format) – could be converted using ogr2ogr utility  GeoJSON - a standard way of representing geographic features in JavaScript  TopoJSON - an extension of GeoJSON that is significantly more compact  The primary mechanism for displaying geographic data is d3.geo.path.
  • 41. Map – Projections D3 includes several common projections by default. All of them are presented below:  d3.geo.albersUsa  d3.geo.azimuthalEqualArea  d3.geo.azimuthalEquidistant  d3.geo.conicEqualArea  d3.geo.conicConformal  d3.geo.conicEquidistant  d3.geo.equirectangular  d3.geo.gnomonic  d3.geo.Mercator  d3.geo.orthographic  d3.geo.stereographic  d3.geo.transverseMercator
  • 42. Map – Projections  Numerous (less-commonly used) projections are available in the extended geographic projections plugin and the polyhedral projection plugin.  Most projections provided by D3 are created via d3.geo.projection and are configurable.
  • 43. Map – Geo Streams  For fast transformations of geometry without temporary copies of geometry objects, D3 uses geometry streams.  The main d3.geo.stream method converts a GeoJSON input object to a stream: a series of method calls on a stream listener.  See more: github.com/mbostock/d3/wiki/Geo- Streams
  • 44. Map – Implementation  Finding Data  Installing Tools  Converting Data  Loading Data  Displaying Polygons  Styling Polygons  Displaying Boundaries  Displaying Places  Do magic Demo: cookbook/map-advanced.html
  • 45. The road to data nirvana:  Step 1: Raw data  Step 2: Visualize data  Step 3: Interact with data  Step 4: Data immersion One more thing
  • 46. Data immersion – Crossfilter  Crossfilter is a JavaScript library for exploring large datasets that include many variables in the browser.  Crossfilter provides a map-reduce function to data using “dimensions” and “groups”.  MapReduce is a programming model for processing large data sets with a parallel, distributed algorithm on a cluster.  See more: square.github.io/crossfilter Demo: cookbook/crossfilter.html
  • 47. Data immersion – Dc.js  Dc.js is designed to be an enabler for both libraries (Crossfilter.js and D3.js). Taking the power of crossfilter's data manipulation capabilities and integrating the graphical capabilities of d3.js.  It is designed to provide access to a range of different chart types in a relatively easy to use fashion.  See more: dc-js.github.io/dc.js Demo: cookbook/dc-js.html
  • 48. Data immersion – Dc.js The different (generic) types of chart that dc.js supports are:  Bar Chart  Pie Chart  Row Chart  Line Chart  Bubble Chart  Geo Choropleth Chart  Data Table Demo: cookbook/dc-js.html
  • 49. More examples  github.com/mbostock/d3/wiki/Tutorials  github.com/mbostock/d3/wiki/Gallery  bost.ocks.org/mike  bl.ocks.org/mbostock  christopheviau.com/d3list  techslides.com/over-1000-d3-js-examples-and- demos
  • 51. References  “Getting Started with D3” (Mike Dewar, 2012)  “D3.js in Action” (Elijah Meeks, 2014)  “D3 Tips and Tricks” (Malcolm Maclean, 2013)  “Data Visualization with d3.js Cookbook” (Ari Lerner, Victor Powell, 2014)  github.com/mbostock/d3/wiki/Tutorials  dashingd3js.com
  • 52. THANK YOU FOR YOUR ATTENTION
  • 53. Q&A Oleksii Prohonnyi  oprohonnyi@gmail.com  fb.com/oprohonnyi  linkedin.com/in/oprohonnyi/en  Sources: goo.gl/gjgHwO