@fnando/sparkline
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -212,2 +212,3 @@ var sparkline = | ||
var path = buildElement("path", { | ||
class: "sparkline--line", | ||
d: pathCoords, | ||
@@ -220,2 +221,3 @@ fill: "none" | ||
var fill = buildElement("path", { | ||
class: "sparkline--fill", | ||
d: fillCoords, | ||
@@ -222,0 +224,0 @@ stroke: "none" |
@@ -1,2 +0,2 @@ | ||
var sparkline=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function n(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function i(t,e,r,n){return parseFloat((e-n*e/t+r).toFixed(2))}function a(t){return t.value}function u(t,e){var r=document.createElementNS("http://www.w3.org/2000/svg",t);for(var n in e)r.setAttribute(n,e[n]);return r}function o(t,e,r){if(function(t){[].concat(n(t.querySelectorAll("*"))).forEach(function(e){return t.removeChild(e)})}(t),!(e.length<=1)){r=r||{},"number"==typeof e[0]&&(e=e.map(function(t){return{value:t}}));var o=r.onmousemove,s=r.onmouseout,l="interactive"in r?r.interactive:!!o,c=r.spotRadius||2,f=2*c,p=r.cursorWidth||2,d=parseFloat(t.attributes["stroke-width"].value),v=r.fetch||a,h=e.map(function(t){return v(t)}),x=parseFloat(t.attributes.width.value)-2*f,b=parseFloat(t.attributes.height.value),y=b-2*d-f,m=Math.max.apply(Math,n(h)),A=h.length-1,g=x/A,w=[],k=i(m,y,d+c,h[0]),O="M"+f+" "+k;h.forEach(function(t,r){var n=r*g+f,a=i(m,y,d+c,t);w.push(Object.assign({},e[r],{index:r,x:n,y:a})),O+=" L "+n+" "+a});var C=u("path",{d:O,fill:"none"}),M=u("path",{d:O+" V "+b+" L "+f+" "+b+" Z",stroke:"none"});if(t.appendChild(M),t.appendChild(C),l){var _=u("line",{class:"sparkline--cursor",x1:-1e3,x2:-1e3,y1:0,y2:b,"stroke-width":p}),j=u("circle",{class:"sparkline--spot",cx:-1e3,cy:-1e3,r:c});t.appendChild(_),t.appendChild(j);var E=u("rect",{width:t.attributes.width.value,height:t.attributes.height.value,style:"fill: transparent; stroke: transparent",class:"sparkline--interaction-layer"});t.appendChild(E),E.addEventListener("mouseout",function(t){_.setAttribute("x1",-1e3),_.setAttribute("x2",-1e3),j.setAttribute("cx",-1e3),s&&s(t)}),E.addEventListener("mousemove",function(t){var e=t.offsetX,r=w.find(function(t){return t.x>=e});r||(r=w[A]);var n=w[w.indexOf(r)-1],i=void 0,a=void 0;n?(a=n.x+(r.x-n.x)/2,i=e>=a?r:n):i=r;var u=i.x,s=i.y;j.setAttribute("cx",u),j.setAttribute("cy",s),_.setAttribute("x1",u),_.setAttribute("x2",u),o&&o(t,i)})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.sparkline=o,e.default=o}]); | ||
var sparkline=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function n(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function i(t,e,r,n){return parseFloat((e-n*e/t+r).toFixed(2))}function a(t){return t.value}function u(t,e){var r=document.createElementNS("http://www.w3.org/2000/svg",t);for(var n in e)r.setAttribute(n,e[n]);return r}function o(t,e,r){if(function(t){[].concat(n(t.querySelectorAll("*"))).forEach(function(e){return t.removeChild(e)})}(t),!(e.length<=1)){r=r||{},"number"==typeof e[0]&&(e=e.map(function(t){return{value:t}}));var o=r.onmousemove,s=r.onmouseout,l="interactive"in r?r.interactive:!!o,c=r.spotRadius||2,f=2*c,p=r.cursorWidth||2,d=parseFloat(t.attributes["stroke-width"].value),v=r.fetch||a,h=e.map(function(t){return v(t)}),x=parseFloat(t.attributes.width.value)-2*f,b=parseFloat(t.attributes.height.value),y=b-2*d-f,m=Math.max.apply(Math,n(h)),A=h.length-1,g=x/A,k=[],w=i(m,y,d+c,h[0]),O="M"+f+" "+w;h.forEach(function(t,r){var n=r*g+f,a=i(m,y,d+c,t);k.push(Object.assign({},e[r],{index:r,x:n,y:a})),O+=" L "+n+" "+a});var C=u("path",{class:"sparkline--line",d:O,fill:"none"}),M=u("path",{class:"sparkline--fill",d:O+" V "+b+" L "+f+" "+b+" Z",stroke:"none"});if(t.appendChild(M),t.appendChild(C),l){var _=u("line",{class:"sparkline--cursor",x1:-1e3,x2:-1e3,y1:0,y2:b,"stroke-width":p}),j=u("circle",{class:"sparkline--spot",cx:-1e3,cy:-1e3,r:c});t.appendChild(_),t.appendChild(j);var E=u("rect",{width:t.attributes.width.value,height:t.attributes.height.value,style:"fill: transparent; stroke: transparent",class:"sparkline--interaction-layer"});t.appendChild(E),E.addEventListener("mouseout",function(t){_.setAttribute("x1",-1e3),_.setAttribute("x2",-1e3),j.setAttribute("cx",-1e3),s&&s(t)}),E.addEventListener("mousemove",function(t){var e=t.offsetX,r=k.find(function(t){return t.x>=e});r||(r=k[A]);var n=k[k.indexOf(r)-1],i=void 0,a=void 0;n?(a=n.x+(r.x-n.x)/2,i=e>=a?r:n):i=r;var u=i.x,s=i.y;j.setAttribute("cx",u),j.setAttribute("cy",s),_.setAttribute("x1",u),_.setAttribute("x2",u),o&&o(t,i)})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.sparkline=o,e.default=o}]); | ||
//# sourceMappingURL=sparkline.min.js.map |
{ | ||
"name": "@fnando/sparkline", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "src/sparkline.js", |
@@ -73,2 +73,11 @@ # sparkline | ||
} | ||
/* style fill area and line colors using specific class name */ | ||
.sparkline--fill { | ||
fill: rgba(255, 0, 0, .3); | ||
} | ||
.sparkline--line { | ||
stroke: red; | ||
} | ||
``` | ||
@@ -75,0 +84,0 @@ |
@@ -117,2 +117,3 @@ function getY(max, height, diff, value) { | ||
const path = buildElement("path", { | ||
class: "sparkline--line", | ||
d: pathCoords, | ||
@@ -125,2 +126,3 @@ fill: "none" | ||
const fill = buildElement("path", { | ||
class: "sparkline--fill", | ||
d: fillCoords, | ||
@@ -127,0 +129,0 @@ stroke: "none" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49262
424
120