SlideShare a Scribd company logo
1 of 21
Download to read offline
INTERACTIVITY
                               It’s alive!!!




Tuesday, January 29, 13
Why?
                  Our data is large and multi-faceted---multiple parameters, data
                  types, sources of information, etc.

                  At times it is difficult to explore it fully and build an integrated
                  understanding of the system

                  Even with statistical or numerical analyses it is difficult to
                  translate results to actual physical phenomena or situations in the
                  data

                  It is important to be able to check our assumptions with active
                  exploration of the system

Tuesday, January 29, 13
Compare:
                                Module 23




                                                  41
                                                                 18
                                             41
                                                       18                  18



                                            41                        18
                                   42




                                                            41




                           18

                                  41




Tuesday, January 29, 13
Compare:




Tuesday, January 29, 13
How?
                  HTML, CSS, Javascript

                  HTML - HyperText Markup Language
                  A webpage, if you will. This is just to hold the meat really.
                  Don’t worry, this isn’t 1999 on MySpace.

                  CSS - Cascading Style Sheets
                  This is for styling our page elements in a sane and modular
                  fashion

                  Javascript - ...just Javascript
                  This is a programming language, no relation to Java (Thank God)

Tuesday, January 29, 13
But...How does it work?
                  HTML is, for our purposes, more like just a dumb container.
                  CSS is just to do styling on elements and isn’t needed to start.

                  REAL TALK: Javascript on its own...isn’t great.

                  BUT: There are tons of libraries for javascript that make it great
                  to work with. The rate of libraries is also growing at an
                  astonishing rate (for actual programming use check out node.js)

                  Specifically we will make heavy use of:
                  jQuery (adds lots of methods, functional programming elements)
                  d3.js (this is how we graph)

Tuesday, January 29, 13
What can d3 do?

                  http://mbostock.github.com/d3/ex/force.html
                  http://square.github.com/crossfilter/
                  http://bl.ocks.org/1136236

                  Pros: Easy to use, Web standard (with WebKit), SVG,
                  Interactive

                  Cons: Examples are the primary reference material. There is an
                  excellent primer by Scott Murray (http://alignedleft.com), but
                  you have to get your hands dirty


Tuesday, January 29, 13
Case Study


                  Let’s graph a freaking time series!

                  What do we even input as data to this?
                  JSONs (JavaScript Object Notation), Don’t worry it’s awesome.
                  CSVs (Comma Separated Values)




Tuesday, January 29, 13
Our Data
                  It’s basically just a saved dictionary into a file.
                  Python has a ‘JSON’ module that can import/export dictionaries
                  as a json string for saving




Tuesday, January 29, 13
How do I do that?




Tuesday, January 29, 13
But how do I get it going?
     Just tell it that
       it’s HTML


    These are library
        imports




                                      Importing supported
                                             styling

Tuesday, January 29, 13
Now....What?

              Make a div




            Call our script

Tuesday, January 29, 13
Getting our hands dirty
       Load our data, the graph creation is wrapped inside this (`$` is jQuery)




    We populate the
    arrays with our
      x and y data




    Define the height and width for our graphic to be used later (this is important)
Tuesday, January 29, 13
Making a place to place
                               We have to place
      Create our svg
                              our svg in a div (our
    to place our graph
                                 div had an id
    in (uses our width
                                   ‘party-viz’)
      and height from
          before)




Tuesday, January 29, 13
Let’s place some data

            We append a path,
           with our data, using
           a previously defined
               line function



           This is our function,
              it just iterates
            through the data,
           returning the x and
              y transformed
           positions for a point
Tuesday, January 29, 13
But now we need to know
                               what’s a point
               We add the data
               circles as a svg
               container type




            Now we actually
           append and give the
            attributes for the
                  circles

Tuesday, January 29, 13
But wait, now let’s make this
                              interactive
          We use tipsy/jQuery
             to generate an
           interactive tooltip




                Return an
               appropriately
            formatted string to
                  display

Tuesday, January 29, 13
Now for looking at it!
                  We can just open the .html file in a web browser or...

                  We need a server.
                  WAIT ISN’T THAT HARD??????

                  We can use a super quick, simple server with python.
                  In the directory with the page and code just do:




Tuesday, January 29, 13
Now, the moment of glory




Tuesday, January 29, 13
As help
                  I have a web template repo on bitbucket that you can use, with a
                  special branch for this example.




Tuesday, January 29, 13
As a note

                  This is all really new, cool stuff.

                  As such, it requires effort on your part to make it work and
                  understand it.

                  Not everything needs to be interactive/web. It takes work to do
                  this, so think first if it is worth your time.

                  I am more than willing to help you, but there is one master of
                  d3.js right now---the guy who wrote it.


Tuesday, January 29, 13

More Related Content

Viewers also liked

Pictograms & Cartograms
Pictograms & CartogramsPictograms & Cartograms
Pictograms & CartogramsRosna Davis
 
Pictogram PPT Presentation
Pictogram PPT PresentationPictogram PPT Presentation
Pictogram PPT PresentationAngelicaGuna
 
Ielts writing task 1 sample line graph
Ielts writing task 1 sample line graphIelts writing task 1 sample line graph
Ielts writing task 1 sample line graphimadhawamdeh
 
Pictograph presentation
Pictograph presentationPictograph presentation
Pictograph presentationlilbearlexi16
 
IELTS ACADEMIC TASK 1: How to describe a line graph
IELTS ACADEMIC TASK 1: How to describe a line graphIELTS ACADEMIC TASK 1: How to describe a line graph
IELTS ACADEMIC TASK 1: How to describe a line graphBen Worthington
 
4 Key Elements of Great Infographic Design
4 Key Elements of Great Infographic Design4 Key Elements of Great Infographic Design
4 Key Elements of Great Infographic DesignAndrea Fryrear
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkVolker Hirsch
 

Viewers also liked (9)

Pictograms
PictogramsPictograms
Pictograms
 
Pictograms & Cartograms
Pictograms & CartogramsPictograms & Cartograms
Pictograms & Cartograms
 
The Pictogram
The PictogramThe Pictogram
The Pictogram
 
Pictogram PPT Presentation
Pictogram PPT PresentationPictogram PPT Presentation
Pictogram PPT Presentation
 
Ielts writing task 1 sample line graph
Ielts writing task 1 sample line graphIelts writing task 1 sample line graph
Ielts writing task 1 sample line graph
 
Pictograph presentation
Pictograph presentationPictograph presentation
Pictograph presentation
 
IELTS ACADEMIC TASK 1: How to describe a line graph
IELTS ACADEMIC TASK 1: How to describe a line graphIELTS ACADEMIC TASK 1: How to describe a line graph
IELTS ACADEMIC TASK 1: How to describe a line graph
 
4 Key Elements of Great Infographic Design
4 Key Elements of Great Infographic Design4 Key Elements of Great Infographic Design
4 Key Elements of Great Infographic Design
 
TEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of WorkTEDx Manchester: AI & The Future of Work
TEDx Manchester: AI & The Future of Work
 

Similar to D3 interactivity Linegraph basic example

Web Programming Intro
Web Programming IntroWeb Programming Intro
Web Programming IntroYnon Perek
 
My last three projects - wins and failures
My last three projects - wins and failuresMy last three projects - wins and failures
My last three projects - wins and failuresAnton Katunin
 
Intro to-html-backbone-angular
Intro to-html-backbone-angularIntro to-html-backbone-angular
Intro to-html-backbone-angularzonathen
 
Better. Faster. UXier. — AToMIC Design
Better. Faster. UXier. — AToMIC DesignBetter. Faster. UXier. — AToMIC Design
Better. Faster. UXier. — AToMIC Designjennifer gergen
 
Building a Cutting-Edge Data Process Environment on a Budget by Gael Varoquaux
Building a Cutting-Edge Data Process Environment on a Budget by Gael VaroquauxBuilding a Cutting-Edge Data Process Environment on a Budget by Gael Varoquaux
Building a Cutting-Edge Data Process Environment on a Budget by Gael VaroquauxPyData
 
XPages Blast - Lotusphere 2013
XPages Blast - Lotusphere 2013XPages Blast - Lotusphere 2013
XPages Blast - Lotusphere 2013Tim Clark
 
Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Eugene Lazutkin
 
Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview. Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview. Doug Needham
 
Getting Started With MongoDB and Mongoose
Getting Started With MongoDB and MongooseGetting Started With MongoDB and Mongoose
Getting Started With MongoDB and MongooseYnon Perek
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the cloudsStuart Lodge
 
Python Machine Learning - Getting Started
Python Machine Learning - Getting StartedPython Machine Learning - Getting Started
Python Machine Learning - Getting StartedRafey Iqbal Rahman
 
Tutorial machine learning with python - a tutorial
Tutorial   machine learning with python - a tutorialTutorial   machine learning with python - a tutorial
Tutorial machine learning with python - a tutorialMarcusBBraga
 
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...Xamarin
 
DevOps Jungle of Tools, Ran Tavory
DevOps Jungle of Tools, Ran TavoryDevOps Jungle of Tools, Ran Tavory
DevOps Jungle of Tools, Ran TavoryDevOpsDays Tel Aviv
 
Data Structure Graph DMZ #DMZone
Data Structure Graph DMZ #DMZoneData Structure Graph DMZ #DMZone
Data Structure Graph DMZ #DMZoneDoug Needham
 

Similar to D3 interactivity Linegraph basic example (20)

Web Programming Intro
Web Programming IntroWeb Programming Intro
Web Programming Intro
 
My last three projects - wins and failures
My last three projects - wins and failuresMy last three projects - wins and failures
My last three projects - wins and failures
 
Intro to-html-backbone-angular
Intro to-html-backbone-angularIntro to-html-backbone-angular
Intro to-html-backbone-angular
 
Better. Faster. UXier. — AToMIC Design
Better. Faster. UXier. — AToMIC DesignBetter. Faster. UXier. — AToMIC Design
Better. Faster. UXier. — AToMIC Design
 
Building a Cutting-Edge Data Process Environment on a Budget by Gael Varoquaux
Building a Cutting-Edge Data Process Environment on a Budget by Gael VaroquauxBuilding a Cutting-Edge Data Process Environment on a Budget by Gael Varoquaux
Building a Cutting-Edge Data Process Environment on a Budget by Gael Varoquaux
 
XPages Blast - Lotusphere 2013
XPages Blast - Lotusphere 2013XPages Blast - Lotusphere 2013
XPages Blast - Lotusphere 2013
 
Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.Practical pairing of generative programming with functional programming.
Practical pairing of generative programming with functional programming.
 
Building data pipelines
Building data pipelinesBuilding data pipelines
Building data pipelines
 
Graph everything
Graph everythingGraph everything
Graph everything
 
Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview. Social Network Analysis Introduction including Data Structure Graph overview.
Social Network Analysis Introduction including Data Structure Graph overview.
 
Python and Sage
Python and SagePython and Sage
Python and Sage
 
Mongodb Intro
Mongodb IntroMongodb Intro
Mongodb Intro
 
Getting Started With MongoDB and Mongoose
Getting Started With MongoDB and MongooseGetting Started With MongoDB and Mongoose
Getting Started With MongoDB and Mongoose
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds10 things I’ve learnt In the clouds
10 things I’ve learnt In the clouds
 
Python Machine Learning - Getting Started
Python Machine Learning - Getting StartedPython Machine Learning - Getting Started
Python Machine Learning - Getting Started
 
Tutorial machine learning with python - a tutorial
Tutorial   machine learning with python - a tutorialTutorial   machine learning with python - a tutorial
Tutorial machine learning with python - a tutorial
 
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
GitHub halp app - Minimizing platform-specific code with MVVM - Justin Spahr-...
 
DevOps Jungle of Tools, Ran Tavory
DevOps Jungle of Tools, Ran TavoryDevOps Jungle of Tools, Ran Tavory
DevOps Jungle of Tools, Ran Tavory
 
Data Structure Graph DMZ #DMZone
Data Structure Graph DMZ #DMZoneData Structure Graph DMZ #DMZone
Data Structure Graph DMZ #DMZone
 

Recently uploaded

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

D3 interactivity Linegraph basic example

  • 1. INTERACTIVITY It’s alive!!! Tuesday, January 29, 13
  • 2. Why? Our data is large and multi-faceted---multiple parameters, data types, sources of information, etc. At times it is difficult to explore it fully and build an integrated understanding of the system Even with statistical or numerical analyses it is difficult to translate results to actual physical phenomena or situations in the data It is important to be able to check our assumptions with active exploration of the system Tuesday, January 29, 13
  • 3. Compare: Module 23 41 18 41 18 18 41 18 42 41 18 41 Tuesday, January 29, 13
  • 5. How? HTML, CSS, Javascript HTML - HyperText Markup Language A webpage, if you will. This is just to hold the meat really. Don’t worry, this isn’t 1999 on MySpace. CSS - Cascading Style Sheets This is for styling our page elements in a sane and modular fashion Javascript - ...just Javascript This is a programming language, no relation to Java (Thank God) Tuesday, January 29, 13
  • 6. But...How does it work? HTML is, for our purposes, more like just a dumb container. CSS is just to do styling on elements and isn’t needed to start. REAL TALK: Javascript on its own...isn’t great. BUT: There are tons of libraries for javascript that make it great to work with. The rate of libraries is also growing at an astonishing rate (for actual programming use check out node.js) Specifically we will make heavy use of: jQuery (adds lots of methods, functional programming elements) d3.js (this is how we graph) Tuesday, January 29, 13
  • 7. What can d3 do? http://mbostock.github.com/d3/ex/force.html http://square.github.com/crossfilter/ http://bl.ocks.org/1136236 Pros: Easy to use, Web standard (with WebKit), SVG, Interactive Cons: Examples are the primary reference material. There is an excellent primer by Scott Murray (http://alignedleft.com), but you have to get your hands dirty Tuesday, January 29, 13
  • 8. Case Study Let’s graph a freaking time series! What do we even input as data to this? JSONs (JavaScript Object Notation), Don’t worry it’s awesome. CSVs (Comma Separated Values) Tuesday, January 29, 13
  • 9. Our Data It’s basically just a saved dictionary into a file. Python has a ‘JSON’ module that can import/export dictionaries as a json string for saving Tuesday, January 29, 13
  • 10. How do I do that? Tuesday, January 29, 13
  • 11. But how do I get it going? Just tell it that it’s HTML These are library imports Importing supported styling Tuesday, January 29, 13
  • 12. Now....What? Make a div Call our script Tuesday, January 29, 13
  • 13. Getting our hands dirty Load our data, the graph creation is wrapped inside this (`$` is jQuery) We populate the arrays with our x and y data Define the height and width for our graphic to be used later (this is important) Tuesday, January 29, 13
  • 14. Making a place to place We have to place Create our svg our svg in a div (our to place our graph div had an id in (uses our width ‘party-viz’) and height from before) Tuesday, January 29, 13
  • 15. Let’s place some data We append a path, with our data, using a previously defined line function This is our function, it just iterates through the data, returning the x and y transformed positions for a point Tuesday, January 29, 13
  • 16. But now we need to know what’s a point We add the data circles as a svg container type Now we actually append and give the attributes for the circles Tuesday, January 29, 13
  • 17. But wait, now let’s make this interactive We use tipsy/jQuery to generate an interactive tooltip Return an appropriately formatted string to display Tuesday, January 29, 13
  • 18. Now for looking at it! We can just open the .html file in a web browser or... We need a server. WAIT ISN’T THAT HARD?????? We can use a super quick, simple server with python. In the directory with the page and code just do: Tuesday, January 29, 13
  • 19. Now, the moment of glory Tuesday, January 29, 13
  • 20. As help I have a web template repo on bitbucket that you can use, with a special branch for this example. Tuesday, January 29, 13
  • 21. As a note This is all really new, cool stuff. As such, it requires effort on your part to make it work and understand it. Not everything needs to be interactive/web. It takes work to do this, so think first if it is worth your time. I am more than willing to help you, but there is one master of d3.js right now---the guy who wrote it. Tuesday, January 29, 13