tiny-spark 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tiny-spark.es.js +1 -1
- package/dist/tiny-spark.umd.js +1 -1
- package/package.json +1 -1
package/dist/tiny-spark.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _ = "http://www.w3.org/2000/svg";
|
|
2
2
|
var q = /* @__PURE__ */ ((t) => (t.BAR = "bar", t.LINE = "line", t))(q || {}), g = /* @__PURE__ */ ((t) => (t.ANIMATION = "animation", t.AREA_COLOR = "areaColor", t.CURVE = "curve", t.DATES = "dates", t.ID = "id", t.INDICATOR_COLOR = "indicatorColor", t.INDICATOR_WIDTH = "indicatorWidth", t.LINE_COLOR = "lineColor", t.LINE_THICKNESS = "lineThickness", t.NUMBER_LOCALE = "numberLocale", t.NUMBER_ROUNDING = "numberRounding", t.NUMBER_SHOW_ON = "numberShowOn", t.PLOT_COLOR = "plotColor", t.PLOT_RADIUS = "plotRadius", t.SET = "set", t.HIDE_PLOTS_ABOVE = "hidePlotsAbove", t.SHOW_LAST_VALUE = "showLastValue", t.LAST_VALUE_FONT_SIZE = "lastValueFontSize", t.LAST_VALUE_COLOR = "lastValueColor", t.TYPE = "type", t.TOOLTIP_SMOOTHING = "tooltipSmoothing", t))(g || {}), E = /* @__PURE__ */ ((t) => (t.ANIMATION = "data-animation", t.AREA_COLOR = "data-area-color", t.CURVE = "data-curve", t.DATES = "data-dates", t.ID = "data-id", t.INDICATOR_COLOR = "data-indicator-color", t.INDICATOR_WIDTH = "data-indicator-width", t.LINE_COLOR = "data-line-color", t.LINE_THICKNESS = "data-line-thickness", t.NUMBER_LOCALE = "data-number-locale", t.NUMBER_ROUNDING = "data-number-rounding", t.NUMBER_SHOW_ON = "data-number-show-on", t.PLOT_COLOR = "data-plot-color", t.PLOT_RADIUS = "data-plot-radius", t.SET = "data-set", t.HIDE_PLOTS_ABOVE = "data-hide-plots-above", t.SHOW_LAST_VALUE = "data-show-last-value", t.LAST_VALUE_FONT_SIZE = "data-last-value-font-size", t.LAST_VALUE_COLOR = "data-last-value-color", t.TYPE = "data-type", t.TOOLTIP_SMOOTHING = "data-tooltip-smoothing", t))(E || {});
|
|
3
|
-
const rt = "0.
|
|
3
|
+
const rt = "0.6.1", ot = {
|
|
4
4
|
version: rt
|
|
5
5
|
};
|
|
6
6
|
function st(t) {
|
package/dist/tiny-spark.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function($,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):($=typeof globalThis<"u"?globalThis:$||self,O($.TinySpark={}))})(this,function($){"use strict";const O="http://www.w3.org/2000/svg";var W=(t=>(t.BAR="bar",t.LINE="line",t))(W||{}),c=(t=>(t.ANIMATION="animation",t.AREA_COLOR="areaColor",t.CURVE="curve",t.DATES="dates",t.ID="id",t.INDICATOR_COLOR="indicatorColor",t.INDICATOR_WIDTH="indicatorWidth",t.LINE_COLOR="lineColor",t.LINE_THICKNESS="lineThickness",t.NUMBER_LOCALE="numberLocale",t.NUMBER_ROUNDING="numberRounding",t.NUMBER_SHOW_ON="numberShowOn",t.PLOT_COLOR="plotColor",t.PLOT_RADIUS="plotRadius",t.SET="set",t.HIDE_PLOTS_ABOVE="hidePlotsAbove",t.SHOW_LAST_VALUE="showLastValue",t.LAST_VALUE_FONT_SIZE="lastValueFontSize",t.LAST_VALUE_COLOR="lastValueColor",t.TYPE="type",t.TOOLTIP_SMOOTHING="tooltipSmoothing",t))(c||{}),j=(t=>(t.ANIMATION="data-animation",t.AREA_COLOR="data-area-color",t.CURVE="data-curve",t.DATES="data-dates",t.ID="data-id",t.INDICATOR_COLOR="data-indicator-color",t.INDICATOR_WIDTH="data-indicator-width",t.LINE_COLOR="data-line-color",t.LINE_THICKNESS="data-line-thickness",t.NUMBER_LOCALE="data-number-locale",t.NUMBER_ROUNDING="data-number-rounding",t.NUMBER_SHOW_ON="data-number-show-on",t.PLOT_COLOR="data-plot-color",t.PLOT_RADIUS="data-plot-radius",t.SET="data-set",t.HIDE_PLOTS_ABOVE="data-hide-plots-above",t.SHOW_LAST_VALUE="data-show-last-value",t.LAST_VALUE_FONT_SIZE="data-last-value-font-size",t.LAST_VALUE_COLOR="data-last-value-color",t.TYPE="data-type",t.TOOLTIP_SMOOTHING="data-tooltip-smoothing",t))(j||{});const it={version:"0.
|
|
1
|
+
(function($,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):($=typeof globalThis<"u"?globalThis:$||self,O($.TinySpark={}))})(this,function($){"use strict";const O="http://www.w3.org/2000/svg";var W=(t=>(t.BAR="bar",t.LINE="line",t))(W||{}),c=(t=>(t.ANIMATION="animation",t.AREA_COLOR="areaColor",t.CURVE="curve",t.DATES="dates",t.ID="id",t.INDICATOR_COLOR="indicatorColor",t.INDICATOR_WIDTH="indicatorWidth",t.LINE_COLOR="lineColor",t.LINE_THICKNESS="lineThickness",t.NUMBER_LOCALE="numberLocale",t.NUMBER_ROUNDING="numberRounding",t.NUMBER_SHOW_ON="numberShowOn",t.PLOT_COLOR="plotColor",t.PLOT_RADIUS="plotRadius",t.SET="set",t.HIDE_PLOTS_ABOVE="hidePlotsAbove",t.SHOW_LAST_VALUE="showLastValue",t.LAST_VALUE_FONT_SIZE="lastValueFontSize",t.LAST_VALUE_COLOR="lastValueColor",t.TYPE="type",t.TOOLTIP_SMOOTHING="tooltipSmoothing",t))(c||{}),j=(t=>(t.ANIMATION="data-animation",t.AREA_COLOR="data-area-color",t.CURVE="data-curve",t.DATES="data-dates",t.ID="data-id",t.INDICATOR_COLOR="data-indicator-color",t.INDICATOR_WIDTH="data-indicator-width",t.LINE_COLOR="data-line-color",t.LINE_THICKNESS="data-line-thickness",t.NUMBER_LOCALE="data-number-locale",t.NUMBER_ROUNDING="data-number-rounding",t.NUMBER_SHOW_ON="data-number-show-on",t.PLOT_COLOR="data-plot-color",t.PLOT_RADIUS="data-plot-radius",t.SET="data-set",t.HIDE_PLOTS_ABOVE="data-hide-plots-above",t.SHOW_LAST_VALUE="data-show-last-value",t.LAST_VALUE_FONT_SIZE="data-last-value-font-size",t.LAST_VALUE_COLOR="data-last-value-color",t.TYPE="data-type",t.TOOLTIP_SMOOTHING="data-tooltip-smoothing",t))(j||{});const it={version:"0.6.1"};function ot(t){const{width:i,height:n}=t.parentElement.getBoundingClientRect(),a={width:300,height:100},l=String(u(t,c.SHOW_LAST_VALUE,"false"))==="true",e=q(t),b=e&&e.length?e.at(-1):null;let o=0;if(!(t.dataset.type&&t.dataset.type==="bar")&&l&&![null,void 0].includes(b)){const r=Number(String(u(t,c.NUMBER_ROUNDING,0)));o=6+b.toFixed(r).length*(Number(u(t,c.LAST_VALUE_FONT_SIZE,12))/2)}const N=`0 0 ${(i||a.width)+o} ${n||a.height}`,h=document.createElementNS(O,"svg"),_=t.dataset.id;h.id=_,h.setAttribute("viewBox",N),h.style.width="100%",h.style.height="100%";const L=document.createElementNS(O,"desc");return L.setAttribute("aria-hidden","true"),L.innerHTML=`Composed with tiny-spark v${it.version}`,h.appendChild(L),{svg:h,svgId:_,width:i||a.width,height:n||a.height,viewBox:N}}function C(t,i=0){return isNaN(t)?i:t}function z(t){let i=[];for(let n=0;n<t.length;n+=1)i.push(`${C(t[n].x)},${C(t[n].y)} `);return i.join(" ").trim()}function D(t){if(t.length<1)return"0,0";const i=t.length-1,n=[`${C(t[0].x)},${C(t[0].y)}`],a=[],l=[],e=[],b=[];for(let o=0;o<i;o+=1)a[o]=t[o+1].x-t[o].x,l[o]=t[o+1].y-t[o].y,e[o]=l[o]/a[o];b[0]=e[0],b[i]=e[i-1];for(let o=1;o<i;o+=1)if(e[o-1]*e[o]<=0)b[o]=0;else{const S=2*e[o-1]*e[o]/(e[o-1]+e[o]);b[o]=S}for(let o=0;o<i;o+=1){const S=t[o].x,I=t[o].y,N=t[o+1].x,h=t[o+1].y,_=b[o],L=b[o+1],r=S+(N-S)/3,x=I+_*(N-S)/3,P=N-(N-S)/3,k=h-L*(N-S)/3;n.push(`C ${C(r)},${C(x)} ${C(P)},${C(k)} ${C(N)},${C(h)}`)}return n.join(" ")}function rt(t,i=1e3,n){t.style.opacity="1";const a=t.getTotalLength();t.style.strokeDasharray=String(a),t.style.strokeDashoffset=String(a),t.getBoundingClientRect(),t.style.transition=`stroke-dashoffset ${i}ms ease-in-out`,t.style.strokeDashoffset="0",t.addEventListener("transitionend",function l(){t.style.transition="",t.removeEventListener("transitionend",l),n&&n()})}function st(t,i,n=1e3){i.style.opacity="1";const a=i.getBBox(),l=a.width,e=document.createElementNS("http://www.w3.org/2000/svg","clipPath"),b="clip-"+Math.random().toString(36).substr(2,9);e.setAttribute("id",b);const o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("x",a.x.toString()),o.setAttribute("y",a.y.toString()),o.setAttribute("width","0"),o.setAttribute("height",a.height.toString()),e.appendChild(o);let S=t.querySelector("defs");S||(S=document.createElementNS("http://www.w3.org/2000/svg","defs"),t.insertBefore(S,t.firstChild)),S.appendChild(e),i.setAttribute("clip-path",`url(#${b})`),o.style.transition=`width ${n}ms ease-out`,o.getBoundingClientRect(),o.setAttribute("width",l.toString()),o.addEventListener("transitionend",function I(){i.removeAttribute("clip-path"),e.parentNode&&e.parentNode.removeChild(e),o.removeEventListener("transitionend",I)})}function at(){return document.querySelectorAll(".tiny-spark")}function K(t,i){return Object.keys(t.dataset).includes(i)}function u(t,i,n){return K(t,i)?t.dataset[i]:n}function lt(t){if(!t)return{color:"#1A1A1A",backgroundColor:"#FFFFFF"};const i=window.getComputedStyle(t),n=i.getPropertyValue("color")||"#1A1A1A",a=i.getPropertyValue("background-color"),l=i.getPropertyValue("background");return{color:n,backgroundColor:a||l||"#FFFFFF"}}function Z(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const i=Math.random()*16|0;return(t=="x"?i:i&3|8).toString(16)})}function q(t){const i=t.getAttribute("data-set");if(!i)return[];try{const n=JSON.parse(i);return Array.isArray(n)&&n.every(a=>typeof a=="number"||[null,void 0].includes(a))?n:(console.warn("data-set is not an array of numbers."),[])}catch(n){return console.error("Error parsing data-set:",n),[]}}function dt(t){const i=t.getAttribute("data-dates");if(!i)return[];try{const n=JSON.parse(i);return Array.isArray(n)&&n.every(a=>typeof a=="string")?n:(console.warn("data-dates is not an array of strings"),[])}catch(n){return console.error("Error parsing data-dates",n),[]}}function E(t){return{min:Math.min(...t),max:Math.max(...t)}}function J(){return new Promise(t=>setTimeout(t,0))}function Q(t,i){const n=String(u(t,c.NUMBER_LOCALE,navigator.language||"en-US")),a=Number(String(u(t,c.NUMBER_ROUNDING,0)));return i.toLocaleString(n,{useGrouping:!0,minimumFractionDigits:a,maximumFractionDigits:a})}function ut(t,i,n){if(!t.createSVGPoint||!t.getScreenCTM)throw new Error("Your browser does not support SVG coordinate transformation.");const a=t.getScreenCTM();if(!a)throw new Error("Cannot obtain the screen CTM.");const l=t.createSVGPoint();l.x=i,l.y=n;const e=l.matrixTransform(a);return{x:e.x,y:e.y}}const H={};function T(t,i,n,a,l){let e=H[a];if(!l){e&&(cancelAnimationFrame(e.frameId),e.frameId=null,e.tool.style.opacity="0");return}const b=i.dataset.type===W.BAR,{x:o,y:S}=ut(t,n.x,b&&!n.isPositive?n.bar.y:n.y);if(!e){const r=document.createElement("div");r.classList.add("tiny-spark-tooltip"),r.setAttribute("id",`tooltip_${a}`),r.setAttribute("role","tooltip"),r.setAttribute("aria-live","polite"),r.style.position="fixed",r.style.pointerEvents="none",r.style.opacity="0",r.style.willChange="top, left",document.body.appendChild(r),e=H[a]={targetX:0,targetY:0,displayX:0,displayY:0,frameId:null,tool:r,width:0,height:0,hasSnapped:!1}}e.tool.setAttribute("aria-hidden","false"),e.tool.innerHTML=`
|
|
2
2
|
<div class="tiny-spark-tooltip-content">
|
|
3
3
|
${n.d?`${n.d}: `:""}${[null,void 0].includes(n.v)?"-":Q(i,Number(n.v))}
|
|
4
4
|
</div>
|
package/package.json
CHANGED