SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
d3 is cool
                     maps data to DOM




Sunday, 7 April 13
# jQuery-esque API
            d3
               .select("body")
               .append("p")
               .text("New paragraph!")
               .attr("class", "yep")
               .style("height", "10px")




Sunday, 7 April 13
data = []
            for num in [0..25]
              data.push Math.random() * 30

            d3.select("#bar") # get a wrapper element
              .selectAll("div") # get an array
              .data(data) # get a data-bound array
              .enter() # creates new nodes
              .append("div") # adds to DOM
              .style("height", (d)-> d * 5 + "px")




Sunday, 7 April 13
maps data to DOM




Sunday, 7 April 13
svg is cool
                     DOM for vector graphics & text




Sunday, 7 April 13
<svg height="200" width="700">
              <rect x="0" y="0" width="500" height="50">
              <circle cx="10" cy="100" r="50" fill="red">
              <text x="250" y="50">Easy-peasy</text>
              <path d="M 100 100 L 300 100 L 200 300 z" stroke-width="3">
              <image>
              <font> # fek yeah
            </svg>




Sunday, 7 April 13
svg = d3.select("body")
              .append("svg")
              .attr("width", w)
              .attr("height", h)
            circles = svg.selectAll()
              .data(dataset)
              .enter()
              .append("circle")
              .attr("cx", (d, i)-> i * 22)
              .attr("cy", 50)
              .attr("r", (d)-> d / 2)
              .attr("fill", (d)-> "rgb(" + Math.floor(d * 6) + ",0,150)")




Sunday, 7 April 13
data = [
              [5, 20],
              ...
              [220, 88]
            ]
            svg = getSVG()
            svg.selectAll()
               .data(data)
               .enter()
               .append("circle")
               .attr("cx", (d)-> d[0])
               .attr("cy", (d)-> d[1])
               .attr("r", 4)




Sunday, 7 April 13
# scales - d3's best feature
            # functions that map an input range to an output range
            xScale = d3.time.scale()
              .domain([xMin, xMax])
              .range([0, w]);

            yScale = d3.scale.linear()
              .domain([yMin, yMax])
              .range([h, 0]);
              # y output reversed because elements are positioned top/left




Sunday, 7 April 13
readings = [{
              read_at: '2013-03-27T00:04:00Z'
              wind_speed: 28,
              gust: 34,
              wind_direction: 287.3
            }...]

            xPoint = (reading)-> xScale(new Date(reading.read_at))
            yPointBySpeed = (reading)-> yScale(reading.wind_speed)
            yPointByGust = (reading)-> yScale(reading.gust)

            speedLine = d3.svg.line()
              .x(xPoint)
              .y(yPointBySpeed)

            # dark blue line
            svg.append("svg:path")
              .attr("d", speedLine(readings))
              .attr("stroke-width", 2)
              .attr("stroke", "#04C8FF")
              .attr("fill", "none")

Sunday, 7 April 13
speeds = []
            gusts = []
            for reading in data
              x = xPoint reading
              speeds.push [x, yPointBySpeed(reading)]
              gusts.push [x, yPointByGust(reading)]

            # light blue area
            # array of speed(x,y) followed by array of gust(x,y) reversed
            svg.selectAll("path.area")
              .data([speeds.concat(gusts.reverse())])
              .enter()
              .append("path")
              .attr("fill", "#04C8FF")
              .attr("fill-opacity", .2)
              .attr("d", d3.svg.area())




Sunday, 7 April 13
# arrow heads
            arrowTransform = (reading)->
              "translate(#{xPoint(reading)}, #{yPointBySpeed(reading)}),
               rotate(#{reading.wind_direction})"

            svg.selectAll("polygon")
              .data(data)
              .enter()
              .append("polygon")
              .attr("transform", arrowTransform)
              .attr("points", "0,-7.8 -5.1,7.8 0,5.4 5.1,7.8")
              .attr("stroke-width", 1)
              .attr("stroke", "#fff")
              .attr("fill", "#04C8FF")




Sunday, 7 April 13
yPointBySwellPeriod = (reading)->
              yScale(reading.swell_period)

            swellLine = d3.svg.line()
              .x(xPoint)
              .y(yPointBySwellPeriod)
              .interpolate("cardinal")
              # Many ways for svg paths to be drawn around the points

            svg.append("svg:path")
              .attr("d", swellLine(data))
              .attr("stroke-width", 2)
              .attr("stroke", "#28d7bd")
              .attr("fill", "none")




Sunday, 7 April 13
Lots of things I’m yet to play with..

                                      Transitions
                                Events - mouse, touches
                                          Ajax
                                         Colors
                                          Axes
                                   Other scale types
                                     Other shapes
                                    Time Intervals

                Cluster, Force, Hierarchy, Histogram, Pack, Partition, Pie,
                Stack, Tree, Treemap, Geography, Projections, Zoom etc..


Sunday, 7 April 13
d3 is cool
                                  Thanks!

                     http://alignedleft.com/tutorials/d3/

                              @markbrown4




Sunday, 7 April 13

Weitere ähnliche Inhalte

Was ist angesagt?

Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
Effector: we need to go deeper
Effector: we need to go deeperEffector: we need to go deeper
Effector: we need to go deeperVictor Didenko
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvasGary Yeh
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 CanvasHenry Osborne
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysGilbert Guerrero
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONFun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONTomomi Imura
 
λ | Lenses
λ | Lensesλ | Lenses
λ | LensesOpen-IT
 
Visualization of Big Data in Web Apps
Visualization of Big Data in Web AppsVisualization of Big Data in Web Apps
Visualization of Big Data in Web AppsEPAM
 
Micro and moblile: Java on the Raspberry Pi
Micro and moblile: Java on the Raspberry PiMicro and moblile: Java on the Raspberry Pi
Micro and moblile: Java on the Raspberry PiPance Cavkovski
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvasdeanhudson
 
Expand/Collapse animation on Android
Expand/Collapse animation on AndroidExpand/Collapse animation on Android
Expand/Collapse animation on AndroidPavlo Dudka
 
Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015Filippo Vitale
 

Was ist angesagt? (20)

Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
Effector: we need to go deeper
Effector: we need to go deeperEffector: we need to go deeper
Effector: we need to go deeper
 
Introduction to D3
Introduction to D3 Introduction to D3
Introduction to D3
 
Intro to HTML5 Canvas
Intro to HTML5 CanvasIntro to HTML5 Canvas
Intro to HTML5 Canvas
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Fuzzy Data Leaks
Fuzzy Data LeaksFuzzy Data Leaks
Fuzzy Data Leaks
 
Drawing with the HTML5 Canvas
Drawing with the HTML5 CanvasDrawing with the HTML5 Canvas
Drawing with the HTML5 Canvas
 
Ml all programs
Ml all programsMl all programs
Ml all programs
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + Arrays
 
Supstat nyc subway
Supstat nyc subwaySupstat nyc subway
Supstat nyc subway
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSONFun with D3.js: Data Visualization Eye Candy with Streaming JSON
Fun with D3.js: Data Visualization Eye Candy with Streaming JSON
 
Beyond Scala Lens
Beyond Scala LensBeyond Scala Lens
Beyond Scala Lens
 
λ | Lenses
λ | Lensesλ | Lenses
λ | Lenses
 
Visualization of Big Data in Web Apps
Visualization of Big Data in Web AppsVisualization of Big Data in Web Apps
Visualization of Big Data in Web Apps
 
Micro and moblile: Java on the Raspberry Pi
Micro and moblile: Java on the Raspberry PiMicro and moblile: Java on the Raspberry Pi
Micro and moblile: Java on the Raspberry Pi
 
Pointer Events in Canvas
Pointer Events in CanvasPointer Events in Canvas
Pointer Events in Canvas
 
Expand/Collapse animation on Android
Expand/Collapse animation on AndroidExpand/Collapse animation on Android
Expand/Collapse animation on Android
 
Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015Will it Blend? - ScalaSyd February 2015
Will it Blend? - ScalaSyd February 2015
 

Andere mochten auch

7 tips for great presentations
7 tips for great presentations7 tips for great presentations
7 tips for great presentationsEnglish Teaching
 
Bhagavat Gita Simplified[1]
Bhagavat Gita Simplified[1]Bhagavat Gita Simplified[1]
Bhagavat Gita Simplified[1]Sekar S
 
FM&amp;Property Summit Oct2011
FM&amp;Property Summit Oct2011FM&amp;Property Summit Oct2011
FM&amp;Property Summit Oct2011pcarder
 
Why Does God Exist
Why Does God ExistWhy Does God Exist
Why Does God ExistBlooper
 
Lychnari 2005 01 Zigeuners
Lychnari 2005 01 ZigeunersLychnari 2005 01 Zigeuners
Lychnari 2005 01 Zigeunerszefanjahoogers
 
Don\'t Sprint the Marathon
Don\'t Sprint the MarathonDon\'t Sprint the Marathon
Don\'t Sprint the MarathonSekar S
 

Andere mochten auch (9)

7 tips for great presentations
7 tips for great presentations7 tips for great presentations
7 tips for great presentations
 
Bhagavat Gita Simplified[1]
Bhagavat Gita Simplified[1]Bhagavat Gita Simplified[1]
Bhagavat Gita Simplified[1]
 
Project
ProjectProject
Project
 
FM&amp;Property Summit Oct2011
FM&amp;Property Summit Oct2011FM&amp;Property Summit Oct2011
FM&amp;Property Summit Oct2011
 
Why Does God Exist
Why Does God ExistWhy Does God Exist
Why Does God Exist
 
Lychnari 2005 01 Zigeuners
Lychnari 2005 01 ZigeunersLychnari 2005 01 Zigeuners
Lychnari 2005 01 Zigeuners
 
Don\'t Sprint the Marathon
Don\'t Sprint the MarathonDon\'t Sprint the Marathon
Don\'t Sprint the Marathon
 
Fixtures
FixturesFixtures
Fixtures
 
Child Development
Child DevelopmentChild Development
Child Development
 

Ähnlich wie d3 is cool

D3.js 30-minute intro
D3.js   30-minute introD3.js   30-minute intro
D3.js 30-minute introFelipe
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tddMarcos Iglesias
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular500Tech
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...Sencha
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7decoupled
 
Useful javascript
Useful javascriptUseful javascript
Useful javascriptLei Kang
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
Chapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdfChapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdfMekiyaShigute1
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and MapsIntro C# Book
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..Dr. Volkan OBAN
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 

Ähnlich wie d3 is cool (20)

Scrollytelling
ScrollytellingScrollytelling
Scrollytelling
 
SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
D3.js 30-minute intro
D3.js   30-minute introD3.js   30-minute intro
D3.js 30-minute intro
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Better d3 charts with tdd
Better d3 charts with tddBetter d3 charts with tdd
Better d3 charts with tdd
 
D3 svg & angular
D3 svg & angularD3 svg & angular
D3 svg & angular
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Joclad 2010 d
Joclad 2010 dJoclad 2010 d
Joclad 2010 d
 
Chapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdfChapter3_Visualizations2.pdf
Chapter3_Visualizations2.pdf
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
07. Java Array, Set and Maps
07.  Java Array, Set and Maps07.  Java Array, Set and Maps
07. Java Array, Set and Maps
 
imager package in R and examples..
imager package in R and examples..imager package in R and examples..
imager package in R and examples..
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
D3
D3D3
D3
 

Kürzlich hochgeladen

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
 
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
 
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
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Kürzlich hochgeladen (20)

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
 
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
 
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
 
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)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

d3 is cool

  • 1. d3 is cool maps data to DOM Sunday, 7 April 13
  • 2. # jQuery-esque API d3 .select("body") .append("p") .text("New paragraph!") .attr("class", "yep") .style("height", "10px") Sunday, 7 April 13
  • 3. data = [] for num in [0..25] data.push Math.random() * 30 d3.select("#bar") # get a wrapper element .selectAll("div") # get an array .data(data) # get a data-bound array .enter() # creates new nodes .append("div") # adds to DOM .style("height", (d)-> d * 5 + "px") Sunday, 7 April 13
  • 4. maps data to DOM Sunday, 7 April 13
  • 5. svg is cool DOM for vector graphics & text Sunday, 7 April 13
  • 6. <svg height="200" width="700"> <rect x="0" y="0" width="500" height="50"> <circle cx="10" cy="100" r="50" fill="red"> <text x="250" y="50">Easy-peasy</text> <path d="M 100 100 L 300 100 L 200 300 z" stroke-width="3"> <image> <font> # fek yeah </svg> Sunday, 7 April 13
  • 7. svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h) circles = svg.selectAll() .data(dataset) .enter() .append("circle") .attr("cx", (d, i)-> i * 22) .attr("cy", 50) .attr("r", (d)-> d / 2) .attr("fill", (d)-> "rgb(" + Math.floor(d * 6) + ",0,150)") Sunday, 7 April 13
  • 8. data = [ [5, 20], ... [220, 88] ] svg = getSVG() svg.selectAll() .data(data) .enter() .append("circle") .attr("cx", (d)-> d[0]) .attr("cy", (d)-> d[1]) .attr("r", 4) Sunday, 7 April 13
  • 9. # scales - d3's best feature # functions that map an input range to an output range xScale = d3.time.scale() .domain([xMin, xMax]) .range([0, w]); yScale = d3.scale.linear() .domain([yMin, yMax]) .range([h, 0]); # y output reversed because elements are positioned top/left Sunday, 7 April 13
  • 10. readings = [{ read_at: '2013-03-27T00:04:00Z' wind_speed: 28, gust: 34, wind_direction: 287.3 }...] xPoint = (reading)-> xScale(new Date(reading.read_at)) yPointBySpeed = (reading)-> yScale(reading.wind_speed) yPointByGust = (reading)-> yScale(reading.gust) speedLine = d3.svg.line() .x(xPoint) .y(yPointBySpeed) # dark blue line svg.append("svg:path") .attr("d", speedLine(readings)) .attr("stroke-width", 2) .attr("stroke", "#04C8FF") .attr("fill", "none") Sunday, 7 April 13
  • 11. speeds = [] gusts = [] for reading in data x = xPoint reading speeds.push [x, yPointBySpeed(reading)] gusts.push [x, yPointByGust(reading)] # light blue area # array of speed(x,y) followed by array of gust(x,y) reversed svg.selectAll("path.area") .data([speeds.concat(gusts.reverse())]) .enter() .append("path") .attr("fill", "#04C8FF") .attr("fill-opacity", .2) .attr("d", d3.svg.area()) Sunday, 7 April 13
  • 12. # arrow heads arrowTransform = (reading)-> "translate(#{xPoint(reading)}, #{yPointBySpeed(reading)}), rotate(#{reading.wind_direction})" svg.selectAll("polygon") .data(data) .enter() .append("polygon") .attr("transform", arrowTransform) .attr("points", "0,-7.8 -5.1,7.8 0,5.4 5.1,7.8") .attr("stroke-width", 1) .attr("stroke", "#fff") .attr("fill", "#04C8FF") Sunday, 7 April 13
  • 13. yPointBySwellPeriod = (reading)-> yScale(reading.swell_period) swellLine = d3.svg.line() .x(xPoint) .y(yPointBySwellPeriod) .interpolate("cardinal") # Many ways for svg paths to be drawn around the points svg.append("svg:path") .attr("d", swellLine(data)) .attr("stroke-width", 2) .attr("stroke", "#28d7bd") .attr("fill", "none") Sunday, 7 April 13
  • 14. Lots of things I’m yet to play with.. Transitions Events - mouse, touches Ajax Colors Axes Other scale types Other shapes Time Intervals Cluster, Force, Hierarchy, Histogram, Pack, Partition, Pie, Stack, Tree, Treemap, Geography, Projections, Zoom etc.. Sunday, 7 April 13
  • 15. d3 is cool Thanks! http://alignedleft.com/tutorials/d3/ @markbrown4 Sunday, 7 April 13