jpfinley + javascript 38
Datavisualization.ch Selected Tools
22 days ago by jpfinley
Datavisualization.ch Selected Tools is a collection of tools that we, the people behind Datavisualization.ch, work with on a daily basis and recommend warmly. This is not a list of everything out there, but instead a thoughtfully curated selection of our favourite tools that will make your life easier creating meaningful and beautiful data visualizations.
data
javascript
programming
tools
visualization
22 days ago by jpfinley
Morf.js - CSS3 Transitions with custom easing functions
january 2012 by jpfinley
Javascript work-around for hardware accelerated CSS3 transitions with custom easing functions.
animation
css
css3
javascript
easing
math
january 2012 by jpfinley
A Quick Look Into The Math Of Animations With JavaScript - Smashing Coding
october 2011 by jpfinley
There is a lot of math in the visual things we do, even if we don’t realize it. If you want to make something look natural and move naturally, you need to add a bit of physics and rounding to it. Nature doesn’t work in right angles or linear acceleration. This is why zombies in movies are so creepy. This was covered here before in relation to CSS animation, but today let’s go a bit deeper and look at the simple math behind the smooth looks.
animation
javascript
math
js
easing
october 2011 by jpfinley
About « PhoneGap
may 2011 by jpfinley
PhoneGap is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores.
css
javascript
mobile
framework
programming
web
may 2011 by jpfinley
HOWTO: Native iPhone/iPad apps in JavaScript
february 2011 by jpfinley
In this article, I'll explain how to:
strip away the browser chrome (the url bar and button bar);
prevent viewport scrolling and scaling;
respond to multi-touch and gesture events;
use webkit CSS to get the iPhone OS look and feel;
cache the app so it runs without internet access;
get a custom icon on the home screen; and
have a splash screen load at the start.
apple
html5
ipad
iphone
javascript
strip away the browser chrome (the url bar and button bar);
prevent viewport scrolling and scaling;
respond to multi-touch and gesture events;
use webkit CSS to get the iPhone OS look and feel;
cache the app so it runs without internet access;
get a custom icon on the home screen; and
have a splash screen load at the start.
february 2011 by jpfinley
Initializr - Start your HTML5 project in 15 seconds!
february 2011 by jpfinley
Initializr is a simple tool to help you getting started with an HTML5 project. It is built on HTML5 Boilerplate, a powerful HTML5 template created by Paul Irish and Divya Manian. Initializr will generate for you a clean customizable template based on Boilerplate with just what you need to start.
css
html5
javascript
template
february 2011 by jpfinley
My JS1K Demo - The Making Of | Acko.net - Steven Wittens
august 2010 by jpfinley
A nice little rundown of a JS1K demo.
canvas
demoscene
javascript
js
animation
august 2010 by jpfinley
Old School Color Cycling with HTML5 | EffectGames.com
july 2010 by jpfinley
DAMN. 90s-era color cycling with JavaScript.
html
html5
javascript
games
colorcycling
animation
art
color
lucasarts
july 2010 by jpfinley
EffectGames.com
july 2010 by jpfinley
Free online tools for building, sharing, and playing your own browser-based games.
games
web
html5
javascript
july 2010 by jpfinley
JavaScript InfoVis Toolkit
july 2010 by jpfinley
The JavaScript InfoVis Toolkit provides tools for creating Interactive Data Visualizations for the Web.
javascript
data
infovis
visualization
july 2010 by jpfinley
Interactive mapping with HTML5, JavaScript, and Canvas
june 2010 by jpfinley
Part 1: Loading, projecting, and drawing geodata
I’m getting into more canvas and JavaScript for interactive mapping. Much of the Flash/ActionScript work I’ve written or come to rely upon is directly portable to JS/canvas. What’s missing is a sweet RIA framework and IDE for the kind of development Flash and Flex have made possible for years.
Luckily it’s not hard to roll our own interactive web map using web standard technologies. In this post I’m just showing off the basics: dynamically loading geodata, projecting it client-side, and rendering to the canvas element.
Hopefully the above map shows up for you. It’s loaded into this blog post with dynamic KML data, projected using the Proj4js library, and drawn onto HTML’s canvas element using JavaScript. You can check out the P.O.C. on a separate page.
Loading geographic data
It all starts with data. Points, polylines, or polygons — typically defined by latitude/longitude coordinates. Your data may be in a CSV file or in a database. For a simple interactive web map it’s best if it’s in a common GIS file format, like the Shapefile or KML.
These days, it’s not too hard to load a geographic layer on top of a web map — using Google Maps or OpenLayers, say. But since we’re looking down the road to interactivity, custom projections, and thematic mapping, it’s best to roll our own. Luckily, getting the data in is pretty easy.
In ActionScript I would use Edwin van Rijkom’s ESRI SHP parser, my own E00 parser, or some simple custom methods I’ve written to load in KML documents. Tom Carden of Stamen has done some great work porting the AS3 SHP library to JavaScript, with additional classes and methods to allow basic layering, panning, and zooming.
Carden’s classes are great; for demo purposes, and to keep this as lightweight as possible, I’ve just written a quick JavaScript method to grab what I need from a KML document:
$.get( "data/kml/generalized_african_countries.kml", function( xml ) {
var features = new Array();
$( xml ).find( 'Placemark' ).each( function() {
var rings = new Array();
$( this ).find( 'outerBoundaryIs' ).each( function() {
var ring = new Array();
var coordsText = $( this ).find( 'coordinates' ).text();
var coordStrings = coordsText.split( ' ' );
for ( var coordText in coordStrings ) {
var coordinate = new Array();
var coordSplit = coordStrings[ coordText ].split( ',' );
for ( var coordInd in coordSplit ) coordinate.push( Number( coordSplit[ coordInd ] ) );
ring.push( coordinate );
}
rings.push( ring );
} );
features.push( rings );
} );
/* feature coordinates all loaded -- now do something with them */
} );
You’ll notice a bit of jQuery in there. And you’ll also notice that it grabs only coordinate data and works only for polygons. But it produces an array of feature coordinates, which is an array of ring coordinates, which is an array of lat/long coordinates, which is all we need for the current application.
Projecting geographic data
One of my biggest beefs with the typical online map providers is that they’re all rendered in a Mercator projection. No problem for most purposes (and great for producing those 90 degree road intersections), but not so great for country-level mapping and bad for many thematic mapping pursuits. That’s one reason we’re rolling our own here.
PROJ.4 is a generally sweet projections library, originally written in C by Gerald Evenden then of the USGS. It’s been ported to JavaScript as Proj4js. To use it you just have to define source and a dest objects:
Proj4js.defs[ 'albersEqualArea_Africa' ] = '+title= albers_AFR\
+proj=aea\
+lat_1=20\
+lat_2=-23\
+lat_0=0\
+lon_0=25\
+x_0=0\
+y_0=0\
+ellps=WGS84\
+datum=WGS84\
+units=m\
+no_defs';
var source = new Proj4js.Proj( 'WGS:84' );
var dest = new Proj4js.Proj( 'albersEqualArea_Africa' );
And thereafter you can call
Proj4js.transform( source, dest, pt );
where pt is any object with x and y properties. So all coordinates gathered from the KML above can be run through the Proj4js.transform() method, in this case applying a custom Albers Equal Area projection (proj=aea) for the African continent.
Drawing geographic data on the canvas element
The results of the above can be easily rendered to HTML’s canvas element using JavaScript. I’m used to ActionScript’s Graphics class, and its assorted vector drawing methods. Of course, given the common ECMAScript heritage, the JS methods are nearly identical. So the projected linework is rendered thusly:
function drawPolygonFeatures( features, minX, maxX, minY, maxY )
{
var c_canvas = document.getElementById( "map" );
var context = c_canvas.getContext("2d");
var multiFactor = Math.min( c_canvas.width / ( maxX - minX ), c_canvas.height / ( maxY - minY ) );
var x = 0; var y = 0;
for ( var featureNum in features ) {
for ( var ringNum in features[ featureNum ] ) {
var ring = features[ featureNum ][ ringNum ];
context.moveTo( ( ring[ 0 ][ 0 ] - minX ) * multiFactor, c_canvas.height - ( ring[ 0 ][ 1 ] - minY ) * multiFactor );
for ( var coordNum = 1; coordNum < ring.length; coordNum++ ) {
x = ( ring[ coordNum ][ 0 ] - minX ) * multiFactor;
y = c_canvas.height - ( ring[ coordNum ][ 1 ] - minY ) * multiFactor;
context.lineTo( x, y );
}
}
}
context.shadowOffsetX = context.shadowOffsetY = 3;
context.shadowBlur = 4;
context.shadowColor = 'rgba(0, 0, 0, 0.5)';
context.fillStyle = "#0099cc";
context.fill();
context.shadowOffsetX = context.shadowOffsetY = context.shadowBlur = 0;
context.strokeStyle = "#fff";
context.stroke();
}
That method’s made a bit longer by that bitchin’ drop shadow (sorry Firefox, but you Konqueror folks should be cool). See above, or the P.O.C. on a separate page.
Up next
So far this has been pretty sweet: we’ve loaded coordinate data dynamically, projected it, and drawn it to the canvas element. But it hasn’t exactly lived up to the “interactive” part of the title. Next time I hope to get going on panning and zooming, feature mouse-over, and perhaps even attribute loading and thematic mapping.
Uncategorized
canvas
code
flash
howto
html5
javascript
jquery
kml
mapping
proj4
projections
w3c
web_standards
from google
I’m getting into more canvas and JavaScript for interactive mapping. Much of the Flash/ActionScript work I’ve written or come to rely upon is directly portable to JS/canvas. What’s missing is a sweet RIA framework and IDE for the kind of development Flash and Flex have made possible for years.
Luckily it’s not hard to roll our own interactive web map using web standard technologies. In this post I’m just showing off the basics: dynamically loading geodata, projecting it client-side, and rendering to the canvas element.
Hopefully the above map shows up for you. It’s loaded into this blog post with dynamic KML data, projected using the Proj4js library, and drawn onto HTML’s canvas element using JavaScript. You can check out the P.O.C. on a separate page.
Loading geographic data
It all starts with data. Points, polylines, or polygons — typically defined by latitude/longitude coordinates. Your data may be in a CSV file or in a database. For a simple interactive web map it’s best if it’s in a common GIS file format, like the Shapefile or KML.
These days, it’s not too hard to load a geographic layer on top of a web map — using Google Maps or OpenLayers, say. But since we’re looking down the road to interactivity, custom projections, and thematic mapping, it’s best to roll our own. Luckily, getting the data in is pretty easy.
In ActionScript I would use Edwin van Rijkom’s ESRI SHP parser, my own E00 parser, or some simple custom methods I’ve written to load in KML documents. Tom Carden of Stamen has done some great work porting the AS3 SHP library to JavaScript, with additional classes and methods to allow basic layering, panning, and zooming.
Carden’s classes are great; for demo purposes, and to keep this as lightweight as possible, I’ve just written a quick JavaScript method to grab what I need from a KML document:
$.get( "data/kml/generalized_african_countries.kml", function( xml ) {
var features = new Array();
$( xml ).find( 'Placemark' ).each( function() {
var rings = new Array();
$( this ).find( 'outerBoundaryIs' ).each( function() {
var ring = new Array();
var coordsText = $( this ).find( 'coordinates' ).text();
var coordStrings = coordsText.split( ' ' );
for ( var coordText in coordStrings ) {
var coordinate = new Array();
var coordSplit = coordStrings[ coordText ].split( ',' );
for ( var coordInd in coordSplit ) coordinate.push( Number( coordSplit[ coordInd ] ) );
ring.push( coordinate );
}
rings.push( ring );
} );
features.push( rings );
} );
/* feature coordinates all loaded -- now do something with them */
} );
You’ll notice a bit of jQuery in there. And you’ll also notice that it grabs only coordinate data and works only for polygons. But it produces an array of feature coordinates, which is an array of ring coordinates, which is an array of lat/long coordinates, which is all we need for the current application.
Projecting geographic data
One of my biggest beefs with the typical online map providers is that they’re all rendered in a Mercator projection. No problem for most purposes (and great for producing those 90 degree road intersections), but not so great for country-level mapping and bad for many thematic mapping pursuits. That’s one reason we’re rolling our own here.
PROJ.4 is a generally sweet projections library, originally written in C by Gerald Evenden then of the USGS. It’s been ported to JavaScript as Proj4js. To use it you just have to define source and a dest objects:
Proj4js.defs[ 'albersEqualArea_Africa' ] = '+title= albers_AFR\
+proj=aea\
+lat_1=20\
+lat_2=-23\
+lat_0=0\
+lon_0=25\
+x_0=0\
+y_0=0\
+ellps=WGS84\
+datum=WGS84\
+units=m\
+no_defs';
var source = new Proj4js.Proj( 'WGS:84' );
var dest = new Proj4js.Proj( 'albersEqualArea_Africa' );
And thereafter you can call
Proj4js.transform( source, dest, pt );
where pt is any object with x and y properties. So all coordinates gathered from the KML above can be run through the Proj4js.transform() method, in this case applying a custom Albers Equal Area projection (proj=aea) for the African continent.
Drawing geographic data on the canvas element
The results of the above can be easily rendered to HTML’s canvas element using JavaScript. I’m used to ActionScript’s Graphics class, and its assorted vector drawing methods. Of course, given the common ECMAScript heritage, the JS methods are nearly identical. So the projected linework is rendered thusly:
function drawPolygonFeatures( features, minX, maxX, minY, maxY )
{
var c_canvas = document.getElementById( "map" );
var context = c_canvas.getContext("2d");
var multiFactor = Math.min( c_canvas.width / ( maxX - minX ), c_canvas.height / ( maxY - minY ) );
var x = 0; var y = 0;
for ( var featureNum in features ) {
for ( var ringNum in features[ featureNum ] ) {
var ring = features[ featureNum ][ ringNum ];
context.moveTo( ( ring[ 0 ][ 0 ] - minX ) * multiFactor, c_canvas.height - ( ring[ 0 ][ 1 ] - minY ) * multiFactor );
for ( var coordNum = 1; coordNum < ring.length; coordNum++ ) {
x = ( ring[ coordNum ][ 0 ] - minX ) * multiFactor;
y = c_canvas.height - ( ring[ coordNum ][ 1 ] - minY ) * multiFactor;
context.lineTo( x, y );
}
}
}
context.shadowOffsetX = context.shadowOffsetY = 3;
context.shadowBlur = 4;
context.shadowColor = 'rgba(0, 0, 0, 0.5)';
context.fillStyle = "#0099cc";
context.fill();
context.shadowOffsetX = context.shadowOffsetY = context.shadowBlur = 0;
context.strokeStyle = "#fff";
context.stroke();
}
That method’s made a bit longer by that bitchin’ drop shadow (sorry Firefox, but you Konqueror folks should be cool). See above, or the P.O.C. on a separate page.
Up next
So far this has been pretty sweet: we’ve loaded coordinate data dynamically, projected it, and drawn it to the canvas element. But it hasn’t exactly lived up to the “interactive” part of the title. Next time I hope to get going on panning and zooming, feature mouse-over, and perhaps even attribute loading and thematic mapping.
june 2010 by jpfinley
Protovis
january 2010 by jpfinley
JavaScript-based information visualization
javascript
protovis
infographics
visualization
data
january 2010 by jpfinley
Chicago Deep Dish
october 2009 by jpfinley
For those who couldn’t be there, and for those who were there and seek to savor the memories, here is An Event Apart Chicago, all wrapped up in a pretty bow:
AEA Chicago – official photo set
By John Morrison, subism studios llc. See also (and contribute to) An Event Apart Chicago 2009 Pool, a user group on Flickr.
A Feed Apart Chicago
Live tweeting from the show, captured forever and still being updated. Includes complete blow-by-blow from Whitney Hess.
Luke W’s Notes on the Show
Smart note-taking by Luke Wroblewski, design lead for Yahoo!, frequent AEA speaker, and author of Web Form Design: Filling in the Blanks (Rosenfeld Media, 2008):
Jeffrey Zeldman: A Site Redesign
Jason Santa Maria: Thinking Small
Kristina Halvorson: Content First
Dan Brown: Concept Models -A Tool for Planning Websites
Whitney Hess: DIY UX -Give Your Users an Upgrade
Andy Clarke: Walls Come Tumbling Down
Eric Meyer: JavaScript Will Save Us All (not captured)
Aaron Gustafson: Using CSS3 Today with eCSStender (not captured)
Simon Willison: Building Things Fast
Luke Wroblewski: Web Form Design in Action (download slides)
Dan Rubin: Designing Virtual Realism
Dan Cederholm: Progressive Enrichment With CSS3 (not captured)
Three years of An Event Apart Presentations
Note: Comment posting here is a bit wonky at the moment. We are investigating the cause. Normal commenting has been restored. Thank you, Noel Jackson.
Short URL: zeldman.com/?p=2695
A_List_Apart
An_Event_Apart
Appearances
Authoring
Browsers
CSS
Career
Chicago
Code
Community
Compatibility
DOM
Design
Education
Fonts
Formats
HTML
HTML5
Happy_Cog™
Information_architecture
Jason_Santa_Maria
Markup
Real_type_on_the_web
Scripting
Search
Standards
State_of_the_Web
architecture
art_direction
bugs
cities
conferences
content
content_strategy
creativity
development
downloads
editorial
engagement
eric_meyer
events
flickr
glamorous
industry
javascript
photography
social_networking
speaking
spec
from google
AEA Chicago – official photo set
By John Morrison, subism studios llc. See also (and contribute to) An Event Apart Chicago 2009 Pool, a user group on Flickr.
A Feed Apart Chicago
Live tweeting from the show, captured forever and still being updated. Includes complete blow-by-blow from Whitney Hess.
Luke W’s Notes on the Show
Smart note-taking by Luke Wroblewski, design lead for Yahoo!, frequent AEA speaker, and author of Web Form Design: Filling in the Blanks (Rosenfeld Media, 2008):
Jeffrey Zeldman: A Site Redesign
Jason Santa Maria: Thinking Small
Kristina Halvorson: Content First
Dan Brown: Concept Models -A Tool for Planning Websites
Whitney Hess: DIY UX -Give Your Users an Upgrade
Andy Clarke: Walls Come Tumbling Down
Eric Meyer: JavaScript Will Save Us All (not captured)
Aaron Gustafson: Using CSS3 Today with eCSStender (not captured)
Simon Willison: Building Things Fast
Luke Wroblewski: Web Form Design in Action (download slides)
Dan Rubin: Designing Virtual Realism
Dan Cederholm: Progressive Enrichment With CSS3 (not captured)
Three years of An Event Apart Presentations
Note: Comment posting here is a bit wonky at the moment. We are investigating the cause. Normal commenting has been restored. Thank you, Noel Jackson.
Short URL: zeldman.com/?p=2695
october 2009 by jpfinley
Prototype Window Class : Introduction
december 2007 by jpfinley
This javascript class allows you to add window in a HTML page.
ajax
javascript
prototype
window
december 2007 by jpfinley
calendardateselect - Google Code
august 2007 by jpfinley
Calendar Widget
calendar
javascript
rubyonrails
rails
ajax
august 2007 by jpfinley
Syncotype Your Baselines — RobGoodlatte.com
august 2007 by jpfinley
I wrote a simple bookmarklet script that overlays a baseline grid atop everything on the page you’re viewing.
typography
design
grid
css
javascript
august 2007 by jpfinley
Sneaky Abstractions: JavaScript Eye for the Ruby Guy
august 2007 by jpfinley
This article is an introduction to JavaScript for those who already know Ruby.
javascript
ruby
so
august 2007 by jpfinley
SIMILE Project
august 2007 by jpfinley
SIMILE is focused on developing robust, open source tools based on Semantic Web technologies that improve access, management and reuse among digital assets.
ajax
web
javascript
information
semanticweb
semantic
tool
application
software
august 2007 by jpfinley
You think you know (JavaScript) but you have no idea
august 2007 by jpfinley
A series of excellent presentations held by Douglas Crockford from Yahoo!
javascript
video
software
code
programming
development
tutorial
august 2007 by jpfinley
YSlow for Firebug
july 2007 by jpfinley
YSlow analyzes web pages and tells you why they're slow based on the rules for high performance web sites.
firefox
performance
yahoo
javascript
july 2007 by jpfinley
YUI Theater: Douglas Crockford, The JavaScript Programming Language » Yahoo! User Interface Blog
january 2007 by jpfinley
In this presentation, which is meant to be the beginning of the three-course sequence (followed by “Theory of the DOM” and then “Advanced JavaScript”), Douglas explores not only the language as it is today but also how the language came to be the
javascript
video
tutorial
yui
january 2007 by jpfinley
Javascript Boot Camp Tutorial
july 2006 by jpfinley
"On Monday I gave a 3-hour tutorial here at O'Reilly OSCON 2006 in Portland. This talk is for everyone who feels their Javascript skills just aren't up to snuff."
javascript
tutorial
programming
july 2006 by jpfinley
Better Living Through Bookmarklets
december 2005 by jpfinley
[JavaScript & DHTML Tutorials]
bookmarklet
javascript
webdev
web
december 2005 by jpfinley
related tags
ajax ⊕ animation ⊕ An_Event_Apart ⊕ Appearances ⊕ apple ⊕ application ⊕ architecture ⊕ art ⊕ art_direction ⊕ audio ⊕ Authoring ⊕ A_List_Apart ⊕ bluff ⊕ bookmarklet ⊕ Browsers ⊕ buckminster_fuller ⊕ bugs ⊕ calendar ⊕ canvas ⊕ Career ⊕ chart ⊕ charting ⊕ charts ⊕ Chicago ⊕ cities ⊕ code ⊕ color ⊕ colorcycling ⊕ Community ⊕ Compatibility ⊕ conferences ⊕ content ⊕ content_strategy ⊕ creativity ⊕ cropper ⊕ css ⊕ css3 ⊕ data ⊕ datavisualization ⊕ demoscene ⊕ design ⊕ development ⊕ DOM ⊕ downloads ⊕ dymaxion ⊕ easing ⊕ editorial ⊕ Education ⊕ engagement ⊕ eric_meyer ⊕ events ⊕ firefox ⊕ flash ⊕ flickr ⊕ Fonts ⊕ Formats ⊕ framework ⊕ games ⊕ geometry ⊕ glamorous ⊕ graph ⊕ grid ⊕ Happy_Cog™ ⊕ howto ⊕ html ⊕ html5 ⊕ icosahedron ⊕ image ⊕ images ⊕ industry ⊕ infographics ⊕ information ⊕ Information_architecture ⊕ infovis ⊕ ipad ⊕ iphone ⊕ Jason_Santa_Maria ⊕ javascript ⊖ jquery ⊕ js ⊕ kml ⊕ last.fm ⊕ library ⊕ lucasarts ⊕ mapping ⊕ Markup ⊕ math ⊕ mobile ⊕ openlayers ⊕ performance ⊕ photo ⊕ photography ⊕ programming ⊕ proj4 ⊕ projections ⊕ prototype ⊕ protovis ⊕ rails ⊕ Real_type_on_the_web ⊕ reference ⊕ ruby ⊕ rubyonrails ⊕ Scripting ⊕ Search ⊕ semantic ⊕ semanticweb ⊕ so ⊕ social_networking ⊕ software ⊕ sparklines ⊕ speaking ⊕ spec ⊕ Standards ⊕ State_of_the_Web ⊕ template ⊕ tool ⊕ tools ⊕ tutorial ⊕ typography ⊕ ui ⊕ Uncategorized ⊕ video ⊕ videoplayer ⊕ visualisation ⊕ visualization ⊕ w3c ⊕ web ⊕ webdev ⊕ web_standards ⊕ window ⊕ yahoo ⊕ yui ⊕Copy this bookmark: