Page MenuHomePhabricator

D536.id1931.diff
No OneTemporary

D536.id1931.diff

diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-node_modules/
\ No newline at end of file
+node_modules/
+dist/
\ No newline at end of file
diff --git a/dist/graph.js b/dist/graph.js
--- a/dist/graph.js
+++ b/dist/graph.js
@@ -1 +1 @@
-var Graph;Graph=(()=>{var t={304:()=>{depend("graph",[],(function(){var t=function(t,n,e){this.x=t,this.y=n,this.id=e},n=function(){this.points=[]};n.prototype={put:function(n,e,i){this.points.push(new t(n,e,i))},minX:function(){return Math.min.apply(null,this.points.map((function(t){return t.x})))},maxX:function(){return Math.max.apply(null,this.points.map((function(t){return t.x})))},minY:function(){return Math.min.apply(null,this.points.map((function(t){return t.y})))},maxY:function(){return Math.max.apply(null,this.points.map((function(t){return t.y})))},constraints:function(){return{x:[this.minX(),this.maxX()],y:[this.minY(),this.maxY()]}}};var e=function(t){this.constraints=t};e.prototype={locate:function(t){return{x:(t.x-this.constraints.x[0])/(this.constraints.x[1]-this.constraints.x[0]),y:(t.y-this.constraints.y[0])/(this.constraints.y[1]-this.constraints.y[0])*.9+.05}}};var i=function(t){this.target=t,this.commands=[]};return i.prototype={moveTo:function(t,n){var e=parseInt(t),i=parseInt(n);return this.commands.push(`M ${e},${i}`),this},lineTo:function(t,n){var e=parseInt(t),i=parseInt(n);return this.commands.push(`L ${e},${i}`),this},close:function(){return this.commands.push("Z"),this},commit:function(){this.target.setAttribute("d",this.commands.join(" "))}},function(o,r,s){for(var a=new n,c=0;c<r.length;c++)a.put(r[c].x,r[c].y,r[c].id);var p=o.appendChild(document.createElementNS("http://www.w3.org/2000/svg","svg"));p.style.display="block",p.style.width="100%",p.style.height="100%";var u=new e(a.constraints()),h=p.appendChild(document.createElementNS("http://www.w3.org/2000/svg","g")),l=new i(h.appendChild(document.createElementNS("http://www.w3.org/2000/svg","path"))),m=new i(h.appendChild(document.createElementNS("http://www.w3.org/2000/svg","path")));!function(t,n){for(c in n)n.hasOwnProperty(c)&&(t[c]||(t[c]=n[c]))}(s||{},{lineWidth:5,lineColor:"#4B9FED",stopColor:"#369BF9",fillColor:"#CAE2F9"}),console.log(s);var d=p.clientWidth,f=p.clientHeight;p.setAttribute("viewBox",`0 0 ${d} ${f}`);var v="#4B9FED",w="#CAE2F9";l.moveTo(0,f),l.target.setAttribute("fill",w),l.target.setAttribute("stroke",w);var y=u.locate(a.points[0]);for(l.lineTo(0,f-y.y*f),c=0;c<a.points.length;c++)y=u.locate(a.points[c]),l.lineTo(y.x*d,f-y.y*f);for(l.lineTo(d,f),l.close(),l.commit(),m.target.setAttribute("fill","none"),m.target.setAttribute("stroke",v),m.target.setAttribute("stroke-width",5),m.moveTo(0,f-u.locate(a.points[0]).y*f),c=0;c<a.points.length;c++)y=u.locate(a.points[c]),m.lineTo(y.x*d,f-y.y*f);m.commit();var g=h.appendChild(document.createElementNS("http://www.w3.org/2000/svg","circle"));g.setAttribute("fill",v),g.setAttribute("r",7),g.setAttribute("opacity",0),o.addEventListener("mousemove",(function(n){var i=this.getBoundingClientRect(),r=new e({x:[i.left,i.left+i.width],y:[i.top,i.top+i.height]}).locate(new t(n.x,n.y)),s=a.points.map((function(t){return{point:t,distance:Math.abs(u.locate(t).x-r.x)}}));s.sort((function(t,n){return t.distance<n.distance?-1:1})),g.setAttribute("cx",u.locate(s[0].point).x*d),g.setAttribute("cy",(1-u.locate(s[0].point).y)*f),g.setAttribute("opacity",1);var c=new CustomEvent("graphover",{detail:{point:s[0].point},bubbles:!1,cancelable:!0});o.dispatchEvent(c)})),o.addEventListener("mouseout",(function(t){g.setAttribute("opacity",0)}))}}))}},n={};return function e(i){if(n[i])return n[i].exports;var o=n[i]={exports:{}};return t[i](o,o.exports,e),o.exports}(304)})();
\ No newline at end of file
+var Graph;Graph=(()=>{"use strict";var t={304:(t,e,n)=>{n.r(e),n.d(e,{default:()=>a,Graph:()=>a});var i=function(t,e,n){this.x=t,this.y=e,this.additional=n},o=function(){this.points=[]};o.prototype={put:function(t,e,n){this.points.push(new i(t,e,n))},minX:function(){return Math.min.apply(null,this.points.map((function(t){return t.x})))},maxX:function(){return Math.max.apply(null,this.points.map((function(t){return t.x})))},minY:function(){return Math.min.apply(null,this.points.map((function(t){return t.y})))},maxY:function(){return Math.max.apply(null,this.points.map((function(t){return t.y})))},constraints:function(){return{x:[this.minX(),this.maxX()],y:[this.minY(),this.maxY()]}}};var r=function(t){this.constraints=t};r.prototype={locate:function(t){return{x:(t.x-this.constraints.x[0])/(this.constraints.x[1]-this.constraints.x[0]),y:(t.y-this.constraints.y[0])/(this.constraints.y[1]-this.constraints.y[0])*.9+.05}}};var s=function(t){this.target=t,this.commands=[]};function a(t,e,n){for(var a=new o,p=0;p<e.length;p++)a.put(e[p].x,e[p].y,e[p].additional);var c=t.appendChild(document.createElementNS("http://www.w3.org/2000/svg","svg"));c.style.display="block",c.style.width="100%",c.style.height="100%";var u=new r(a.constraints()),l=c.appendChild(document.createElementNS("http://www.w3.org/2000/svg","g")),h=new s(l.appendChild(document.createElementNS("http://www.w3.org/2000/svg","path"))),m=new s(l.appendChild(document.createElementNS("http://www.w3.org/2000/svg","path")));!function(t,e){for(p in e)e.hasOwnProperty(p)&&(t[p]||(t[p]=e[p]))}(n||{},{lineWidth:5,lineColor:"#4B9FED",stopColor:"#369BF9",fillColor:"#CAE2F9"});var d=c.clientWidth,f=c.clientHeight;c.setAttribute("viewBox",`0 0 ${d} ${f}`);var y="#4B9FED",v="#CAE2F9";h.moveTo(0,f),h.target.setAttribute("fill",v),h.target.setAttribute("stroke",v);var w=u.locate(a.points[0]);for(h.lineTo(0,f-w.y*f),p=0;p<a.points.length;p++)w=u.locate(a.points[p]),h.lineTo(w.x*d,f-w.y*f);for(h.lineTo(d,f),h.close(),h.commit(),m.target.setAttribute("fill","none"),m.target.setAttribute("stroke",y),m.target.setAttribute("stroke-width",5),m.moveTo(0,f-u.locate(a.points[0]).y*f),p=0;p<a.points.length;p++)w=u.locate(a.points[p]),m.lineTo(w.x*d,f-w.y*f);m.commit();var g=l.appendChild(document.createElementNS("http://www.w3.org/2000/svg","circle"));g.setAttribute("fill",y),g.setAttribute("r",7),g.setAttribute("opacity",0),t.addEventListener("mousemove",(function(e){var n=this.getBoundingClientRect(),o=new r({x:[n.left,n.left+n.width],y:[n.top,n.top+n.height]}).locate(new i(e.x,e.y)),s=a.points.map((function(t){return{point:t,distance:Math.abs(u.locate(t).x-o.x)}}));s.sort((function(t,e){return t.distance<e.distance?-1:1})),g.setAttribute("cx",u.locate(s[0].point).x*d),g.setAttribute("cy",(1-u.locate(s[0].point).y)*f),g.setAttribute("opacity",1);var p=new CustomEvent("graphover",{detail:{point:s[0].point},bubbles:!1,cancelable:!0});t.dispatchEvent(p)})),t.addEventListener("mouseout",(function(t){g.setAttribute("opacity",0)}))}s.prototype={moveTo:function(t,e){var n=parseInt(t),i=parseInt(e);return this.commands.push(`M ${n},${i}`),this},lineTo:function(t,e){var n=parseInt(t),i=parseInt(e);return this.commands.push(`L ${n},${i}`),this},close:function(){return this.commands.push("Z"),this},commit:function(){this.target.setAttribute("d",this.commands.join(" "))}}}},e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}return n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(304)})();
\ No newline at end of file
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -1,8 +1,9 @@
{
"name": "m3w-graph",
- "version": "0.1.0",
+ "version": "0.1.0-alpha1-2",
"description": "Graph library",
- "main": "src/graph.js",
+ "main": "dist/graph.js",
+ "module": "src/graph.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
diff --git a/src/graph.js b/src/graph.js
--- a/src/graph.js
+++ b/src/graph.js
@@ -1,10 +1,10 @@
-var Point = function (x, y, id) {
+var Point = function (x, y, additional) {
this.x = x;
this.y = y;
- this.id = id;
+ this.additional = additional;
};
var Series = function () {
@@ -80,7 +80,7 @@
var series = new Series();
for (var i = 0; i < stops.length; i++) {
- series.put(stops[i].x, stops[i].y, stops[i].id);
+ series.put(stops[i].x, stops[i].y, stops[i].additional);
}
var canvas = container.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'svg'));
@@ -198,4 +198,4 @@
};
-export const Graph;
+export {Graph};

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 14, 4:22 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5963
Default Alt Text
D536.id1931.diff (8 KB)

Event Timeline