diff --git a/examples/index.html b/examples/index.html index ad9d554..bf503e5 100644 --- a/examples/index.html +++ b/examples/index.html @@ -8,7 +8,7 @@ } -
+ diff --git a/timeline.js b/timeline.js index 75e39ab..874e213 100644 --- a/timeline.js +++ b/timeline.js @@ -1,3 +1,18 @@ +/* Timeline.js + * Author : Phyks (http://phyks.me) + * http://phyks.github.io/timeline.js + + * -------------------------------------------------------------------------------- + * "THE NO-ALCOHOL BEER-WARE LICENSE" (Revision 42): + * Phyks (webmaster@phyks.me) wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff (and you can also do whatever you want + * with this stuff without retaining it, but that's not cool...). If we meet some + * day, and you think this stuff is worth it, you can buy me ak||k===false){k=t}}h.push(q);g.push(p);e.push(l);d.push(k)}h=Math.min.apply(null,h);g=Math.min.apply(null,g);e=Math.max.apply(null,e);d=Math.max.apply(null,d);u=SVG.newCoordinates(h+Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))),h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight)-SVG.newCoordinates(h,h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight);t=SVG.newCoordinates(g+Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))),g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop)-SVG.newCoordinates(g,g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop);if(SVG.grid==="big"||SVG.grid==="both"){SVG.holder.getElementById("grid").setAttribute("width",u);SVG.holder.getElementById("grid").setAttribute("height",t);SVG.holder.getElementById("grid").setAttribute("y",SVG.newCoordinates(Math.floor(g/Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))),g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop));SVG.holder.getElementById("grid").setAttribute("x",SVG.newCoordinates(Math.floor(h/Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))),h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight));SVG.holder.getElementById("grid").querySelector("path").setAttribute("d","M "+u+" 0 L 0 0 0 "+t);if(SVG.grid==="both"){SVG.holder.getElementById("grid").querySelector("rect").setAttribute("width",u);SVG.holder.getElementById("grid").querySelector("rect").setAttribute("height",t)}}if(SVG.grid==="small"||SVG.grid==="both"){u=u/10;t=t/10;SVG.holder.getElementById("smallGrid").setAttribute("width",u);SVG.holder.getElementById("smallGrid").setAttribute("height",t);if(SVG.grid==="small"){SVG.holder.getElementById("smallGrid").setAttribute("y",SVG.newCoordinates(Math.floor(g/Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))),g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop));SVG.holder.getElementById("smallGrid").setAttribute("x",SVG.newCoordinates(Math.floor(h/Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))),h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight))}SVG.holder.getElementById("smallGrid").querySelector("path").setAttribute("d","M "+u+" 0 L 0 0 0 "+t)}if(SVG.x_axis===true){t=SVG.newCoordinates(0,g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop);SVG.axis.setAttribute("y1",t);SVG.axis.setAttribute("y2",t)}var j=new Array();j.minX=h;j.minY=g;j.maxX=e;j.maxY=d;return j};SVG.addGraph=function(e,d){SVG.raw_points[e]={};SVG.raw_points[e].color=d;SVG.raw_points[e].data=new Array();SVG.labels[e]=new Array()};SVG.addPoints=function(e,d){d.sort(function(g,f){if(g.x k||k===false){k=t}}h.push(q);g.push(p);e.push(l);d.push(k)}h=Math.min.apply(null,h);g=Math.min.apply(null,g);e=Math.max.apply(null,e);d=Math.max.apply(null,d);u=SVG.newCoordinates(h+Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))),h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight)-SVG.newCoordinates(h,h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight);t=SVG.newCoordinates(g+Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))),g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop)-SVG.newCoordinates(g,g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop);if(SVG.grid==="big"||SVG.grid==="both"){SVG.holder.getElementById("grid").setAttribute("width",u);SVG.holder.getElementById("grid").setAttribute("height",t);SVG.holder.getElementById("grid").setAttribute("y",SVG.newCoordinates(Math.floor(g/Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))),g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop));SVG.holder.getElementById("grid").setAttribute("x",SVG.newCoordinates(Math.floor(h/Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))),h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight));SVG.holder.getElementById("grid").querySelector("path").setAttribute("d","M "+u+" 0 L 0 0 0 "+t);if(SVG.grid==="both"){SVG.holder.getElementById("grid").querySelector("rect").setAttribute("width",u);SVG.holder.getElementById("grid").querySelector("rect").setAttribute("height",t)}}if(SVG.grid==="small"||SVG.grid==="both"){u=u/10;t=t/10;SVG.holder.getElementById("smallGrid").setAttribute("width",u);SVG.holder.getElementById("smallGrid").setAttribute("height",t);if(SVG.grid==="small"){SVG.holder.getElementById("smallGrid").setAttribute("y",SVG.newCoordinates(Math.floor(g/Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(d-g)/Math.log(10))),g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop));SVG.holder.getElementById("smallGrid").setAttribute("x",SVG.newCoordinates(Math.floor(h/Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))))*Math.pow(10,Math.floor(Math.log(e-h)/Math.log(10))),h,e,SVG.marginLeft,SVG.parent_holder.offsetWidth-SVG.marginRight))}SVG.holder.getElementById("smallGrid").querySelector("path").setAttribute("d","M "+u+" 0 L 0 0 0 "+t)}if(SVG.x_axis===true){t=SVG.newCoordinates(0,g,d,2*SVG.marginBottom,SVG.parent_holder.offsetHeight-SVG.marginTop);SVG.axis.setAttribute("y1",t);SVG.axis.setAttribute("y2",t)}var j=new Array();j.minX=h;j.minY=g;j.maxX=e;j.maxY=d;return j};SVG.addGraph=function(e,d){SVG.raw_points[e]={};SVG.raw_points[e].color=d;SVG.raw_points[e].data=new Array();SVG.labels[e]=new Array()};SVG.addPoints=function(e,d){d.sort(function(g,f){if(g.x