Responsivity

The Oatmeal

Responsive Web Design

Responsive Web Design

Responsive Web Design

Email Fallback:

Responsive Visualizations

Responsive Visualizations

Responsive Visualizations

Bocoup: Mobile Vis

Sebastian Sadowski: Mobile Infovis

Responsive Web Design

Major form factors/devices:

Responsive Web Design

Differences:

Responsive Web Design

Differences:

Responsive Web Design

Device-centric -> User-centric

Responsive Web Design

How do you design for someone who ...

Interaction

Heer, Shneiderman: Interactive Dynamics for Visual Analysis

Responsive Interaction

Responsive Interaction

Major question of responsive design: how to shrink interaction to different form factors?

Responsive Interaction

Do we even NEED interaction?

Archie Tse's "3 rules for visual storytelling"

1. If you make the reader click or do anything other than scroll, something spectacular has to happen.

Archie Tse: Malofiej 2016

Archie Tse's "3 rules for visual storytelling"

2. If you make a tooltip or rollover, assume no one will ever see it. If the content is important for readers to see, don't hide it.

Archie Tse: Malofiej 2016

Archie Tse's "3 rules for visual storytelling"

3. When deciding to make something interactive, remember that getting it to work on all platforms is expensive.

Archie Tse: Malofiej 2016

Exercise:
Pick one of Accurat's Corriere Della Sera graphics and turn them into something that could work on a phone/tablet.

https://www.accurat.it/works/la-lettura/

https://www.flickr.com/photos/accurat/sets/72157632185046466/with/9715671141/

Case studies

Case studies

OECD Regional Well-Being

Case studies

OECD Better Life Index

Case studies

2q17.de

Basic ideas

Basic Ideas

Basic Ideas

Good (clear) design becomes more important, the less space there is available!

HTML/CSS Techniques

HTML/CSS Techniques

Use the right meta tags:

<meta
  name="viewport"
  content="width=device-width, initial-scale=1"
>

HTML/CSS Techniques

Use relative sizes instead of absolute ones:

#viz {
  width: 960px;
}
#viz {
  width: 80%;
}

HTML/CSS Techniques

Use (r)em instead of px/pt for font sizes:

.title {
  font-size: 2em;
}

body {
  font-size: 24px;
}

HTML/CSS Techniques

CSS media queries let you fine-tune for specific devices:

#nav {
  width: 100%;
}

@media screen and (min-width: 1368px) {
  #nav {
    float: left;
    width: 32.5%;
  }
}

HTML/CSS Techniques

To keep CSS and JS in sync, use window.matchMedia:

var query = '(min-width: 1280px)';

var isDesktop = window.matchMedia(query).matches
// >= 1280px => true
// < 1280px  => false

Grids

Grids

Organizing content in boxes and placing them in a grid not only makes for a cleaner design, but also helps with adapting to different screen sizes.

OECD Regional Well-Being

Grids

There are various CSS frameworks supporting grids out there. The bigger ones are Twitter's Bootstrap and Zurb's Foundation.

Grids

Let's have a look at Bootstrap's grids:

Bootstrap grid options

Grids

Let's work with an example:

https://dominikus.github.io/rdv/01_cards.html

SVG Techniques

SVG Techniques

As the name implies, SVG are scalable, which makes them automatically look nice on various types of devices.

SVG Techniques

You can fine-tune the scaling using the SVG viewBox and preserveAspectRatio attributes:

<svg width="600" height="400"
  viewBox="0 0 200 200"
  preserveAspectRatio="xMinYMax meet" />

Interaction

Interaction

Touch input has different event handlers. But they work just like their mouse counterparts.

circle.on('touchstart', ...)
  .on('touchmove', ...)
  .on('touchend', ...);

Apple: Human Interface Guidelines

Interaction

Mobile browsers have to juggle touch-to-scroll with touch-to-interact. If you have a fullscreen page anyway, consider disabling scrolling:

document.ontouchstart = 
  function(e){
    e.preventDefault();
  };

Interaction

Consider adding enlarged (invisible) touch areas:

Interaction

.touch-help {
    opacity: 0;
    z-index: 99999;
}

Interaction

... or even take over interactivity completely:

Interaction

touchHelpers.on('touchstart', function(){
  console.log(d3.touches(this));
  // => [342.1, 283.5]
});
  

Interaction

Use voronoi diagrams for fine-grained interaction.

Mike Bostock: Voronoi Tesselation

Interaction

Voronoi scatterplot:

Voronoi scatterplot

Tooltips

Tooltips

Tooltips are pretty useful for data exploration - we don't want to lose them on mobile!

Tooltips

One solution: have a position: fixed tooltip at the bottom!

Tooltips

Two-step interaction: tap once to open, tap again to click, tap anywhere to close.

OECD Regional Well-Being

Sensors

Sensors

Mobile devices also have upsides: cool sensors!

Sensors

Geolocation:

navigator.geolocation.getCurrentPosition(
      function(position){
         console.log(
            position.coords.latitude +
            "," + position.coords.longitude
         );
      }
   );
    

Sensors

Geolocation:

OECD Regional Well-Being

Sensors

Multitouch/Gestural interactions: Supported by most d3 behaviors out of the box.

Mike Bostock: Pan & Zoom IV

Mike Bostock: Multitouch II

Sensors

You can also use a dedicated gesture library like QuoJS or HammerJS to support fancier interactions.

Sensors

Gyroscopes/Accelerometers

window.addEventListener(
    "deviceorientation",
    function(orientation){
       console.log(orientation.alpha +
       "," + orientation.beta +
       "," + orientation.gamma
       );
    },
    true
 );
  

Sensors

http://dominiku.indus.uberspace.de/marble/

More

Bill Hinderman: Building Responsive Data Visualization for the Web

Scrollytelling

Scrollytelling

Let's go exploring!

The Pudding: The Unlikely Odds of Making it Big

Scrollytelling

Mike Bostock: How To Scroll

Scrollytelling

The Pudding: Scrollytelling with six libraries

Scrollytelling

The Pudding: Responsive Scrollytelling best practices

Scrollytelling

Libraries

Waypoints.js

Scrollytelling

Libraries

Russell Goldenberg: Scrollama

Scrollytelling

Let's work with an example:

https://dominikus.github.io/rdv/02_scrolly_vis.html

Scrollytelling

(Continued)

https://dominikus.github.io/rdv/03_globe.html

Scrollytelling

Let's put it all together:

https://dominikus.github.io/rdv/04_unlikely_odds.html

One last detail

Would be even nicer with sticky positioning of the vis:

MDN: position

Performance

Performance

Speaking about responsiveness, oftentimes we bind redraw handler to the resize event:

window.on('resize', redraw);

Performance

This can lead to A LOT of redraws. Consider using some way of debouncing:

window.on('resize', _.debounce(redraw, 300))

Performance

Use requestAnimationFrame instead of setTimeout.

Performance

Sometimes: canvas/WebGL can be faster than SVG (usually with really massive amounts of shapes/animations).

Performance

Plus all the other details:

Performance

Dominikus Baur: Weighing Performance Against Pain (OpenVisConf)