20
HTML5 Canvas DATA VISUALISATION Antonio Fabregat Mundo Hinxton Services Forum May 30, 2013

Data Visualisation using HTML5 Canvas

Embed Size (px)

Citation preview

Page 1: Data Visualisation using HTML5 Canvas

HTML5 Canvas

DATA VISUALISATION

Antonio Fabregat Mundo Hinxton Services Forum May 30, 2013

Page 2: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Overview

•  Aim

•  Web technologies for rich graphics creation

•  Dealing with the data

•  CANVASing the data

•  Interactivity in Canvas

•  Animation in Canvas

•  Some tips

•  Examples

Page 3: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Aim

•  Data visualisation

•  Interactivity

•  Animation

Page 4: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Web technologies for rich graphics creation

CANVAS SVG High performance 2D surface for drawing. Resolution independence.

Constant performance because everything is a pixel. Performance only degrades when the image resolution increases.

SVG has very good support for animations. Elements can be animated using a declarative syntax, or via JavaScript.

Resulting image into the Canvas can be saved as PNG or JPEG. Full control over each element using the SVG DOM API in JavaScript.

Best suited for generating raster graphics, editing of images, and operations requiring pixel-level manipulation.

Accessibility to the SVG objects can be much better than that of canvas elements.

CANVAS SVG No DOM nodes for the represented objects. Slow rendering when document complexity increases. A use case is a large dataset to

be represented as an image.

Animation to be implemented manually. SVG might not be suited by itself for applications like games. Perhaps the best choice would be a Canvas + SVG combination

Poor text rendering capabilities. Difficulties exporting the resulting image.

Advantages

Disadvantages

Page 5: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Web technologies for rich graphics creation

•  Canvas •  Interactive image editing

•  Generating raster graphics

•  Image analysis

•  Rendering game graphics, such as sprites and backgrounds

•  SVG •  Resolution-independent Web

application user interfaces

•  Highly interactive animated user interfaces

•  Data charts and plots

•  Vector image editing

Each technology has its own uses It is not like one can abandon Canvas in favor of SVG, or vice-versa.

Which one to pick?

Page 6: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Dealing with the data

Data acquisition Web services providing raw data (XML or JSON format)

Page 7: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Dealing with the data

Splitting the view from the model MV* keeps data and representation separated

Page 8: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

CANVASing the data

Client side image generation Objects in the data model are drawn into the canvas

Page 9: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

CANVASing the data

Graphical projection Calculating where to draw every object

Depends on the available area and number of objects

Page 10: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

CANVASing the data

Mouse position Bijective function to determine hovered objects

Page 11: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Interactivity in Canvas

•  Interactivity is not animation

•  Refreshing canvas when mouse over

•  How to improve behavior?

•  Render screen differences only

•  Back Buffer (redraw a gradient à 5 times faster)

•  Layered canvases

•  Important: Refreshing more than 24 times per second?

Page 12: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Animation in Canvas

Full redrawing Every object drawer defines how to proceed for a certain percentage

Page 13: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Some tips

Always update the model Actions over the canvas directly modify the model

Page 14: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Some tips

Precalculate as much as possible Calculations that can be done once have to be moved out from the drawing methods

Page 15: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Some tips

Discrete time slots Response improvement

Page 16: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Some tips

Refreshing only when needed Checking basic user actions before refreshing saves time

Page 17: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Examples PRIDE - Protein coverage viewer

PRIDE - Sequence viewer

Page 18: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

METABOLIGHTS – Spectrum viewer

Examples PRIDE – Spectrum viewer

Page 19: Data Visualisation using HTML5 Canvas

Data Visualisation using HTML5 Canvas Hinxton Services Forum May 30, 2013

Examples REACTOME – Pathway Diagram

Page 20: Data Visualisation using HTML5 Canvas

Thank you! J

[email protected]