diff --git a/examples/quake.html b/examples/quake.html index 8fd8cb5..d8b5522 100644 --- a/examples/quake.html +++ b/examples/quake.html @@ -95,16 +95,19 @@ // Create a color scale for the various earthquake magnitudes; the // minimum magnitude in our data set is 2.5. var colors = d3.scale.pow() - .exponent(2) - .domain([2, 6,10]) - .range(['rgb(255,255,204)', 'rgb(253,141,60)','rgb(128,0,38)']) - .clamp(true); + .exponent(3) + .domain([2, 6, 10]) + .range(['yellow', 'orange', 'red']); // Also create a scale for mapping magnitudes to ping angle sizes var angles = d3.scale.pow() - .exponent(2) + .exponent(3) .domain([2.5, 10]) - .range([0.5, 15]) - .clamp(true); + .range([0.5, 15]); + // And finally, a scale for mapping magnitudes to ping TTLs + var ttls = d3.scale.pow() + .exponent(3) + .domain([2.5, 10]) + .range([2000, 5000]); // Create a key to show the magnitudes and their colors d3.select('#magnitudes').selectAll('li') @@ -199,7 +202,8 @@ // Here we use the `angles` and `colors` scales we built earlier // to convert magnitudes to appropriate angles and colors. angle: angles(ping.mag), - color: colors(ping.mag) + color: colors(ping.mag), + ttl: ttls(ping.mag) }); } diff --git a/examples/quake/quake.js b/examples/quake/quake.js index c6fb4f9..0b5f8e8 100644 --- a/examples/quake/quake.js +++ b/examples/quake/quake.js @@ -32,16 +32,19 @@ // Create a color scale for the various earthquake magnitudes; the // minimum magnitude in our data set is 2.5. var colors = d3.scale.pow() - .exponent(2) - .domain([2, 6,10]) - .range(['rgb(255,255,204)', 'rgb(253,141,60)','rgb(128,0,38)']) - .clamp(true); + .exponent(3) + .domain([2, 6, 10]) + .range(['yellow', 'orange', 'red']); // Also create a scale for mapping magnitudes to ping angle sizes var angles = d3.scale.pow() - .exponent(2) + .exponent(3) .domain([2.5, 10]) - .range([0.5, 15]) - .clamp(true); + .range([0.5, 15]); + // And finally, a scale for mapping magnitudes to ping TTLs + var ttls = d3.scale.pow() + .exponent(3) + .domain([2.5, 10]) + .range([2000, 5000]); // Create a key to show the magnitudes and their colors d3.select('#magnitudes').selectAll('li') @@ -136,7 +139,8 @@ // Here we use the `angles` and `colors` scales we built earlier // to convert magnitudes to appropriate angles and colors. angle: angles(ping.mag), - color: colors(ping.mag) + color: colors(ping.mag), + ttl: ttls(ping.mag) }); } diff --git a/js/lib/planetaryjs.min.js b/js/lib/planetaryjs.min.js index e8636c4..66417ed 100644 --- a/js/lib/planetaryjs.min.js +++ b/js/lib/planetaryjs.min.js @@ -1,2 +1,2 @@ -/*! Planetary.js 0.2.2 | (c) 2013 Brandon Tilley | Released under MIT License */ +/*! Planetary.js 0.3.0 | (c) 2013 Brandon Tilley | Released under MIT License */ !function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n=o.onInit.length?r(n,t,o):i(l)};i(l)}else r(n,t,o)},u=function(n,t,o,e){l(n,o),n.canvas=t,n.context=t.getContext("2d"),a(n,t,e)},c={plugins:{},noConflict:function(){return o.planetaryjs=e,c},loadPlugin:function(n){i.push(n)},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={plugins:{},draw:function(n){u(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n){t.push(n)},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return c.plugins.topojson=function(t){return function(o){o.plugins.topojson={},o.onInit(function(e){if(t.world)o.plugins.topojson.world=t.world,setTimeout(e,0);else{var i=t.file||"world-110m.json";n.json(i,function(n,t){if(n)throw new Error("Could not load JSON "+i);o.plugins.topojson.world=t,e()})}})}},c.plugins.oceans=function(n){return function(t){t.onDraw(function(){t.withSavedContext(function(o){o.beginPath(),t.path.context(o)({type:"Sphere"}),o.fillStyle=n.fill||"black",o.fill()})})}},c.plugins.land=function(n){return function(o){var e=null;o.onInit(function(){var n=o.plugins.topojson.world;e=t.feature(n,n.objects.land)}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),0!=n.fill&&(t.fillStyle=n.fill||"white",t.fill()),n.stroke&&(n.lineWidth&&(t.lineWidth=n.lineWidth),t.strokeStyle=n.stroke,t.stroke())})})}},c.plugins.borders=function(n){return function(o){var e=null,i={internal:function(n,t){return n.id!==t.id},external:function(n,t){return n.id===t.id},both:function(){return!0}};o.onInit(function(){var r=o.plugins.topojson.world,l=r.objects.countries,a=n.type||"internal";e=t.mesh(r,l,i[a])}),o.onDraw(function(){o.withSavedContext(function(t){t.beginPath(),o.path.context(t)(e),t.strokeStyle=n.stroke||"gray",n.lineWidth&&(t.lineWidth=n.lineWidth),t.stroke()})})}},c.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){c.plugins.topojson(t)(n),c.plugins.oceans(o)(n),c.plugins.land(e)(n),c.plugins.borders(i)(n)}},c.plugins.pings=function(t){var o=[],t=t||{},e=function(n,e,i){var i=i||{};i.color=i.color||t.color||"white",i.angle=i.angle||t.angle||5,i.ttl=i.ttl||t.ttl||2e3;var r={time:new Date,options:i};t.latitudeFirst?(r.lat=n,r.lng=e):(r.lng=n,r.lat=e),o.push(r)},i=function(n,t,e){for(var i=[],l=0;l90&&(i[1]=90),i[1]<-90&&(i[1]=-90),i[0]>=180&&(i[0]-=360),t.projection.rotate(i),l()});n.select(t.canvas).call(o)})}},c}); \ No newline at end of file