SlideShare ist ein Scribd-Unternehmen logo
1 von 69
Downloaden Sie, um offline zu lesen
D3JS
DREAMPUF JAN. 2013
AGENDA
Introduction
Examples
A guide of bar chart
The analysis of source code
   The Wealth & Health of Nations
   An time series visual design of Adserver svn commit
   record
Resources
INTRODUCTION
D3.JS: DATA-DRIVEN DOCUMENTS
JavaScript Library
Open source (BSD license)
developed by Michael Bostock and others at Stanford
University
former work on Protovis Library
                   from Intro to d3
D3.JS: DATA-DRIVEN DOCUMENTS
not a traditional visualization framework
focus on efficient manipulation of documents based on
data
bind arbitrary data to the DOM
apply data-driven transformations to the document
functional/declarative style
support for interaction and animation
you have to do the graphical representation yourself!
but has helpers for SVG generation
                     from Intro to d3
FEATURE
SELECTIONS
d3.selectAll("p")
  .style("color", "white");

  operate on arbitrary sets of nodes called selections
  W3C Selectors API or Sizzle fallback
DYNAMIC PROPERTIES
 d3.selectAll("p")
   .data([4, 8, 15, 16, 23, 42])
   .style("font-size", function(d, i) { return d + "px"; });

bind data to a selection
apply functions to styles, attributes and other
properties
a lot of built-in reusable functions available
bound data available as first argument
you can omit the data operator the second time!
ENTER AND EXIT
 var p = d3.select("body").selectAll("p")   // Update…
     .data([4, 8, 15, 16, 23, 42])
     .text(String);
 p.enter().append("p") // Enter…
     .text(String);
 p.exit().remove();    // Exit…

enter: selects all data elements without a DOM
representation
exit: selects all DOM elements without data
common pattern
perform only necessary modifications
SUBSELECTIONS
 d3.selectAll("ul")
     .data(questions) // an array of questions
   .selectAll("li")
     // a nested array of responses
     .data(function(d) { return d.responses; })
     // the text of the response
     .text(function(d) { return d.text; });

generate a subselection by calling selectAll on an
existing selection
maintains the hierarchical structure
TRANSITIONS
 // fade background from white to black in 1s
 d3.select("body").transition()
     .duration(1000)
     .style("background-color", "black");

with d3.js they are easy!
various tweening functions
interpolation of basic types, numbers and numbers in
strings (e.g. "15px")
EXAMPLES
FISHER–YATES SHUFFLE
2008 OLYMPIC MEDALS
OBAMA'S 2013 BUDGET
    PROPOSAL
economy (mpg)    cylinders   displacement (cc)   power (hp)    weight (lb)   0-60 mph (s)
                8.0
                                450
   45                                            220          5,000           24

                7.5
                                                 200
   40                           400
                                                                              22
                                                              4,500
                7.0
                                                 180
   35
                                350
                                                                              20
                6.5                              160
                                                              4,000
   30

                6.0             300              140
                                                                              18

   25                                                         3,500
                                                 120
                5.5
                                250                                           16

   20                                            100
                5.0                                           3,000

                                                  80                          14
                                200
   15
                4.5
                                                  60          2,500
                                                                              12
   10                           150
                4.0
                                                  40

                                                              2,000           10
    5           3.5
                                100               20



    0           3.0                                0                            8
Agglo merativeCluster




                                                                                                                                                                                                        lity
                                                                                                                                                                           Co mmunityStructure



                                                                                                                                                                         L inkD e nne ssCe ntra
                                            O pe rato pe rato rL ist




                                                                                                                                                                                                   te r
                                              Stac ando m L ayo u t




                                                                                                                                                                          HierarchicalClus
                                                O pe rato rSw e




                                                                                                                                                                                              ke r
                                                No d




                                                                                                                                                                       Span e stPaths t
                                                  Tre e M




                                                                                                                                                                        Sho rt lo wMinCu
                                                  Rad




                                                   So rtO pe ratoh
                                                   Ind Icicle cte d L ayyo ut t




                                                   ke dA




                                                                                                                                                                                           nce
                                                                                                                  Visualization
                                                    R




                                                                                                                                                                                         B an
                                                     Fo ndr ck le L o u ut




                                                                                                                                                                                            e
                                                     O




                                                                                                                                                                                       Tre e
                                                                                                                                                                        MaxF istance
                                                      e L in




                                                      rSe que nc




                                                                                                                                                                          Me rge Edg
                                                       e nt
                                                        rce o g ing ay te




                                                        ialTr Pie L ay o ut
                                                        De Pa c R o
                                                         Cir




                                                                                                                                                                                         r
                                                                                                                                                                                    que



                                                                                                                                                         Ob mbixInte to r lato r r
                                                           O pe ra




                                                                                                                                                                                    atio




                                                                                                                                                             Int te In te rp o lato
                                                           re aL ayo ut




                                                                                                                                                          Nu atr o la rpo ato
                                                           apL a
                                                            ed

                                                            kTre L ayyo ut




                                                                                                                                                                                ning
                                                             cle
                                                             Bu




                                                             Dir ra L a o u r




                                                                                                                                                                 e I la to r
                                                              ee




                                                                                                                                                         ct Inte te rpo to r
                                                                                                                                                               gl o o la lato
                                                                                                                                                                         Be twe




                                                                                                                                                                              nSe
                                                                                                                                                                            e ctR




                                                                                                                                                                                ol
                                                                nd




                                                                Tre e L ay o ut
                                                                e




                                                                                                                                                                                  r
                                                                                                                                                                    nt to r
                                                                 L




                                                                                                                                                                               to
                                                                 Tre L ay o ut




                                                                                                                                                              Dao lo rIn te rp
                                                                  ayo u
                                                                  e L a o ut
                                                                  Sta




                                                                  itc




                                                                                                                                                       Reo int ctInrInte o la
                                                                    yo utt
                                                                    le d A




                                                                                                                                                                            la
                                                                     e La ou




                                                                     to r




                                                                                                                                                                        ctio
                                                                                                                                                                    Funsing




                                                                                                                                                                      er r
                                                                      Cir ge ay
                                                                      ck R




                                                                       r




                                                                                                                                                                        po
                                                                                                                                                                        rp
                                                                                                                                                                      Asp




                                                                                                                                                                C rayIn
                                                                         y
                                                                         m




                                                                                                                                                            M e rp te
                                                                         Ed xisL




                                                                         ou




                                                                                                                                                            an rp rp
                                                                          e d ad




                                                                                                                                                                     Ea
                                                                            t
                                                                              Ar ial L a




                                                                                                                                                        P je e
                                                                                                                                                                 Ar
                                                                                e a L a be o r




                                                                                                                                                                le
                                                                                 t




                                                                                                                                          Se cheuse le l lab
                                                                                   L a be le
                                    G




                                                                                                                                                           n
                                                                                      be le r
                                      ra




                                                                                                                                                       l u
                                      Fis




                                                                                                                                                    izatio




                                                                                                                                               Pa ara e d
                                                                                       IO
                                         p




                                                                                         le r
                                                                                          hD




                                                                                                                                    cluste r
                                       he




                                                                                                                                              itio nc r
                                                                                          Vi tan

                                                                                           pe Filtete r




                                                                                                                                           ns ue ule
                                                                                                                                                 P ch
                                                                                            r




                                                                                                                                                      e
                                                                                                                                             graph
                                                                                             sib c
                                                                                                                                                                                                                             t




                                                                                              is
                                          ye
                                                                                                                                                                                                                    er en




                                                                                                 ra




                                                                                                                                                   IS


                                                                                                                                        Tra q d
                                                                                                                                                                                                                                                r




                                                                                                                                          o ptim
                                                                                                  ilit e F
                                             Tre




                                                                                                                                                  n
                                                                                                                                                                                                                 o n nEv                    rte




                                                                                                                                                te
                                                                                                     t
                         Pr Sha Siz




                                                                                                      y il




                                                                                                       lay
                            op p eE              eF                                                                                                                                                           iti io                      ve r




                                                                                                                                          o la




                                                                                                                                            S
                                e r e E nc          ilte                                                                                                                                                   ns sit                      on e




                                                                                                           o ut
                                                                                                            r
                                                                                                                                                                                                        Traran e n             rs tC rt




                                                                                                                                     e rp
                                   tyE nc o
                        Co            n o      de r                                                                                                                                                       T we             rte Te x nv e r
                             lo En co de r




                                                                                                                                  int
                Fis             rEn co de r                                                                                                                                                                 T          v e te d Co rte
                                                                                                                                                                                                                    o nlimi hML nv e rte r




                                                                                    la
                    he              co de r




                                                                                       b
                        ye                                                                                                                                                                                       C e p o ve




                                                                                      el
             Bif            D          de r                                                                                                                                                                        D ra aC o n




                                                                                                                                                 cs
                o c D isto                 r                                                                                                                                                                         G at NC




                                                                                                                                               analyti
                     alD isto rtio                                                                                                                                                                                     ID SO




                                                                            filt
                          isto rtio n                                                                                                                                                                                                 ld a




                                                                                           op
            Le                                                en                                                                                                                                                         J         Fie he m




                                                                                e
               ge              rtio n




                                                                               r
                                                                  co                                                                                                                                   s                       ataaSc t




                                                                                            e ra
             L e ndR                n                                de                                                                                                                           rte
                                                                                                                                                                                                      r                      D at e ce
                 g e an                                                                                                                                                                                                       D ataS o ur
                       nd ge                                            r                                                                                                                      ve




                                                                                                to r




                                                                                                                                                                   e
                  L e g Ite m                         dis                                                                                                                                    on                                 D taS able




                                                                                                                                                                 at
   Visu
                         en                               to                                                                                                                                c                                    Da taT til




                                                                                                                                                               im
        aliz                  d                              rtio
            a
         T tio n                                                                                                                                                                                                                  Da taU




                                                                                                                                                             an
                                                                  n                                                                                                                                                                Da
    Se leo o ltip Ev e nt                         le g                                                                                                                                                                                       rite
          ctio Ev e n                                                                                                                                                                                                                    ySp
         Dat   nEv         t                             en
                                                            d                                                                                                                                                                       Dirt e Sprite
              aEv e nt                                                                                                                                                                                                               L in
                    e nt
       Tre e                                   eve
             Build                                     nts
                     e                                                                                                                                                              ta                        lay
   Scale        Tre er                                                                                                                                                         da                      disp
           Bindin
                    g
Shape R
         e nde re                                                                                                                                                                                        fle x
      IRe nd         r
 Edge Re nd e re r                                                                          v is
              e re r                     re nde r
    Arro wType
                                                                                                                                                                                                           physics
      Node Sprite                                                           data
      EdgeSprite
       DataSprite                                                                                                                 fla
                                                                                                                                      re
         DataList
            Data
               ntro l
  To o ltipCo ntro l
          nCo
Se le ctiomCo ntro l                                   ls
        o          ol                             ro
PanZo       ICo ntr o l                      co nt
                 ntr
           e rCo ntro l
      Ho v dCo
          n          ro l
    Expa agCo ntlL ist
         Dr o ntro o l
            C         tr                                                                                                                                               qu
                Co n tro l                                       is                                                                                                      er
               kCo
                     n                                      ax                                                                                                             y
           Clic
Aitoff
TUTORIALS
A GUIDE OF BAR CHART
BASE COMPONENT
     HTML
     CSS
     Javascript
     SVG
SVG
<svg width="50" height="50">
</svg>
SVG
<svg width="50" height="50">
    <circle cx="25" cy="25" r="22"
     fill="blue" stroke="gray" stroke-width="2"/>
</svg>
SIMPLE SHAPES
SIMPLE SHAPES
<rect x="0" y="0" width="500" height="50"/>
SIMPLE SHAPES
<circle cx="250" cy="25" r="25"/>
SIMPLE SHAPES
<ellipse cx="250" cy="25" rx="100" ry="25"/>
SIMPLE SHAPES
<line x1="0" y1="0" x2="500" y2="50" stroke="black"/>
SIMPLE SHAPES
<text x="250" y="25">Easy-peasy</text>

                                  Easy-peasy
SIMPLE SHAPES
<text x="150" y="50" font-family="sans-serif"
      font-size="50" fill="gray">Easy-peasy</text>


                          Easy-peasy
SIMPLE SHAPES
<circle cx="25" cy="25" r="100"
  fill="yellow" stroke="orange" stroke-width="5"/>
SIMPLE SHAPES
<circle cx="25" cy="25" r="22" class="pumpkin"/>

.pumpkin {
    fill: red;
    stroke: orange;
    stroke-width: 5;
 }
SIMPLE SHAPES
<rect   x="100"   y="100"   width="80"   height="80"   fill="purple"/>
<rect   x="120"   y="105"   width="80"   height="80"   fill="blue"/>
<rect   x="140"   y="110"   width="80"   height="80"   fill="green"/>
<rect   x="160"   y="115"   width="80"   height="80"   fill="yellow"/>
<rect   x="180"   y="120"   width="80"   height="80"   fill="red"/>
SIMPLE SHAPES
<circle   cx="125"   cy="80"   r="60"   fill="rgba(128, 0, 128, 1.0)"/>
<circle   cx="150"   cy="80"   r="60"   fill="rgba(0, 0, 805, 0.75)"/>
<circle   cx="175"   cy="80"   r="60"   fill="rgba(0, 805, 0, 0.5)"/>
<circle   cx="200"   cy="80"   r="60"   fill="rgba(805, 805, 0, 0.80)"/>
<circle   cx="280"   cy="80"   r="60"   fill="rgba(805, 0, 0, 0.1)"/>
PAGE
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>D3 Test</title>
        <script type="text/javascript" src="d3/d3.v3.js">&lt;/script>
    </head>
    <body>
        <script type="text/javascript">
            // Your beautiful D3 code will go here
        &lt;/script>
    </body>
</html>
FIRST
d3.select("body").append("p").text("New paragraph!");
WITH DATA
var dataset = [ 5, 10, 15, 20, 25 ];
d3.select("body").selectAll("p");
WITH DATA
d3.select("body").selectAll("p")
    .data(dataset)
    .enter()
    .append("p")
    .text("New paragraph!");
WITH DATA
console.log(d3.selectAll("p"))
WITH DATA
console.log(d3.selectAll("p"))
WITH DATA
var dataset = [ 5, 10, 15, 20, 25 ];
d3.select("body").selectAll("p")
    .data(dataset)
    .enter()
    .append("p")
    .text(function(d) { return d; });
BEYOND TEXT
.style("color", "red");

.style("color", function(d) {
    if (d > 15) { //Threshold of 15
        return "red";
    } else {
        return "black";
    }
});
PLAY WITH DATA
var dataset = [ 25, 7, 5, 26, 11, 8, 25, 14, 23, 19,
                14, 11, 22, 29, 11, 13, 12, 17, 18, 10,
                24, 18, 25, 9, 3 ];

d3.select("body").selectAll("div")
    .data(dataset) // <-- The answer is here!
    .enter()
    .append("div")
    .attr("class", "bar")
    .style("height", function(d) {
        var barHeight = d * 5;
        return barHeight + "px";
    });
MAKING A BAR CHART
var dataset = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13,
                11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ];
MAKING A BAR CHART
svg.selectAll("rect")
   .data(dataset)
   .enter()
   .append("rect")
   .attr("x", 0)
   .attr("y", 0)
   .attr("width", 20)
   .attr("height", 100);
MAKING A BAR CHART
.attr("x", function(d, i) {
    return i * 21; //Bar width of 20 plus 1 for padding
})
MAKING A BAR CHART
.attr("height", function(d) {
    return d;
});
MAKING A BAR CHART
.attr("y", function(d) {
    return h - d; //Height minus data value
})
.attr("height", function(d) {
    return d * 4; //Just the data value
});
MAKING A BAR CHART
.attr("fill", function(d) {
    return "rgb(0, 0, " + (d * 10) + ")";
});
MAKING A BAR CHART
svg.selectAll("text")
   .data(dataset)
   .enter()
   .append("text")
   .text(function(d) {
       return d;
   })
   .attr("text-anchor", "middle")
   .attr("x", function(d, i) {
       return i * (w / dataset.length) + (w / dataset.length - barPadd
ing) / 2;
   })
   .attr("y", function(d) {
       return h - (d * 4) + 14;
   })
   .attr("font-family", "sans-serif")
   .attr("font-size", "11px")
   .attr("fill", "white");
THE ANALYSIS OF
 SOURCE CODE
THE WEALTH & HEALTH OF NATIONS
DATA
[{
     "name": "Angola",
     "region": "Sub-Saharan Africa",
     "income": [
       [1800, 359.93],
       [1820, 359.93],
       [1913, 556.12],
       [1950, 3363.02],
       [1951, 3440.9],
       [1952, 3520.61],
       [1953, 3598.81],
       [1954, 3450.82],
       [1955, 3672.08],
       [1956, 3549.04],
TRANSITION
// Start a transition that interpolates the data based on year.
svg.transition()
    .duration(duration)
    .ease("linear")
    .tween("year", tweenYear())
    .each("end", enableInteraction);

// Tweens the entire chart by first tweening the year, and then the da
ta.
// For the interpolated data, the dots and label are redrawn.
function tweenYear(start, end) {
  start = start || 1800;
  end = end || 2009;
  return function() {
    var year = d3.interpolateNumber(start, end);
    return function(t) { displayYear(year(t)); };
  }
}
INTERPOLATE DATA
// Interpolates the dataset for the given (fractional) year.
function interpolateData(year) {
  return nations.map(function(d) {
    return {
       name: d.name,
       income: interpolateValues(d.income, year),
       //...
    };
  });
}

// Finds (and possibly interpolates) the value for the specified year.
function interpolateValues(values, year) {
  var i = bisect.left(values, year, 0, values.length - 1),
      a = values[i];
  if (i > 0) {
    var b = values[i - 1],
        t = (year - a[0]) / (b[0] - a[0]);
ADSERVER SVN COMMIT RECORD
DATA
"total": [
   [1303115788,   2],
   [1303182050,   6],
   [1303194454,   18],
   [1303210228,   28],
   [1303267612,   40],
   //...
],
"qwang": [
   [1335869108,   0],
   [1335869108,   9],
   [1335869340,   2],
   [1335954367,   33],
   //...
LAYOUT
force = d3.layout.force()
          .gravity(.5)
          .charge(function(d, i){ return i ? 0 : -20; })
          .nodes(users)
          .size([width, height]);

force.start();
force.on("tick", function(e) {
  var q = d3.geom.quadtree(users),
      i = 0,
      n = users.length;

  while (++i < n) {
    q.visit(collide(users[i]));
  }

  dot.selectAll("g")
     .attr("transform", function(d) { return "translate(" + d.x + ", "
COLLISION
function collide(node) {
  var rr = r(node),
      nx1 = node.x - rr,
      nx2 = node.x + rr,
      ny1 = node.y - rr,
      ny2 = node.y + rr;
  return function(quad, x1, y1, x2, y2) {
    if (quad.point && (quad.point !== node)) {
      var x = node.x - quad.point.x,
          y = node.y - quad.point.y,
          l = Math.sqrt(x * x + y * y),
          rr = r(node) + r(quad.point);
      if (l < rr) {
        l = (l - rr) / l * .5;
        node.x -= x *= l;
        node.y -= y *= l;
        quad.point.x += x;
        quad.point.y += y;
RESUME
function displayDay(time_pos) {
  dots.data(interpolateData(time_pos)).call(position).sort(order);
  label.text(secondtoday(time_pos));
  force.resume();
}
RESOURCES
RESOURCES
D3js Wiki
Paper:D3: Data-Driven Documents
Mike Bostock
Visual.ly
David McCandless: The beauty of data visualization
GapMinder - for a fact-based world view
Q&A
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

Capitol Tweets: Yeas and Nays of the Congressional Twitterverse
Capitol Tweets: Yeas and Nays of the Congressional TwitterverseCapitol Tweets: Yeas and Nays of the Congressional Twitterverse
Capitol Tweets: Yeas and Nays of the Congressional TwitterverseEdelman
 
Fareham College Aosec Presentation 7 Mar 2012
Fareham College   Aosec Presentation 7 Mar 2012Fareham College   Aosec Presentation 7 Mar 2012
Fareham College Aosec Presentation 7 Mar 2012Charles Whinney
 
Deutsche bank russia one on-one conference — london
Deutsche bank russia one on-one conference — londonDeutsche bank russia one on-one conference — london
Deutsche bank russia one on-one conference — londonevraz_company
 
شرح برنامج اكسل بالتفصيل
شرح برنامج اكسل بالتفصيلشرح برنامج اكسل بالتفصيل
شرح برنامج اكسل بالتفصيلPrince Sh
 
What Can Data Tell Us?
What Can Data Tell Us?What Can Data Tell Us?
What Can Data Tell Us?OReillyTOC
 
2010大陸 絲路旅行計畫
2010大陸 絲路旅行計畫2010大陸 絲路旅行計畫
2010大陸 絲路旅行計畫bluehero
 
MN MTA Presentation 6.19.2012 Kevin Hockert, CMT
MN MTA Presentation 6.19.2012 Kevin Hockert, CMTMN MTA Presentation 6.19.2012 Kevin Hockert, CMT
MN MTA Presentation 6.19.2012 Kevin Hockert, CMTAnn Treacy
 
062112 tamil (supreme court)
062112   tamil (supreme court)062112   tamil (supreme court)
062112 tamil (supreme court)VogelDenise
 

Was ist angesagt? (8)

Capitol Tweets: Yeas and Nays of the Congressional Twitterverse
Capitol Tweets: Yeas and Nays of the Congressional TwitterverseCapitol Tweets: Yeas and Nays of the Congressional Twitterverse
Capitol Tweets: Yeas and Nays of the Congressional Twitterverse
 
Fareham College Aosec Presentation 7 Mar 2012
Fareham College   Aosec Presentation 7 Mar 2012Fareham College   Aosec Presentation 7 Mar 2012
Fareham College Aosec Presentation 7 Mar 2012
 
Deutsche bank russia one on-one conference — london
Deutsche bank russia one on-one conference — londonDeutsche bank russia one on-one conference — london
Deutsche bank russia one on-one conference — london
 
شرح برنامج اكسل بالتفصيل
شرح برنامج اكسل بالتفصيلشرح برنامج اكسل بالتفصيل
شرح برنامج اكسل بالتفصيل
 
What Can Data Tell Us?
What Can Data Tell Us?What Can Data Tell Us?
What Can Data Tell Us?
 
2010大陸 絲路旅行計畫
2010大陸 絲路旅行計畫2010大陸 絲路旅行計畫
2010大陸 絲路旅行計畫
 
MN MTA Presentation 6.19.2012 Kevin Hockert, CMT
MN MTA Presentation 6.19.2012 Kevin Hockert, CMTMN MTA Presentation 6.19.2012 Kevin Hockert, CMT
MN MTA Presentation 6.19.2012 Kevin Hockert, CMT
 
062112 tamil (supreme court)
062112   tamil (supreme court)062112   tamil (supreme court)
062112 tamil (supreme court)
 

Andere mochten auch

Stochastic Optimization: Solvers and Tools
Stochastic Optimization: Solvers and ToolsStochastic Optimization: Solvers and Tools
Stochastic Optimization: Solvers and ToolsSSA KPI
 
Introduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsIntroduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsMichał Oniszczuk
 
Big Data Introduction to D3
Big Data Introduction to D3Big Data Introduction to D3
Big Data Introduction to D3Vishal Kumar
 

Andere mochten auch (6)

Introduction to D3.js
Introduction to D3.jsIntroduction to D3.js
Introduction to D3.js
 
D3 data visualization
D3 data visualizationD3 data visualization
D3 data visualization
 
Stochastic Optimization: Solvers and Tools
Stochastic Optimization: Solvers and ToolsStochastic Optimization: Solvers and Tools
Stochastic Optimization: Solvers and Tools
 
D3 js
D3 jsD3 js
D3 js
 
Introduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsIntroduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven Documents
 
Big Data Introduction to D3
Big Data Introduction to D3Big Data Introduction to D3
Big Data Introduction to D3
 

Ähnlich wie A short introduction of D3js

LinkedIn's Q3 Earnings Call
LinkedIn's Q3 Earnings CallLinkedIn's Q3 Earnings Call
LinkedIn's Q3 Earnings CallLinkedIn
 
SPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARKTsuyoshi Horigome
 
VaR of Operational Risk
VaR of Operational RiskVaR of Operational Risk
VaR of Operational RiskRahmat Mulyana
 
Excel Function in Advanced Use
Excel Function in Advanced UseExcel Function in Advanced Use
Excel Function in Advanced UseDick Lam
 
CAD integrated automatic DFM analysis
CAD integrated automatic DFM analysisCAD integrated automatic DFM analysis
CAD integrated automatic DFM analysisbhaskars
 
Top Application Performance Landmines
Top Application Performance LandminesTop Application Performance Landmines
Top Application Performance LandminesAndreas Grabner
 
Lta qrb501 wk6
Lta qrb501 wk6Lta qrb501 wk6
Lta qrb501 wk6May Avery
 
SPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARKSPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARKTsuyoshi Horigome
 
LinkedIn’s Q4 2011 Earnings Announcement
LinkedIn’s Q4 2011 Earnings AnnouncementLinkedIn’s Q4 2011 Earnings Announcement
LinkedIn’s Q4 2011 Earnings AnnouncementLinkedIn
 
SPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARKTsuyoshi Horigome
 
SPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARKSPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARKTsuyoshi Horigome
 
SPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARKTsuyoshi Horigome
 
SPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARKSPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARKTsuyoshi Horigome
 
SPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARKSPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARKTsuyoshi Horigome
 
SPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARKTsuyoshi Horigome
 

Ähnlich wie A short introduction of D3js (20)

Q3 Earning report of Daimler AG
Q3 Earning report of Daimler AGQ3 Earning report of Daimler AG
Q3 Earning report of Daimler AG
 
LinkedIn's Q3 Earnings Call
LinkedIn's Q3 Earnings CallLinkedIn's Q3 Earnings Call
LinkedIn's Q3 Earnings Call
 
SPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Professional+BDP Model) in SPICE PARK
 
VaR of Operational Risk
VaR of Operational RiskVaR of Operational Risk
VaR of Operational Risk
 
Texconf11
Texconf11Texconf11
Texconf11
 
Excel Function in Advanced Use
Excel Function in Advanced UseExcel Function in Advanced Use
Excel Function in Advanced Use
 
CAD integrated automatic DFM analysis
CAD integrated automatic DFM analysisCAD integrated automatic DFM analysis
CAD integrated automatic DFM analysis
 
Top Application Performance Landmines
Top Application Performance LandminesTop Application Performance Landmines
Top Application Performance Landmines
 
Parker Hannifin 2012 Annual Report
Parker Hannifin 2012 Annual ReportParker Hannifin 2012 Annual Report
Parker Hannifin 2012 Annual Report
 
Lta qrb501 wk6
Lta qrb501 wk6Lta qrb501 wk6
Lta qrb501 wk6
 
SPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARKSPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Standard+BDS Model) in SPICE PARK
 
LinkedIn’s Q4 2011 Earnings Announcement
LinkedIn’s Q4 2011 Earnings AnnouncementLinkedIn’s Q4 2011 Earnings Announcement
LinkedIn’s Q4 2011 Earnings Announcement
 
SPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2611 (Professional+BDP Model) in SPICE PARK
 
Ch099 a ch02-if-wkshts
Ch099 a ch02-if-wkshtsCh099 a ch02-if-wkshts
Ch099 a ch02-if-wkshts
 
SPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARKSPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARK
SPICE MODEL of 2SK2698 (Standard+BDS Model) in SPICE PARK
 
SPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2543 (Professional+BDP Model) in SPICE PARK
 
Chinese Pediatric USCOM values
Chinese Pediatric USCOM valuesChinese Pediatric USCOM values
Chinese Pediatric USCOM values
 
SPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARKSPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TPCM8002-H (Standard+BDS Model) in SPICE PARK
 
SPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARKSPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARK
SPICE MODEL of TK40J60T (Standard+BDS Model) in SPICE PARK
 
SPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARKSPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARK
SPICE MODEL of 2SK2916 (Professional+BDP Model) in SPICE PARK
 

Mehr von dreampuf

Python magicmethods
Python magicmethodsPython magicmethods
Python magicmethodsdreampuf
 
Python profiling
Python profilingPython profiling
Python profilingdreampuf
 
The introduction of data visualization
The introduction of data visualizationThe introduction of data visualization
The introduction of data visualizationdreampuf
 
Python client api
Python client apiPython client api
Python client apidreampuf
 
Communication with python_http_module
Communication with python_http_moduleCommunication with python_http_module
Communication with python_http_moduledreampuf
 
Refactoring
RefactoringRefactoring
Refactoringdreampuf
 
Machine learning share No.1
Machine learning share No.1Machine learning share No.1
Machine learning share No.1dreampuf
 

Mehr von dreampuf (7)

Python magicmethods
Python magicmethodsPython magicmethods
Python magicmethods
 
Python profiling
Python profilingPython profiling
Python profiling
 
The introduction of data visualization
The introduction of data visualizationThe introduction of data visualization
The introduction of data visualization
 
Python client api
Python client apiPython client api
Python client api
 
Communication with python_http_module
Communication with python_http_moduleCommunication with python_http_module
Communication with python_http_module
 
Refactoring
RefactoringRefactoring
Refactoring
 
Machine learning share No.1
Machine learning share No.1Machine learning share No.1
Machine learning share No.1
 

Kürzlich hochgeladen

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
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
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Kürzlich hochgeladen (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
+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...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

A short introduction of D3js

  • 2. AGENDA Introduction Examples A guide of bar chart The analysis of source code The Wealth & Health of Nations An time series visual design of Adserver svn commit record Resources
  • 4. D3.JS: DATA-DRIVEN DOCUMENTS JavaScript Library Open source (BSD license) developed by Michael Bostock and others at Stanford University former work on Protovis Library from Intro to d3
  • 5. D3.JS: DATA-DRIVEN DOCUMENTS not a traditional visualization framework focus on efficient manipulation of documents based on data bind arbitrary data to the DOM apply data-driven transformations to the document functional/declarative style support for interaction and animation you have to do the graphical representation yourself! but has helpers for SVG generation from Intro to d3
  • 7. SELECTIONS d3.selectAll("p") .style("color", "white"); operate on arbitrary sets of nodes called selections W3C Selectors API or Sizzle fallback
  • 8. DYNAMIC PROPERTIES d3.selectAll("p") .data([4, 8, 15, 16, 23, 42]) .style("font-size", function(d, i) { return d + "px"; }); bind data to a selection apply functions to styles, attributes and other properties a lot of built-in reusable functions available bound data available as first argument you can omit the data operator the second time!
  • 9. ENTER AND EXIT var p = d3.select("body").selectAll("p") // Update… .data([4, 8, 15, 16, 23, 42]) .text(String); p.enter().append("p") // Enter… .text(String); p.exit().remove(); // Exit… enter: selects all data elements without a DOM representation exit: selects all DOM elements without data common pattern perform only necessary modifications
  • 10. SUBSELECTIONS d3.selectAll("ul") .data(questions) // an array of questions .selectAll("li") // a nested array of responses .data(function(d) { return d.responses; }) // the text of the response .text(function(d) { return d.text; }); generate a subselection by calling selectAll on an existing selection maintains the hierarchical structure
  • 11. TRANSITIONS // fade background from white to black in 1s d3.select("body").transition() .duration(1000) .style("background-color", "black"); with d3.js they are easy! various tweening functions interpolation of basic types, numbers and numbers in strings (e.g. "15px")
  • 16.
  • 17. economy (mpg) cylinders displacement (cc) power (hp) weight (lb) 0-60 mph (s) 8.0 450 45 220 5,000 24 7.5 200 40 400 22 4,500 7.0 180 35 350 20 6.5 160 4,000 30 6.0 300 140 18 25 3,500 120 5.5 250 16 20 100 5.0 3,000 80 14 200 15 4.5 60 2,500 12 10 150 4.0 40 2,000 10 5 3.5 100 20 0 3.0 0 8
  • 18. Agglo merativeCluster lity Co mmunityStructure L inkD e nne ssCe ntra O pe rato pe rato rL ist te r Stac ando m L ayo u t HierarchicalClus O pe rato rSw e ke r No d Span e stPaths t Tre e M Sho rt lo wMinCu Rad So rtO pe ratoh Ind Icicle cte d L ayyo ut t ke dA nce Visualization R B an Fo ndr ck le L o u ut e O Tre e MaxF istance e L in rSe que nc Me rge Edg e nt rce o g ing ay te ialTr Pie L ay o ut De Pa c R o Cir r que Ob mbixInte to r lato r r O pe ra atio Int te In te rp o lato re aL ayo ut Nu atr o la rpo ato apL a ed kTre L ayyo ut ning cle Bu Dir ra L a o u r e I la to r ee ct Inte te rpo to r gl o o la lato Be twe nSe e ctR ol nd Tre e L ay o ut e r nt to r L to Tre L ay o ut Dao lo rIn te rp ayo u e L a o ut Sta itc Reo int ctInrInte o la yo utt le d A la e La ou to r ctio Funsing er r Cir ge ay ck R r po rp Asp C rayIn y m M e rp te Ed xisL ou an rp rp e d ad Ea t Ar ial L a P je e Ar e a L a be o r le t Se cheuse le l lab L a be le G n be le r ra l u Fis izatio Pa ara e d IO p le r hD cluste r he itio nc r Vi tan pe Filtete r ns ue ule P ch r e graph sib c t is ye er en ra IS Tra q d r o ptim ilit e F Tre n o n nEv rte te t Pr Sha Siz y il lay op p eE eF iti io ve r o la S e r e E nc ilte ns sit on e o ut r Traran e n rs tC rt e rp tyE nc o Co n o de r T we rte Te x nv e r lo En co de r int Fis rEn co de r T v e te d Co rte o nlimi hML nv e rte r la he co de r b ye C e p o ve el Bif D de r D ra aC o n cs o c D isto r G at NC analyti alD isto rtio ID SO filt isto rtio n ld a op Le en J Fie he m e ge rtio n r co s ataaSc t e ra L e ndR n de rte r D at e ce g e an D ataS o ur nd ge r ve to r e L e g Ite m dis on D taS able at Visu en to c Da taT til im aliz d rtio a T tio n Da taU an n Da Se leo o ltip Ev e nt le g rite ctio Ev e n ySp Dat nEv t en d Dirt e Sprite aEv e nt L in e nt Tre e eve Build nts e ta lay Scale Tre er da disp Bindin g Shape R e nde re fle x IRe nd r Edge Re nd e re r v is e re r re nde r Arro wType physics Node Sprite data EdgeSprite DataSprite fla re DataList Data ntro l To o ltipCo ntro l nCo Se le ctiomCo ntro l ls o ol ro PanZo ICo ntr o l co nt ntr e rCo ntro l Ho v dCo n ro l Expa agCo ntlL ist Dr o ntro o l C tr qu Co n tro l is er kCo n ax y Clic
  • 19.
  • 20.
  • 21.
  • 23. TUTORIALS A GUIDE OF BAR CHART
  • 24. BASE COMPONENT HTML CSS Javascript SVG
  • 26. SVG <svg width="50" height="50"> <circle cx="25" cy="25" r="22" fill="blue" stroke="gray" stroke-width="2"/> </svg>
  • 28. SIMPLE SHAPES <rect x="0" y="0" width="500" height="50"/>
  • 29. SIMPLE SHAPES <circle cx="250" cy="25" r="25"/>
  • 30. SIMPLE SHAPES <ellipse cx="250" cy="25" rx="100" ry="25"/>
  • 31. SIMPLE SHAPES <line x1="0" y1="0" x2="500" y2="50" stroke="black"/>
  • 32. SIMPLE SHAPES <text x="250" y="25">Easy-peasy</text> Easy-peasy
  • 33. SIMPLE SHAPES <text x="150" y="50" font-family="sans-serif" font-size="50" fill="gray">Easy-peasy</text> Easy-peasy
  • 34. SIMPLE SHAPES <circle cx="25" cy="25" r="100" fill="yellow" stroke="orange" stroke-width="5"/>
  • 35. SIMPLE SHAPES <circle cx="25" cy="25" r="22" class="pumpkin"/> .pumpkin { fill: red; stroke: orange; stroke-width: 5; }
  • 36. SIMPLE SHAPES <rect x="100" y="100" width="80" height="80" fill="purple"/> <rect x="120" y="105" width="80" height="80" fill="blue"/> <rect x="140" y="110" width="80" height="80" fill="green"/> <rect x="160" y="115" width="80" height="80" fill="yellow"/> <rect x="180" y="120" width="80" height="80" fill="red"/>
  • 37. SIMPLE SHAPES <circle cx="125" cy="80" r="60" fill="rgba(128, 0, 128, 1.0)"/> <circle cx="150" cy="80" r="60" fill="rgba(0, 0, 805, 0.75)"/> <circle cx="175" cy="80" r="60" fill="rgba(0, 805, 0, 0.5)"/> <circle cx="200" cy="80" r="60" fill="rgba(805, 805, 0, 0.80)"/> <circle cx="280" cy="80" r="60" fill="rgba(805, 0, 0, 0.1)"/>
  • 38.
  • 39. PAGE <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>D3 Test</title> <script type="text/javascript" src="d3/d3.v3.js">&lt;/script> </head> <body> <script type="text/javascript"> // Your beautiful D3 code will go here &lt;/script> </body> </html>
  • 41. WITH DATA var dataset = [ 5, 10, 15, 20, 25 ]; d3.select("body").selectAll("p");
  • 42. WITH DATA d3.select("body").selectAll("p") .data(dataset) .enter() .append("p") .text("New paragraph!");
  • 45. WITH DATA var dataset = [ 5, 10, 15, 20, 25 ]; d3.select("body").selectAll("p") .data(dataset) .enter() .append("p") .text(function(d) { return d; });
  • 46.
  • 47. BEYOND TEXT .style("color", "red"); .style("color", function(d) { if (d > 15) { //Threshold of 15 return "red"; } else { return "black"; } });
  • 48. PLAY WITH DATA var dataset = [ 25, 7, 5, 26, 11, 8, 25, 14, 23, 19, 14, 11, 22, 29, 11, 13, 12, 17, 18, 10, 24, 18, 25, 9, 3 ]; d3.select("body").selectAll("div") .data(dataset) // <-- The answer is here! .enter() .append("div") .attr("class", "bar") .style("height", function(d) { var barHeight = d * 5; return barHeight + "px"; });
  • 49. MAKING A BAR CHART var dataset = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13, 11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ];
  • 50. MAKING A BAR CHART svg.selectAll("rect") .data(dataset) .enter() .append("rect") .attr("x", 0) .attr("y", 0) .attr("width", 20) .attr("height", 100);
  • 51. MAKING A BAR CHART .attr("x", function(d, i) { return i * 21; //Bar width of 20 plus 1 for padding })
  • 52. MAKING A BAR CHART .attr("height", function(d) { return d; });
  • 53. MAKING A BAR CHART .attr("y", function(d) { return h - d; //Height minus data value }) .attr("height", function(d) { return d * 4; //Just the data value });
  • 54. MAKING A BAR CHART .attr("fill", function(d) { return "rgb(0, 0, " + (d * 10) + ")"; });
  • 55. MAKING A BAR CHART svg.selectAll("text") .data(dataset) .enter() .append("text") .text(function(d) { return d; }) .attr("text-anchor", "middle") .attr("x", function(d, i) { return i * (w / dataset.length) + (w / dataset.length - barPadd ing) / 2; }) .attr("y", function(d) { return h - (d * 4) + 14; }) .attr("font-family", "sans-serif") .attr("font-size", "11px") .attr("fill", "white");
  • 56. THE ANALYSIS OF SOURCE CODE
  • 57. THE WEALTH & HEALTH OF NATIONS
  • 58. DATA [{ "name": "Angola", "region": "Sub-Saharan Africa", "income": [ [1800, 359.93], [1820, 359.93], [1913, 556.12], [1950, 3363.02], [1951, 3440.9], [1952, 3520.61], [1953, 3598.81], [1954, 3450.82], [1955, 3672.08], [1956, 3549.04],
  • 59. TRANSITION // Start a transition that interpolates the data based on year. svg.transition() .duration(duration) .ease("linear") .tween("year", tweenYear()) .each("end", enableInteraction); // Tweens the entire chart by first tweening the year, and then the da ta. // For the interpolated data, the dots and label are redrawn. function tweenYear(start, end) { start = start || 1800; end = end || 2009; return function() { var year = d3.interpolateNumber(start, end); return function(t) { displayYear(year(t)); }; } }
  • 60. INTERPOLATE DATA // Interpolates the dataset for the given (fractional) year. function interpolateData(year) { return nations.map(function(d) { return { name: d.name, income: interpolateValues(d.income, year), //... }; }); } // Finds (and possibly interpolates) the value for the specified year. function interpolateValues(values, year) { var i = bisect.left(values, year, 0, values.length - 1), a = values[i]; if (i > 0) { var b = values[i - 1], t = (year - a[0]) / (b[0] - a[0]);
  • 62. DATA "total": [ [1303115788, 2], [1303182050, 6], [1303194454, 18], [1303210228, 28], [1303267612, 40], //... ], "qwang": [ [1335869108, 0], [1335869108, 9], [1335869340, 2], [1335954367, 33], //...
  • 63. LAYOUT force = d3.layout.force() .gravity(.5) .charge(function(d, i){ return i ? 0 : -20; }) .nodes(users) .size([width, height]); force.start(); force.on("tick", function(e) { var q = d3.geom.quadtree(users), i = 0, n = users.length; while (++i < n) { q.visit(collide(users[i])); } dot.selectAll("g") .attr("transform", function(d) { return "translate(" + d.x + ", "
  • 64. COLLISION function collide(node) { var rr = r(node), nx1 = node.x - rr, nx2 = node.x + rr, ny1 = node.y - rr, ny2 = node.y + rr; return function(quad, x1, y1, x2, y2) { if (quad.point && (quad.point !== node)) { var x = node.x - quad.point.x, y = node.y - quad.point.y, l = Math.sqrt(x * x + y * y), rr = r(node) + r(quad.point); if (l < rr) { l = (l - rr) / l * .5; node.x -= x *= l; node.y -= y *= l; quad.point.x += x; quad.point.y += y;
  • 65. RESUME function displayDay(time_pos) { dots.data(interpolateData(time_pos)).call(position).sort(order); label.text(secondtoday(time_pos)); force.resume(); }
  • 67. RESOURCES D3js Wiki Paper:D3: Data-Driven Documents Mike Bostock Visual.ly David McCandless: The beauty of data visualization GapMinder - for a fact-based world view
  • 68. Q&A