Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nivo/scales

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nivo/scales - npm Package Compare versions

Comparing version 0.75.0 to 0.76.0

2

dist/nivo-scales.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/uniq"),t=require("lodash/uniqBy"),n=require("lodash/sortBy"),r=require("lodash/last"),a=require("lodash/isDate"),i=require("d3-time-format"),o=require("d3-scale"),u=require("d3-time");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=c(e),d=c(t),l=c(n),f=c(r),m=c(a);function v(){return v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}var p=[function(e){return e.setMilliseconds(0)},function(e){return e.setSeconds(0)},function(e){return e.setMinutes(0)},function(e){return e.setHours(0)},function(e){return e.setDate(1)},function(e){return e.setMonth(0)}],y={millisecond:[],second:p.slice(0,1),minute:p.slice(0,2),hour:p.slice(0,3),day:p.slice(0,4),month:p.slice(0,5),year:p.slice(0,6)},x=function(e){return function(t){return y[e].forEach((function(e){e(t)})),t}},h=function(e){var t=e.format,n=void 0===t?"native":t,r=e.precision,a=void 0===r?"millisecond":r,o=e.useUTC,u=void 0===o||o,c=x(a);return function(e){if(void 0===e)return e;if("native"===n||e instanceof Date)return c(e);var t=u?i.utcParse(n):i.timeParse(n);return c(t(e))}},g=function(e,t,n,r){var a,i,u,c,s=e.min,d=void 0===s?0:s,l=e.max,f=void 0===l?"auto":l,m=e.stacked,v=void 0!==m&&m,p=e.reverse,y=void 0!==p&&p,x=e.clamp,h=void 0!==x&&x,g=e.nice,k=void 0!==g&&g;"auto"===d?a=!0===v?null!=(i=t.minStacked)?i:0:t.min:a=d;"auto"===f?u=!0===v?null!=(c=t.maxStacked)?c:0:t.max:u=f;var T=o.scaleLinear().rangeRound("x"===r?[0,n]:[n,0]).domain(y?[u,a]:[a,u]).clamp(h);return!0===k?T.nice():"number"==typeof k&&T.nice(k),S(T,v)},S=function(e,t){void 0===t&&(t=!1);var n=e;return n.type="linear",n.stacked=t,n},k=function(e,t,n){var r=o.scalePoint().range([0,n]).domain(t.all);return r.type="point",r},T=function(e,t,n,r){var a=e.round,i=void 0===a||a,u=o.scaleBand().range("x"===r?[0,n]:[n,0]).domain(t.all).round(i);return M(u)},M=function(e){var t=e;return t.type="band",t},b=function(e,t,n){var r,a,i=e.format,u=void 0===i?"native":i,c=e.precision,s=void 0===c?"millisecond":c,d=e.min,l=void 0===d?"auto":d,f=e.max,m=void 0===f?"auto":f,v=e.useUTC,p=void 0===v||v,y=e.nice,x=void 0!==y&&y,g=h({format:u,precision:s,useUTC:p});r="auto"===l?g(t.min):"native"!==u?g(l):l,a="auto"===m?g(t.max):"native"!==u?g(m):m;var S=p?o.scaleUtc():o.scaleTime();S.range([0,n]),r&&a&&S.domain([r,a]),!0===x?S.nice():"object"!=typeof x&&"number"!=typeof x||S.nice(x);var k=S;return k.type="time",k.useUTC=p,k},w=function(e,t,n,r){var a,i=e.base,u=void 0===i?10:i,c=e.min,s=void 0===c?"auto":c,d=e.max,l=void 0===d?"auto":d;if(t.all.some((function(e){return 0===e})))throw new Error("a log scale domain must not include or cross zero");var f,m,v=!1;if(t.all.filter((function(e){return null!=e})).forEach((function(e){v||(void 0===a?a=Math.sign(e):Math.sign(e)!==a&&(v=!0))})),v)throw new Error("a log scale domain must be strictly-positive or strictly-negative");f="auto"===s?t.min:s,m="auto"===l?t.max:l;var p=o.scaleLog().domain([f,m]).rangeRound("x"===r?[0,n]:[n,0]).base(u).nice();return p.type="log",p},E=function(e,t,n,r){var a,i,u=e.constant,c=void 0===u?1:u,s=e.min,d=void 0===s?"auto":s,l=e.max,f=void 0===l?"auto":l,m=e.reverse,v=void 0!==m&&m;a="auto"===d?t.min:d,i="auto"===f?t.max:f;var p=o.scaleSymlog().constant(c).rangeRound("x"===r?[0,n]:[n,0]).nice();!0===v?p.domain([i,a]):p.domain([a,i]);var y=p;return y.type="symlog",y},D=function(e){return"x"===e?"y":"x"},C=function(e,t){return e===t},q=function(e,t){return e.getTime()===t.getTime()};function U(e,t,n,r){switch(e.type){case"linear":return g(e,t,n,r);case"point":return k(0,t,n);case"band":return T(e,t,n,r);case"time":return b(e,t,n);case"log":return w(e,t,n,r);case"symlog":return E(e,t,n,r);default:throw new Error("invalid scale spec")}}var O=function(e,t,n){var r;if("stacked"in n&&n.stacked){var a=e.data["x"===t?"xStacked":"yStacked"];return null==a?null:n(a)}return null!=(r=n(e.data[t]))?r:null},P=function(e,t,n){return{x:j(e,"x",t),y:j(e,"y",n)}},j=function(e,t,n,r){var a=void 0===r?{}:r,i=a.getValue,o=void 0===i?function(e){return e.data[t]}:i,u=a.setValue,c=void 0===u?function(e,n){e.data[t]=n}:u;if("linear"===n.type)e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,parseFloat(String(t)))}))}));else if("time"===n.type&&"native"!==n.format){var m=h(n);e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,m(t))}))}))}var v=[];switch(e.forEach((function(e){e.data.forEach((function(e){v.push(o(e))}))})),n.type){case"linear":var p=l.default(s.default(v).filter((function(e){return null!==e})),(function(e){return e}));return{all:p,min:Math.min.apply(Math,p),max:Math.max.apply(Math,p)};case"time":var y=d.default(v,(function(e){return e.getTime()})).slice(0).sort((function(e,t){return t.getTime()-e.getTime()})).reverse();return{all:y,min:y[0],max:f.default(y)};default:var x=s.default(v);return{all:x,min:x[0],max:f.default(x)}}},B=function(e,t,n){var r=D(e),a=[];t[r].all.forEach((function(t){var i=m.default(t)?q:C,o=[];n.forEach((function(n){var u=n.data.find((function(e){return i(e.data[r],t)})),c=null,s=null;if(void 0!==u){if(null!==(c=u.data[e])){var d=f.default(o);void 0===d?s=c:null!==d&&(s=d+c)}u.data["x"===e?"xStacked":"yStacked"]=s}o.push(s),null!==s&&a.push(s)}))})),t[e].minStacked=Math.min.apply(Math,a),t[e].maxStacked=Math.max.apply(Math,a)},A=function(e,t){return B("x",e,t)},F=function(e,t){return B("y",e,t)},H=u.timeInterval((function(e){return e.setHours(0,0,0,0)}),(function(e,t){return e.setDate(e.getDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),L=u.timeInterval((function(e){return e.setUTCHours(0,0,0,0)}),(function(e,t){return e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),V={millisecond:[u.timeMillisecond,u.utcMillisecond],second:[u.timeSecond,u.utcSecond],minute:[u.timeMinute,u.utcMinute],hour:[u.timeHour,u.utcHour],day:[H,L],week:[u.timeWeek,u.utcWeek],sunday:[u.timeSunday,u.utcSunday],monday:[u.timeMonday,u.utcMonday],tuesday:[u.timeTuesday,u.utcTuesday],wednesday:[u.timeWednesday,u.utcWednesday],thursday:[u.timeThursday,u.utcThursday],friday:[u.timeFriday,u.utcFriday],saturday:[u.timeSaturday,u.utcSaturday],month:[u.timeMonth,u.utcMonth],year:[u.timeYear,u.utcYear]},R=Object.keys(V),W=new RegExp("^every\\s*(\\d+)?\\s*("+R.join("|")+")s?$","i");exports.castBandScale=M,exports.castLinearScale=S,exports.centerScale=function(e){var t=e.bandwidth();if(0===t)return e;var n=t/2;return e.round()&&(n=Math.round(n)),function(t){var r;return(null!=(r=e(t))?r:0)+n}},exports.compareDateValues=q,exports.compareValues=C,exports.computeScale=U,exports.computeXYScalesForSeries=function(e,t,n,r,a){var i=e.map((function(e){return function(e){return v({},e,{data:e.data.map((function(e){return{data:v({},e)}}))})}(e)})),o=P(i,t,n);"stacked"in t&&!0===t.stacked&&A(o,i),"stacked"in n&&!0===n.stacked&&F(o,i);var u=U(t,o.x,r,"x"),c=U(n,o.y,a,"y"),s=i.map((function(e){return v({},e,{data:e.data.map((function(e){return v({},e,{position:{x:O(e,"x",u),y:O(e,"y",c)}})}))})}));return v({},o,{series:s,xScale:u,yScale:c})},exports.createBandScale=T,exports.createDateNormalizer=h,exports.createLinearScale=g,exports.createLogScale=w,exports.createPointScale=k,exports.createPrecisionMethod=x,exports.createSymlogScale=E,exports.createTimeScale=b,exports.generateSeriesAxis=j,exports.generateSeriesXY=P,exports.getOtherAxis=D,exports.getScaleTicks=function(e,t){if(Array.isArray(t))return t;if("string"==typeof t&&"useUTC"in e){var n=t.match(W);if(n){var r=n[1],a=n[2],i=V[a][e.useUTC?1:0];if("day"===a){var o,u,c=e.domain(),s=c[0],d=c[1],l=new Date(d);return l.setDate(l.getDate()+1),null!=(o=null==(u=i.every(Number(null!=r?r:1)))?void 0:u.range(s,l))?o:[]}if(void 0===r)return e.ticks(i);var f=i.every(Number(r));if(f)return e.ticks(f)}throw new Error("Invalid tickValues: "+t)}if("ticks"in e){if(void 0===t)return e.ticks();if("number"==typeof(m=t)&&isFinite(m)&&Math.floor(m)===m)return e.ticks(t)}var m;return e.domain()},exports.precisionCutOffs=p,exports.precisionCutOffsByType=y,exports.stackAxis=B,exports.timePrecisions=["millisecond","second","minute","hour","day","month","year"];
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/uniq"),t=require("lodash/uniqBy"),n=require("lodash/sortBy"),r=require("lodash/last"),a=require("lodash/isDate"),i=require("d3-time-format"),o=require("d3-scale"),u=require("d3-time");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=c(e),d=c(t),l=c(n),f=c(r),m=c(a);function v(){return v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}var p=[function(e){return e.setMilliseconds(0)},function(e){return e.setSeconds(0)},function(e){return e.setMinutes(0)},function(e){return e.setHours(0)},function(e){return e.setDate(1)},function(e){return e.setMonth(0)}],y={millisecond:[],second:p.slice(0,1),minute:p.slice(0,2),hour:p.slice(0,3),day:p.slice(0,4),month:p.slice(0,5),year:p.slice(0,6)},x=function(e){return function(t){return y[e].forEach((function(e){e(t)})),t}},h=function(e){var t=e.format,n=void 0===t?"native":t,r=e.precision,a=void 0===r?"millisecond":r,o=e.useUTC,u=void 0===o||o,c=x(a);return function(e){if(void 0===e)return e;if("native"===n||e instanceof Date)return c(e);var t=u?i.utcParse(n):i.timeParse(n);return c(t(e))}},g=function(e,t,n,r){var a,i,u,c,s=e.min,d=void 0===s?0:s,l=e.max,f=void 0===l?"auto":l,m=e.stacked,v=void 0!==m&&m,p=e.reverse,y=void 0!==p&&p,x=e.clamp,h=void 0!==x&&x,g=e.nice,k=void 0!==g&&g;"auto"===d?a=!0===v?null!=(i=t.minStacked)?i:0:t.min:a=d;"auto"===f?u=!0===v?null!=(c=t.maxStacked)?c:0:t.max:u=f;var T=o.scaleLinear().rangeRound("x"===r?[0,n]:[n,0]).domain(y?[u,a]:[a,u]).clamp(h);return!0===k?T.nice():"number"==typeof k&&T.nice(k),S(T,v)},S=function(e,t){void 0===t&&(t=!1);var n=e;return n.type="linear",n.stacked=t,n},k=function(e,t,n){var r=o.scalePoint().range([0,n]).domain(t.all);return r.type="point",r},T=function(e,t,n,r){var a=e.round,i=void 0===a||a,u=o.scaleBand().range("x"===r?[0,n]:[n,0]).domain(t.all).round(i);return M(u)},M=function(e){var t=e;return t.type="band",t},b=function(e,t,n){var r,a,i=e.format,u=void 0===i?"native":i,c=e.precision,s=void 0===c?"millisecond":c,d=e.min,l=void 0===d?"auto":d,f=e.max,m=void 0===f?"auto":f,v=e.useUTC,p=void 0===v||v,y=e.nice,x=void 0!==y&&y,g=h({format:u,precision:s,useUTC:p});r="auto"===l?g(t.min):"native"!==u?g(l):l,a="auto"===m?g(t.max):"native"!==u?g(m):m;var S=p?o.scaleUtc():o.scaleTime();S.range([0,n]),r&&a&&S.domain([r,a]),!0===x?S.nice():"object"!=typeof x&&"number"!=typeof x||S.nice(x);var k=S;return k.type="time",k.useUTC=p,k},w=function(e,t,n,r){var a,i=e.base,u=void 0===i?10:i,c=e.min,s=void 0===c?"auto":c,d=e.max,l=void 0===d?"auto":d;if(t.all.some((function(e){return 0===e})))throw new Error("a log scale domain must not include or cross zero");var f,m,v=!1;if(t.all.filter((function(e){return null!=e})).forEach((function(e){v||(void 0===a?a=Math.sign(e):Math.sign(e)!==a&&(v=!0))})),v)throw new Error("a log scale domain must be strictly-positive or strictly-negative");f="auto"===s?t.min:s,m="auto"===l?t.max:l;var p=o.scaleLog().domain([f,m]).rangeRound("x"===r?[0,n]:[n,0]).base(u).nice();return p.type="log",p},E=function(e,t,n,r){var a,i,u=e.constant,c=void 0===u?1:u,s=e.min,d=void 0===s?"auto":s,l=e.max,f=void 0===l?"auto":l,m=e.reverse,v=void 0!==m&&m;a="auto"===d?t.min:d,i="auto"===f?t.max:f;var p=o.scaleSymlog().constant(c).rangeRound("x"===r?[0,n]:[n,0]).nice();!0===v?p.domain([i,a]):p.domain([a,i]);var y=p;return y.type="symlog",y},D=function(e){return"x"===e?"y":"x"},C=function(e,t){return e===t},q=function(e,t){return e.getTime()===t.getTime()};function U(e,t,n,r){switch(e.type){case"linear":return g(e,t,n,r);case"point":return k(0,t,n);case"band":return T(e,t,n,r);case"time":return b(e,t,n);case"log":return w(e,t,n,r);case"symlog":return E(e,t,n,r);default:throw new Error("invalid scale spec")}}var P=function(e,t,n){var r;if("stacked"in n&&n.stacked){var a=e.data["x"===t?"xStacked":"yStacked"];return null==a?null:n(a)}return null!=(r=n(e.data[t]))?r:null},O=function(e,t,n){return{x:j(e,"x",t),y:j(e,"y",n)}},j=function(e,t,n,r){var a=void 0===r?{}:r,i=a.getValue,o=void 0===i?function(e){return e.data[t]}:i,u=a.setValue,c=void 0===u?function(e,n){e.data[t]=n}:u;if("linear"===n.type)e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,parseFloat(String(t)))}))}));else if("time"===n.type&&"native"!==n.format){var m=h(n);e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,m(t))}))}))}var v=[];switch(e.forEach((function(e){e.data.forEach((function(e){v.push(o(e))}))})),n.type){case"linear":var p=l.default(s.default(v).filter((function(e){return null!==e})),(function(e){return e}));return{all:p,min:Math.min.apply(Math,p),max:Math.max.apply(Math,p)};case"time":var y=d.default(v,(function(e){return e.getTime()})).slice(0).sort((function(e,t){return t.getTime()-e.getTime()})).reverse();return{all:y,min:y[0],max:f.default(y)};default:var x=s.default(v);return{all:x,min:x[0],max:f.default(x)}}},B=function(e,t,n){var r=D(e),a=[];t[r].all.forEach((function(t){var i=m.default(t)?q:C,o=[];n.forEach((function(n){var u=n.data.find((function(e){return i(e.data[r],t)})),c=null,s=null;if(void 0!==u){if(null!==(c=u.data[e])){var d=f.default(o);void 0===d?s=c:null!==d&&(s=d+c)}u.data["x"===e?"xStacked":"yStacked"]=s}o.push(s),null!==s&&a.push(s)}))})),t[e].minStacked=Math.min.apply(Math,a),t[e].maxStacked=Math.max.apply(Math,a)},A=function(e,t){return B("x",e,t)},F=function(e,t){return B("y",e,t)},H=u.timeInterval((function(e){return e.setHours(0,0,0,0)}),(function(e,t){return e.setDate(e.getDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),L=u.timeInterval((function(e){return e.setUTCHours(0,0,0,0)}),(function(e,t){return e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),V={millisecond:[u.timeMillisecond,u.utcMillisecond],second:[u.timeSecond,u.utcSecond],minute:[u.timeMinute,u.utcMinute],hour:[u.timeHour,u.utcHour],day:[H,L],week:[u.timeWeek,u.utcWeek],sunday:[u.timeSunday,u.utcSunday],monday:[u.timeMonday,u.utcMonday],tuesday:[u.timeTuesday,u.utcTuesday],wednesday:[u.timeWednesday,u.utcWednesday],thursday:[u.timeThursday,u.utcThursday],friday:[u.timeFriday,u.utcFriday],saturday:[u.timeSaturday,u.utcSaturday],month:[u.timeMonth,u.utcMonth],year:[u.timeYear,u.utcYear]},R=Object.keys(V),W=new RegExp("^every\\s*(\\d+)?\\s*("+R.join("|")+")s?$","i");exports.castBandScale=M,exports.castLinearScale=S,exports.castPointScale=function(e){var t=e;return t.type="point",t},exports.centerScale=function(e){var t=e.bandwidth();if(0===t)return e;var n=t/2;return e.round()&&(n=Math.round(n)),function(t){var r;return(null!=(r=e(t))?r:0)+n}},exports.compareDateValues=q,exports.compareValues=C,exports.computeScale=U,exports.computeXYScalesForSeries=function(e,t,n,r,a){var i=e.map((function(e){return function(e){return v({},e,{data:e.data.map((function(e){return{data:v({},e)}}))})}(e)})),o=O(i,t,n);"stacked"in t&&!0===t.stacked&&A(o,i),"stacked"in n&&!0===n.stacked&&F(o,i);var u=U(t,o.x,r,"x"),c=U(n,o.y,a,"y"),s=i.map((function(e){return v({},e,{data:e.data.map((function(e){return v({},e,{position:{x:P(e,"x",u),y:P(e,"y",c)}})}))})}));return v({},o,{series:s,xScale:u,yScale:c})},exports.createBandScale=T,exports.createDateNormalizer=h,exports.createLinearScale=g,exports.createLogScale=w,exports.createPointScale=k,exports.createPrecisionMethod=x,exports.createSymlogScale=E,exports.createTimeScale=b,exports.generateSeriesAxis=j,exports.generateSeriesXY=O,exports.getOtherAxis=D,exports.getScaleTicks=function(e,t){if(Array.isArray(t))return t;if("string"==typeof t&&"useUTC"in e){var n=t.match(W);if(n){var r=n[1],a=n[2],i=V[a][e.useUTC?1:0];if("day"===a){var o,u,c=e.domain(),s=c[0],d=c[1],l=new Date(d);return l.setDate(l.getDate()+1),null!=(o=null==(u=i.every(Number(null!=r?r:1)))?void 0:u.range(s,l))?o:[]}if(void 0===r)return e.ticks(i);var f=i.every(Number(r));if(f)return e.ticks(f)}throw new Error("Invalid tickValues: "+t)}if("ticks"in e){if(void 0===t)return e.ticks();if("number"==typeof(m=t)&&isFinite(m)&&Math.floor(m)===m)return e.ticks(t)}var m;return e.domain()},exports.precisionCutOffs=p,exports.precisionCutOffsByType=y,exports.stackAxis=B,exports.timePrecisions=["millisecond","second","minute","hour","day","month","year"];
//# sourceMappingURL=nivo-scales.cjs.js.map

@@ -1,2 +0,2 @@

import n from"lodash/uniq";import t from"lodash/uniqBy";import r from"lodash/sortBy";import e from"lodash/last";import a from"lodash/isDate";import{utcParse as i,timeParse as o}from"d3-time-format";import{scaleLinear as u,scalePoint as c,scaleBand as d,scaleUtc as f,scaleTime as s,scaleLog as l,scaleSymlog as m}from"d3-scale";import{timeInterval as v,timeMillisecond as y,utcMillisecond as p,timeSecond as h,utcSecond as g,timeMinute as x,utcMinute as k,timeHour as T,utcHour as M,timeWeek as w,utcWeek as b,timeSunday as E,utcSunday as S,timeMonday as D,utcMonday as C,timeTuesday as U,utcTuesday as j,timeWednesday as O,utcWednesday as R,timeThursday as H,utcThursday as V,timeFriday as q,utcFriday as A,timeSaturday as B,utcSaturday as F,timeMonth as N,utcMonth as z,timeYear as I,utcYear as P}from"d3-time";function $(){return $=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=r[e])}return n},$.apply(this,arguments)}var G=["millisecond","second","minute","hour","day","month","year"],J=[function(n){return n.setMilliseconds(0)},function(n){return n.setSeconds(0)},function(n){return n.setMinutes(0)},function(n){return n.setHours(0)},function(n){return n.setDate(1)},function(n){return n.setMonth(0)}],K={millisecond:[],second:J.slice(0,1),minute:J.slice(0,2),hour:J.slice(0,3),day:J.slice(0,4),month:J.slice(0,5),year:J.slice(0,6)},L=function(n){return function(t){return K[n].forEach((function(n){n(t)})),t}},Q=function(n){var t=n.format,r=void 0===t?"native":t,e=n.precision,a=void 0===e?"millisecond":e,u=n.useUTC,c=void 0===u||u,d=L(a);return function(n){if(void 0===n)return n;if("native"===r||n instanceof Date)return d(n);var t=c?i(r):o(r);return d(t(n))}},W=function(n,t,r,e){var a,i,o,c,d=n.min,f=void 0===d?0:d,s=n.max,l=void 0===s?"auto":s,m=n.stacked,v=void 0!==m&&m,y=n.reverse,p=void 0!==y&&y,h=n.clamp,g=void 0!==h&&h,x=n.nice,k=void 0!==x&&x;"auto"===f?a=!0===v?null!=(i=t.minStacked)?i:0:t.min:a=f;"auto"===l?o=!0===v?null!=(c=t.maxStacked)?c:0:t.max:o=l;var T=u().rangeRound("x"===e?[0,r]:[r,0]).domain(p?[o,a]:[a,o]).clamp(g);return!0===k?T.nice():"number"==typeof k&&T.nice(k),X(T,v)},X=function(n,t){void 0===t&&(t=!1);var r=n;return r.type="linear",r.stacked=t,r},Y=function(n,t,r){var e=c().range([0,r]).domain(t.all);return e.type="point",e},Z=function(n,t,r,e){var a=n.round,i=void 0===a||a,o=d().range("x"===e?[0,r]:[r,0]).domain(t.all).round(i);return _(o)},_=function(n){var t=n;return t.type="band",t},nn=function(n,t,r){var e,a,i=n.format,o=void 0===i?"native":i,u=n.precision,c=void 0===u?"millisecond":u,d=n.min,l=void 0===d?"auto":d,m=n.max,v=void 0===m?"auto":m,y=n.useUTC,p=void 0===y||y,h=n.nice,g=void 0!==h&&h,x=Q({format:o,precision:c,useUTC:p});e="auto"===l?x(t.min):"native"!==o?x(l):l,a="auto"===v?x(t.max):"native"!==o?x(v):v;var k=p?f():s();k.range([0,r]),e&&a&&k.domain([e,a]),!0===g?k.nice():"object"!=typeof g&&"number"!=typeof g||k.nice(g);var T=k;return T.type="time",T.useUTC=p,T},tn=function(n,t,r,e){var a,i=n.base,o=void 0===i?10:i,u=n.min,c=void 0===u?"auto":u,d=n.max,f=void 0===d?"auto":d;if(t.all.some((function(n){return 0===n})))throw new Error("a log scale domain must not include or cross zero");var s,m,v=!1;if(t.all.filter((function(n){return null!=n})).forEach((function(n){v||(void 0===a?a=Math.sign(n):Math.sign(n)!==a&&(v=!0))})),v)throw new Error("a log scale domain must be strictly-positive or strictly-negative");s="auto"===c?t.min:c,m="auto"===f?t.max:f;var y=l().domain([s,m]).rangeRound("x"===e?[0,r]:[r,0]).base(o).nice();return y.type="log",y},rn=function(n,t,r,e){var a,i,o=n.constant,u=void 0===o?1:o,c=n.min,d=void 0===c?"auto":c,f=n.max,s=void 0===f?"auto":f,l=n.reverse,v=void 0!==l&&l;a="auto"===d?t.min:d,i="auto"===s?t.max:s;var y=m().constant(u).rangeRound("x"===e?[0,r]:[r,0]).nice();!0===v?y.domain([i,a]):y.domain([a,i]);var p=y;return p.type="symlog",p},en=function(n){return"x"===n?"y":"x"},an=function(n,t){return n===t},on=function(n,t){return n.getTime()===t.getTime()};function un(n,t,r,e){switch(n.type){case"linear":return W(n,t,r,e);case"point":return Y(0,t,r);case"band":return Z(n,t,r,e);case"time":return nn(n,t,r);case"log":return tn(n,t,r,e);case"symlog":return rn(n,t,r,e);default:throw new Error("invalid scale spec")}}var cn=function(n,t,r){var e;if("stacked"in r&&r.stacked){var a=n.data["x"===t?"xStacked":"yStacked"];return null==a?null:r(a)}return null!=(e=r(n.data[t]))?e:null},dn=function(n,t,r,e,a){var i=n.map((function(n){return function(n){return $({},n,{data:n.data.map((function(n){return{data:$({},n)}}))})}(n)})),o=fn(i,t,r);"stacked"in t&&!0===t.stacked&&mn(o,i),"stacked"in r&&!0===r.stacked&&vn(o,i);var u=un(t,o.x,e,"x"),c=un(r,o.y,a,"y"),d=i.map((function(n){return $({},n,{data:n.data.map((function(n){return $({},n,{position:{x:cn(n,"x",u),y:cn(n,"y",c)}})}))})}));return $({},o,{series:d,xScale:u,yScale:c})},fn=function(n,t,r){return{x:sn(n,"x",t),y:sn(n,"y",r)}},sn=function(a,i,o,u){var c=void 0===u?{}:u,d=c.getValue,f=void 0===d?function(n){return n.data[i]}:d,s=c.setValue,l=void 0===s?function(n,t){n.data[i]=t}:s;if("linear"===o.type)a.forEach((function(n){n.data.forEach((function(n){var t=f(n);t&&l(n,parseFloat(String(t)))}))}));else if("time"===o.type&&"native"!==o.format){var m=Q(o);a.forEach((function(n){n.data.forEach((function(n){var t=f(n);t&&l(n,m(t))}))}))}var v=[];switch(a.forEach((function(n){n.data.forEach((function(n){v.push(f(n))}))})),o.type){case"linear":var y=r(n(v).filter((function(n){return null!==n})),(function(n){return n}));return{all:y,min:Math.min.apply(Math,y),max:Math.max.apply(Math,y)};case"time":var p=t(v,(function(n){return n.getTime()})).slice(0).sort((function(n,t){return t.getTime()-n.getTime()})).reverse();return{all:p,min:p[0],max:e(p)};default:var h=n(v);return{all:h,min:h[0],max:e(h)}}},ln=function(n,t,r){var i=en(n),o=[];t[i].all.forEach((function(t){var u=a(t)?on:an,c=[];r.forEach((function(r){var a=r.data.find((function(n){return u(n.data[i],t)})),d=null,f=null;if(void 0!==a){if(null!==(d=a.data[n])){var s=e(c);void 0===s?f=d:null!==s&&(f=s+d)}a.data["x"===n?"xStacked":"yStacked"]=f}c.push(f),null!==f&&o.push(f)}))})),t[n].minStacked=Math.min.apply(Math,o),t[n].maxStacked=Math.max.apply(Math,o)},mn=function(n,t){return ln("x",n,t)},vn=function(n,t){return ln("y",n,t)},yn=function(n){var t=n.bandwidth();if(0===t)return n;var r=t/2;return n.round()&&(r=Math.round(r)),function(t){var e;return(null!=(e=n(t))?e:0)+r}},pn={millisecond:[y,p],second:[h,g],minute:[x,k],hour:[T,M],day:[v((function(n){return n.setHours(0,0,0,0)}),(function(n,t){return n.setDate(n.getDate()+t)}),(function(n,t){return(t.getTime()-n.getTime())/864e5}),(function(n){return Math.floor(n.getTime()/864e5)})),v((function(n){return n.setUTCHours(0,0,0,0)}),(function(n,t){return n.setUTCDate(n.getUTCDate()+t)}),(function(n,t){return(t.getTime()-n.getTime())/864e5}),(function(n){return Math.floor(n.getTime()/864e5)}))],week:[w,b],sunday:[E,S],monday:[D,C],tuesday:[U,j],wednesday:[O,R],thursday:[H,V],friday:[q,A],saturday:[B,F],month:[N,z],year:[I,P]},hn=Object.keys(pn),gn=new RegExp("^every\\s*(\\d+)?\\s*("+hn.join("|")+")s?$","i"),xn=function(n,t){if(Array.isArray(t))return t;if("string"==typeof t&&"useUTC"in n){var r=t.match(gn);if(r){var e=r[1],a=r[2],i=pn[a][n.useUTC?1:0];if("day"===a){var o,u,c=n.domain(),d=c[0],f=c[1],s=new Date(f);return s.setDate(s.getDate()+1),null!=(o=null==(u=i.every(Number(null!=e?e:1)))?void 0:u.range(d,s))?o:[]}if(void 0===e)return n.ticks(i);var l=i.every(Number(e));if(l)return n.ticks(l)}throw new Error("Invalid tickValues: "+t)}if("ticks"in n){if(void 0===t)return n.ticks();if("number"==typeof(m=t)&&isFinite(m)&&Math.floor(m)===m)return n.ticks(t)}var m;return n.domain()};export{_ as castBandScale,X as castLinearScale,yn as centerScale,on as compareDateValues,an as compareValues,un as computeScale,dn as computeXYScalesForSeries,Z as createBandScale,Q as createDateNormalizer,W as createLinearScale,tn as createLogScale,Y as createPointScale,L as createPrecisionMethod,rn as createSymlogScale,nn as createTimeScale,sn as generateSeriesAxis,fn as generateSeriesXY,en as getOtherAxis,xn as getScaleTicks,J as precisionCutOffs,K as precisionCutOffsByType,ln as stackAxis,G as timePrecisions};
import n from"lodash/uniq";import t from"lodash/uniqBy";import r from"lodash/sortBy";import e from"lodash/last";import a from"lodash/isDate";import{utcParse as i,timeParse as o}from"d3-time-format";import{scaleLinear as u,scalePoint as c,scaleBand as f,scaleUtc as d,scaleTime as s,scaleLog as l,scaleSymlog as m}from"d3-scale";import{timeInterval as v,timeMillisecond as y,utcMillisecond as p,timeSecond as h,utcSecond as g,timeMinute as x,utcMinute as k,timeHour as T,utcHour as M,timeWeek as w,utcWeek as b,timeSunday as E,utcSunday as S,timeMonday as D,utcMonday as C,timeTuesday as U,utcTuesday as j,timeWednesday as O,utcWednesday as R,timeThursday as H,utcThursday as V,timeFriday as q,utcFriday as A,timeSaturday as B,utcSaturday as F,timeMonth as N,utcMonth as z,timeYear as I,utcYear as P}from"d3-time";function $(){return $=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=r[e])}return n},$.apply(this,arguments)}var G=["millisecond","second","minute","hour","day","month","year"],J=[function(n){return n.setMilliseconds(0)},function(n){return n.setSeconds(0)},function(n){return n.setMinutes(0)},function(n){return n.setHours(0)},function(n){return n.setDate(1)},function(n){return n.setMonth(0)}],K={millisecond:[],second:J.slice(0,1),minute:J.slice(0,2),hour:J.slice(0,3),day:J.slice(0,4),month:J.slice(0,5),year:J.slice(0,6)},L=function(n){return function(t){return K[n].forEach((function(n){n(t)})),t}},Q=function(n){var t=n.format,r=void 0===t?"native":t,e=n.precision,a=void 0===e?"millisecond":e,u=n.useUTC,c=void 0===u||u,f=L(a);return function(n){if(void 0===n)return n;if("native"===r||n instanceof Date)return f(n);var t=c?i(r):o(r);return f(t(n))}},W=function(n,t,r,e){var a,i,o,c,f=n.min,d=void 0===f?0:f,s=n.max,l=void 0===s?"auto":s,m=n.stacked,v=void 0!==m&&m,y=n.reverse,p=void 0!==y&&y,h=n.clamp,g=void 0!==h&&h,x=n.nice,k=void 0!==x&&x;"auto"===d?a=!0===v?null!=(i=t.minStacked)?i:0:t.min:a=d;"auto"===l?o=!0===v?null!=(c=t.maxStacked)?c:0:t.max:o=l;var T=u().rangeRound("x"===e?[0,r]:[r,0]).domain(p?[o,a]:[a,o]).clamp(g);return!0===k?T.nice():"number"==typeof k&&T.nice(k),X(T,v)},X=function(n,t){void 0===t&&(t=!1);var r=n;return r.type="linear",r.stacked=t,r},Y=function(n,t,r){var e=c().range([0,r]).domain(t.all);return e.type="point",e},Z=function(n){var t=n;return t.type="point",t},_=function(n,t,r,e){var a=n.round,i=void 0===a||a,o=f().range("x"===e?[0,r]:[r,0]).domain(t.all).round(i);return nn(o)},nn=function(n){var t=n;return t.type="band",t},tn=function(n,t,r){var e,a,i=n.format,o=void 0===i?"native":i,u=n.precision,c=void 0===u?"millisecond":u,f=n.min,l=void 0===f?"auto":f,m=n.max,v=void 0===m?"auto":m,y=n.useUTC,p=void 0===y||y,h=n.nice,g=void 0!==h&&h,x=Q({format:o,precision:c,useUTC:p});e="auto"===l?x(t.min):"native"!==o?x(l):l,a="auto"===v?x(t.max):"native"!==o?x(v):v;var k=p?d():s();k.range([0,r]),e&&a&&k.domain([e,a]),!0===g?k.nice():"object"!=typeof g&&"number"!=typeof g||k.nice(g);var T=k;return T.type="time",T.useUTC=p,T},rn=function(n,t,r,e){var a,i=n.base,o=void 0===i?10:i,u=n.min,c=void 0===u?"auto":u,f=n.max,d=void 0===f?"auto":f;if(t.all.some((function(n){return 0===n})))throw new Error("a log scale domain must not include or cross zero");var s,m,v=!1;if(t.all.filter((function(n){return null!=n})).forEach((function(n){v||(void 0===a?a=Math.sign(n):Math.sign(n)!==a&&(v=!0))})),v)throw new Error("a log scale domain must be strictly-positive or strictly-negative");s="auto"===c?t.min:c,m="auto"===d?t.max:d;var y=l().domain([s,m]).rangeRound("x"===e?[0,r]:[r,0]).base(o).nice();return y.type="log",y},en=function(n,t,r,e){var a,i,o=n.constant,u=void 0===o?1:o,c=n.min,f=void 0===c?"auto":c,d=n.max,s=void 0===d?"auto":d,l=n.reverse,v=void 0!==l&&l;a="auto"===f?t.min:f,i="auto"===s?t.max:s;var y=m().constant(u).rangeRound("x"===e?[0,r]:[r,0]).nice();!0===v?y.domain([i,a]):y.domain([a,i]);var p=y;return p.type="symlog",p},an=function(n){return"x"===n?"y":"x"},on=function(n,t){return n===t},un=function(n,t){return n.getTime()===t.getTime()};function cn(n,t,r,e){switch(n.type){case"linear":return W(n,t,r,e);case"point":return Y(0,t,r);case"band":return _(n,t,r,e);case"time":return tn(n,t,r);case"log":return rn(n,t,r,e);case"symlog":return en(n,t,r,e);default:throw new Error("invalid scale spec")}}var fn=function(n,t,r){var e;if("stacked"in r&&r.stacked){var a=n.data["x"===t?"xStacked":"yStacked"];return null==a?null:r(a)}return null!=(e=r(n.data[t]))?e:null},dn=function(n,t,r,e,a){var i=n.map((function(n){return function(n){return $({},n,{data:n.data.map((function(n){return{data:$({},n)}}))})}(n)})),o=sn(i,t,r);"stacked"in t&&!0===t.stacked&&vn(o,i),"stacked"in r&&!0===r.stacked&&yn(o,i);var u=cn(t,o.x,e,"x"),c=cn(r,o.y,a,"y"),f=i.map((function(n){return $({},n,{data:n.data.map((function(n){return $({},n,{position:{x:fn(n,"x",u),y:fn(n,"y",c)}})}))})}));return $({},o,{series:f,xScale:u,yScale:c})},sn=function(n,t,r){return{x:ln(n,"x",t),y:ln(n,"y",r)}},ln=function(a,i,o,u){var c=void 0===u?{}:u,f=c.getValue,d=void 0===f?function(n){return n.data[i]}:f,s=c.setValue,l=void 0===s?function(n,t){n.data[i]=t}:s;if("linear"===o.type)a.forEach((function(n){n.data.forEach((function(n){var t=d(n);t&&l(n,parseFloat(String(t)))}))}));else if("time"===o.type&&"native"!==o.format){var m=Q(o);a.forEach((function(n){n.data.forEach((function(n){var t=d(n);t&&l(n,m(t))}))}))}var v=[];switch(a.forEach((function(n){n.data.forEach((function(n){v.push(d(n))}))})),o.type){case"linear":var y=r(n(v).filter((function(n){return null!==n})),(function(n){return n}));return{all:y,min:Math.min.apply(Math,y),max:Math.max.apply(Math,y)};case"time":var p=t(v,(function(n){return n.getTime()})).slice(0).sort((function(n,t){return t.getTime()-n.getTime()})).reverse();return{all:p,min:p[0],max:e(p)};default:var h=n(v);return{all:h,min:h[0],max:e(h)}}},mn=function(n,t,r){var i=an(n),o=[];t[i].all.forEach((function(t){var u=a(t)?un:on,c=[];r.forEach((function(r){var a=r.data.find((function(n){return u(n.data[i],t)})),f=null,d=null;if(void 0!==a){if(null!==(f=a.data[n])){var s=e(c);void 0===s?d=f:null!==s&&(d=s+f)}a.data["x"===n?"xStacked":"yStacked"]=d}c.push(d),null!==d&&o.push(d)}))})),t[n].minStacked=Math.min.apply(Math,o),t[n].maxStacked=Math.max.apply(Math,o)},vn=function(n,t){return mn("x",n,t)},yn=function(n,t){return mn("y",n,t)},pn=function(n){var t=n.bandwidth();if(0===t)return n;var r=t/2;return n.round()&&(r=Math.round(r)),function(t){var e;return(null!=(e=n(t))?e:0)+r}},hn={millisecond:[y,p],second:[h,g],minute:[x,k],hour:[T,M],day:[v((function(n){return n.setHours(0,0,0,0)}),(function(n,t){return n.setDate(n.getDate()+t)}),(function(n,t){return(t.getTime()-n.getTime())/864e5}),(function(n){return Math.floor(n.getTime()/864e5)})),v((function(n){return n.setUTCHours(0,0,0,0)}),(function(n,t){return n.setUTCDate(n.getUTCDate()+t)}),(function(n,t){return(t.getTime()-n.getTime())/864e5}),(function(n){return Math.floor(n.getTime()/864e5)}))],week:[w,b],sunday:[E,S],monday:[D,C],tuesday:[U,j],wednesday:[O,R],thursday:[H,V],friday:[q,A],saturday:[B,F],month:[N,z],year:[I,P]},gn=Object.keys(hn),xn=new RegExp("^every\\s*(\\d+)?\\s*("+gn.join("|")+")s?$","i"),kn=function(n,t){if(Array.isArray(t))return t;if("string"==typeof t&&"useUTC"in n){var r=t.match(xn);if(r){var e=r[1],a=r[2],i=hn[a][n.useUTC?1:0];if("day"===a){var o,u,c=n.domain(),f=c[0],d=c[1],s=new Date(d);return s.setDate(s.getDate()+1),null!=(o=null==(u=i.every(Number(null!=e?e:1)))?void 0:u.range(f,s))?o:[]}if(void 0===e)return n.ticks(i);var l=i.every(Number(e));if(l)return n.ticks(l)}throw new Error("Invalid tickValues: "+t)}if("ticks"in n){if(void 0===t)return n.ticks();if("number"==typeof(m=t)&&isFinite(m)&&Math.floor(m)===m)return n.ticks(t)}var m;return n.domain()};export{nn as castBandScale,X as castLinearScale,Z as castPointScale,pn as centerScale,un as compareDateValues,on as compareValues,cn as computeScale,dn as computeXYScalesForSeries,_ as createBandScale,Q as createDateNormalizer,W as createLinearScale,rn as createLogScale,Y as createPointScale,L as createPrecisionMethod,en as createSymlogScale,tn as createTimeScale,ln as generateSeriesAxis,sn as generateSeriesXY,an as getOtherAxis,kn as getScaleTicks,J as precisionCutOffs,K as precisionCutOffsByType,mn as stackAxis,G as timePrecisions};
//# sourceMappingURL=nivo-scales.es.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash/uniq"),require("lodash/uniqBy"),require("lodash/sortBy"),require("lodash/last"),require("lodash/isDate"),require("d3-time-format"),require("d3-scale"),require("d3-time")):"function"==typeof define&&define.amd?define(["exports","lodash/uniq","lodash/uniqBy","lodash/sortBy","lodash/last","lodash/isDate","d3-time-format","d3-scale","d3-time"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nivo=e.nivo||{},e["lodash/uniq"],e["lodash/uniqBy"],e["lodash/sortBy"],e["lodash/last"],e["lodash/isDate"],e.d3,e.d3,e.d3)}(this,(function(e,t,n,a,r,i,o,u,c){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(t),l=s(n),f=s(a),m=s(r),v=s(i);function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},y.apply(this,arguments)}var h=[function(e){return e.setMilliseconds(0)},function(e){return e.setSeconds(0)},function(e){return e.setMinutes(0)},function(e){return e.setHours(0)},function(e){return e.setDate(1)},function(e){return e.setMonth(0)}],p={millisecond:[],second:h.slice(0,1),minute:h.slice(0,2),hour:h.slice(0,3),day:h.slice(0,4),month:h.slice(0,5),year:h.slice(0,6)},g=function(e){return function(t){return p[e].forEach((function(e){e(t)})),t}},x=function(e){var t=e.format,n=void 0===t?"native":t,a=e.precision,r=void 0===a?"millisecond":a,i=e.useUTC,u=void 0===i||i,c=g(r);return function(e){if(void 0===e)return e;if("native"===n||e instanceof Date)return c(e);var t=u?o.utcParse(n):o.timeParse(n);return c(t(e))}},S=function(e,t,n,a){var r,i,o,c,s=e.min,d=void 0===s?0:s,l=e.max,f=void 0===l?"auto":l,m=e.stacked,v=void 0!==m&&m,y=e.reverse,h=void 0!==y&&y,p=e.clamp,g=void 0!==p&&p,x=e.nice,S=void 0!==x&&x;"auto"===d?r=!0===v?null!=(i=t.minStacked)?i:0:t.min:r=d;"auto"===f?o=!0===v?null!=(c=t.maxStacked)?c:0:t.max:o=f;var k=u.scaleLinear().rangeRound("x"===a?[0,n]:[n,0]).domain(h?[o,r]:[r,o]).clamp(g);return!0===S?k.nice():"number"==typeof S&&k.nice(S),T(k,v)},T=function(e,t){void 0===t&&(t=!1);var n=e;return n.type="linear",n.stacked=t,n},k=function(e,t,n){var a=u.scalePoint().range([0,n]).domain(t.all);return a.type="point",a},M=function(e,t,n,a){var r=e.round,i=void 0===r||r,o=u.scaleBand().range("x"===a?[0,n]:[n,0]).domain(t.all).round(i);return b(o)},b=function(e){var t=e;return t.type="band",t},w=function(e,t,n){var a,r,i=e.format,o=void 0===i?"native":i,c=e.precision,s=void 0===c?"millisecond":c,d=e.min,l=void 0===d?"auto":d,f=e.max,m=void 0===f?"auto":f,v=e.useUTC,y=void 0===v||v,h=e.nice,p=void 0!==h&&h,g=x({format:o,precision:s,useUTC:y});a="auto"===l?g(t.min):"native"!==o?g(l):l,r="auto"===m?g(t.max):"native"!==o?g(m):m;var S=y?u.scaleUtc():u.scaleTime();S.range([0,n]),a&&r&&S.domain([a,r]),!0===p?S.nice():"object"!=typeof p&&"number"!=typeof p||S.nice(p);var T=S;return T.type="time",T.useUTC=y,T},E=function(e,t,n,a){var r,i=e.base,o=void 0===i?10:i,c=e.min,s=void 0===c?"auto":c,d=e.max,l=void 0===d?"auto":d;if(t.all.some((function(e){return 0===e})))throw new Error("a log scale domain must not include or cross zero");var f,m,v=!1;if(t.all.filter((function(e){return null!=e})).forEach((function(e){v||(void 0===r?r=Math.sign(e):Math.sign(e)!==r&&(v=!0))})),v)throw new Error("a log scale domain must be strictly-positive or strictly-negative");f="auto"===s?t.min:s,m="auto"===l?t.max:l;var y=u.scaleLog().domain([f,m]).rangeRound("x"===a?[0,n]:[n,0]).base(o).nice();return y.type="log",y},q=function(e,t,n,a){var r,i,o=e.constant,c=void 0===o?1:o,s=e.min,d=void 0===s?"auto":s,l=e.max,f=void 0===l?"auto":l,m=e.reverse,v=void 0!==m&&m;r="auto"===d?t.min:d,i="auto"===f?t.max:f;var y=u.scaleSymlog().constant(c).rangeRound("x"===a?[0,n]:[n,0]).nice();!0===v?y.domain([i,r]):y.domain([r,i]);var h=y;return h.type="symlog",h},D=function(e){return"x"===e?"y":"x"},C=function(e,t){return e===t},B=function(e,t){return e.getTime()===t.getTime()};function U(e,t,n,a){switch(e.type){case"linear":return S(e,t,n,a);case"point":return k(0,t,n);case"band":return M(e,t,n,a);case"time":return w(e,t,n);case"log":return E(e,t,n,a);case"symlog":return q(e,t,n,a);default:throw new Error("invalid scale spec")}}var j=function(e,t,n){var a;if("stacked"in n&&n.stacked){var r=e.data["x"===t?"xStacked":"yStacked"];return null==r?null:n(r)}return null!=(a=n(e.data[t]))?a:null},O=function(e,t,n){return{x:P(e,"x",t),y:P(e,"y",n)}},P=function(e,t,n,a){var r=void 0===a?{}:a,i=r.getValue,o=void 0===i?function(e){return e.data[t]}:i,u=r.setValue,c=void 0===u?function(e,n){e.data[t]=n}:u;if("linear"===n.type)e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,parseFloat(String(t)))}))}));else if("time"===n.type&&"native"!==n.format){var s=x(n);e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,s(t))}))}))}var v=[];switch(e.forEach((function(e){e.data.forEach((function(e){v.push(o(e))}))})),n.type){case"linear":var y=f.default(d.default(v).filter((function(e){return null!==e})),(function(e){return e}));return{all:y,min:Math.min.apply(Math,y),max:Math.max.apply(Math,y)};case"time":var h=l.default(v,(function(e){return e.getTime()})).slice(0).sort((function(e,t){return t.getTime()-e.getTime()})).reverse();return{all:h,min:h[0],max:m.default(h)};default:var p=d.default(v);return{all:p,min:p[0],max:m.default(p)}}},A=function(e,t,n){var a=D(e),r=[];t[a].all.forEach((function(t){var i=v.default(t)?B:C,o=[];n.forEach((function(n){var u=n.data.find((function(e){return i(e.data[a],t)})),c=null,s=null;if(void 0!==u){if(null!==(c=u.data[e])){var d=m.default(o);void 0===d?s=c:null!==d&&(s=d+c)}u.data["x"===e?"xStacked":"yStacked"]=s}o.push(s),null!==s&&r.push(s)}))})),t[e].minStacked=Math.min.apply(Math,r),t[e].maxStacked=Math.max.apply(Math,r)},F=function(e,t){return A("x",e,t)},H=function(e,t){return A("y",e,t)},L=c.timeInterval((function(e){return e.setHours(0,0,0,0)}),(function(e,t){return e.setDate(e.getDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),V=c.timeInterval((function(e){return e.setUTCHours(0,0,0,0)}),(function(e,t){return e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),R={millisecond:[c.timeMillisecond,c.utcMillisecond],second:[c.timeSecond,c.utcSecond],minute:[c.timeMinute,c.utcMinute],hour:[c.timeHour,c.utcHour],day:[L,V],week:[c.timeWeek,c.utcWeek],sunday:[c.timeSunday,c.utcSunday],monday:[c.timeMonday,c.utcMonday],tuesday:[c.timeTuesday,c.utcTuesday],wednesday:[c.timeWednesday,c.utcWednesday],thursday:[c.timeThursday,c.utcThursday],friday:[c.timeFriday,c.utcFriday],saturday:[c.timeSaturday,c.utcSaturday],month:[c.timeMonth,c.utcMonth],year:[c.timeYear,c.utcYear]},W=Object.keys(R),Y=new RegExp("^every\\s*(\\d+)?\\s*("+W.join("|")+")s?$","i");e.castBandScale=b,e.castLinearScale=T,e.centerScale=function(e){var t=e.bandwidth();if(0===t)return e;var n=t/2;return e.round()&&(n=Math.round(n)),function(t){var a;return(null!=(a=e(t))?a:0)+n}},e.compareDateValues=B,e.compareValues=C,e.computeScale=U,e.computeXYScalesForSeries=function(e,t,n,a,r){var i=e.map((function(e){return function(e){return y({},e,{data:e.data.map((function(e){return{data:y({},e)}}))})}(e)})),o=O(i,t,n);"stacked"in t&&!0===t.stacked&&F(o,i),"stacked"in n&&!0===n.stacked&&H(o,i);var u=U(t,o.x,a,"x"),c=U(n,o.y,r,"y"),s=i.map((function(e){return y({},e,{data:e.data.map((function(e){return y({},e,{position:{x:j(e,"x",u),y:j(e,"y",c)}})}))})}));return y({},o,{series:s,xScale:u,yScale:c})},e.createBandScale=M,e.createDateNormalizer=x,e.createLinearScale=S,e.createLogScale=E,e.createPointScale=k,e.createPrecisionMethod=g,e.createSymlogScale=q,e.createTimeScale=w,e.generateSeriesAxis=P,e.generateSeriesXY=O,e.getOtherAxis=D,e.getScaleTicks=function(e,t){if(Array.isArray(t))return t;if("string"==typeof t&&"useUTC"in e){var n=t.match(Y);if(n){var a=n[1],r=n[2],i=R[r][e.useUTC?1:0];if("day"===r){var o,u,c=e.domain(),s=c[0],d=c[1],l=new Date(d);return l.setDate(l.getDate()+1),null!=(o=null==(u=i.every(Number(null!=a?a:1)))?void 0:u.range(s,l))?o:[]}if(void 0===a)return e.ticks(i);var f=i.every(Number(a));if(f)return e.ticks(f)}throw new Error("Invalid tickValues: "+t)}if("ticks"in e){if(void 0===t)return e.ticks();if("number"==typeof(m=t)&&isFinite(m)&&Math.floor(m)===m)return e.ticks(t)}var m;return e.domain()},e.precisionCutOffs=h,e.precisionCutOffsByType=p,e.stackAxis=A,e.timePrecisions=["millisecond","second","minute","hour","day","month","year"],Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash/uniq"),require("lodash/uniqBy"),require("lodash/sortBy"),require("lodash/last"),require("lodash/isDate"),require("d3-time-format"),require("d3-scale"),require("d3-time")):"function"==typeof define&&define.amd?define(["exports","lodash/uniq","lodash/uniqBy","lodash/sortBy","lodash/last","lodash/isDate","d3-time-format","d3-scale","d3-time"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nivo=e.nivo||{},e["lodash/uniq"],e["lodash/uniqBy"],e["lodash/sortBy"],e["lodash/last"],e["lodash/isDate"],e.d3,e.d3,e.d3)}(this,(function(e,t,n,a,r,i,o,u,c){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(t),l=s(n),f=s(a),m=s(r),v=s(i);function y(){return y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},y.apply(this,arguments)}var h=[function(e){return e.setMilliseconds(0)},function(e){return e.setSeconds(0)},function(e){return e.setMinutes(0)},function(e){return e.setHours(0)},function(e){return e.setDate(1)},function(e){return e.setMonth(0)}],p={millisecond:[],second:h.slice(0,1),minute:h.slice(0,2),hour:h.slice(0,3),day:h.slice(0,4),month:h.slice(0,5),year:h.slice(0,6)},g=function(e){return function(t){return p[e].forEach((function(e){e(t)})),t}},x=function(e){var t=e.format,n=void 0===t?"native":t,a=e.precision,r=void 0===a?"millisecond":a,i=e.useUTC,u=void 0===i||i,c=g(r);return function(e){if(void 0===e)return e;if("native"===n||e instanceof Date)return c(e);var t=u?o.utcParse(n):o.timeParse(n);return c(t(e))}},S=function(e,t,n,a){var r,i,o,c,s=e.min,d=void 0===s?0:s,l=e.max,f=void 0===l?"auto":l,m=e.stacked,v=void 0!==m&&m,y=e.reverse,h=void 0!==y&&y,p=e.clamp,g=void 0!==p&&p,x=e.nice,S=void 0!==x&&x;"auto"===d?r=!0===v?null!=(i=t.minStacked)?i:0:t.min:r=d;"auto"===f?o=!0===v?null!=(c=t.maxStacked)?c:0:t.max:o=f;var k=u.scaleLinear().rangeRound("x"===a?[0,n]:[n,0]).domain(h?[o,r]:[r,o]).clamp(g);return!0===S?k.nice():"number"==typeof S&&k.nice(S),T(k,v)},T=function(e,t){void 0===t&&(t=!1);var n=e;return n.type="linear",n.stacked=t,n},k=function(e,t,n){var a=u.scalePoint().range([0,n]).domain(t.all);return a.type="point",a},M=function(e,t,n,a){var r=e.round,i=void 0===r||r,o=u.scaleBand().range("x"===a?[0,n]:[n,0]).domain(t.all).round(i);return b(o)},b=function(e){var t=e;return t.type="band",t},w=function(e,t,n){var a,r,i=e.format,o=void 0===i?"native":i,c=e.precision,s=void 0===c?"millisecond":c,d=e.min,l=void 0===d?"auto":d,f=e.max,m=void 0===f?"auto":f,v=e.useUTC,y=void 0===v||v,h=e.nice,p=void 0!==h&&h,g=x({format:o,precision:s,useUTC:y});a="auto"===l?g(t.min):"native"!==o?g(l):l,r="auto"===m?g(t.max):"native"!==o?g(m):m;var S=y?u.scaleUtc():u.scaleTime();S.range([0,n]),a&&r&&S.domain([a,r]),!0===p?S.nice():"object"!=typeof p&&"number"!=typeof p||S.nice(p);var T=S;return T.type="time",T.useUTC=y,T},E=function(e,t,n,a){var r,i=e.base,o=void 0===i?10:i,c=e.min,s=void 0===c?"auto":c,d=e.max,l=void 0===d?"auto":d;if(t.all.some((function(e){return 0===e})))throw new Error("a log scale domain must not include or cross zero");var f,m,v=!1;if(t.all.filter((function(e){return null!=e})).forEach((function(e){v||(void 0===r?r=Math.sign(e):Math.sign(e)!==r&&(v=!0))})),v)throw new Error("a log scale domain must be strictly-positive or strictly-negative");f="auto"===s?t.min:s,m="auto"===l?t.max:l;var y=u.scaleLog().domain([f,m]).rangeRound("x"===a?[0,n]:[n,0]).base(o).nice();return y.type="log",y},q=function(e,t,n,a){var r,i,o=e.constant,c=void 0===o?1:o,s=e.min,d=void 0===s?"auto":s,l=e.max,f=void 0===l?"auto":l,m=e.reverse,v=void 0!==m&&m;r="auto"===d?t.min:d,i="auto"===f?t.max:f;var y=u.scaleSymlog().constant(c).rangeRound("x"===a?[0,n]:[n,0]).nice();!0===v?y.domain([i,r]):y.domain([r,i]);var h=y;return h.type="symlog",h},D=function(e){return"x"===e?"y":"x"},C=function(e,t){return e===t},B=function(e,t){return e.getTime()===t.getTime()};function U(e,t,n,a){switch(e.type){case"linear":return S(e,t,n,a);case"point":return k(0,t,n);case"band":return M(e,t,n,a);case"time":return w(e,t,n);case"log":return E(e,t,n,a);case"symlog":return q(e,t,n,a);default:throw new Error("invalid scale spec")}}var P=function(e,t,n){var a;if("stacked"in n&&n.stacked){var r=e.data["x"===t?"xStacked":"yStacked"];return null==r?null:n(r)}return null!=(a=n(e.data[t]))?a:null},j=function(e,t,n){return{x:O(e,"x",t),y:O(e,"y",n)}},O=function(e,t,n,a){var r=void 0===a?{}:a,i=r.getValue,o=void 0===i?function(e){return e.data[t]}:i,u=r.setValue,c=void 0===u?function(e,n){e.data[t]=n}:u;if("linear"===n.type)e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,parseFloat(String(t)))}))}));else if("time"===n.type&&"native"!==n.format){var s=x(n);e.forEach((function(e){e.data.forEach((function(e){var t=o(e);t&&c(e,s(t))}))}))}var v=[];switch(e.forEach((function(e){e.data.forEach((function(e){v.push(o(e))}))})),n.type){case"linear":var y=f.default(d.default(v).filter((function(e){return null!==e})),(function(e){return e}));return{all:y,min:Math.min.apply(Math,y),max:Math.max.apply(Math,y)};case"time":var h=l.default(v,(function(e){return e.getTime()})).slice(0).sort((function(e,t){return t.getTime()-e.getTime()})).reverse();return{all:h,min:h[0],max:m.default(h)};default:var p=d.default(v);return{all:p,min:p[0],max:m.default(p)}}},A=function(e,t,n){var a=D(e),r=[];t[a].all.forEach((function(t){var i=v.default(t)?B:C,o=[];n.forEach((function(n){var u=n.data.find((function(e){return i(e.data[a],t)})),c=null,s=null;if(void 0!==u){if(null!==(c=u.data[e])){var d=m.default(o);void 0===d?s=c:null!==d&&(s=d+c)}u.data["x"===e?"xStacked":"yStacked"]=s}o.push(s),null!==s&&r.push(s)}))})),t[e].minStacked=Math.min.apply(Math,r),t[e].maxStacked=Math.max.apply(Math,r)},F=function(e,t){return A("x",e,t)},H=function(e,t){return A("y",e,t)},L=c.timeInterval((function(e){return e.setHours(0,0,0,0)}),(function(e,t){return e.setDate(e.getDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),V=c.timeInterval((function(e){return e.setUTCHours(0,0,0,0)}),(function(e,t){return e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t.getTime()-e.getTime())/864e5}),(function(e){return Math.floor(e.getTime()/864e5)})),R={millisecond:[c.timeMillisecond,c.utcMillisecond],second:[c.timeSecond,c.utcSecond],minute:[c.timeMinute,c.utcMinute],hour:[c.timeHour,c.utcHour],day:[L,V],week:[c.timeWeek,c.utcWeek],sunday:[c.timeSunday,c.utcSunday],monday:[c.timeMonday,c.utcMonday],tuesday:[c.timeTuesday,c.utcTuesday],wednesday:[c.timeWednesday,c.utcWednesday],thursday:[c.timeThursday,c.utcThursday],friday:[c.timeFriday,c.utcFriday],saturday:[c.timeSaturday,c.utcSaturday],month:[c.timeMonth,c.utcMonth],year:[c.timeYear,c.utcYear]},W=Object.keys(R),Y=new RegExp("^every\\s*(\\d+)?\\s*("+W.join("|")+")s?$","i");e.castBandScale=b,e.castLinearScale=T,e.castPointScale=function(e){var t=e;return t.type="point",t},e.centerScale=function(e){var t=e.bandwidth();if(0===t)return e;var n=t/2;return e.round()&&(n=Math.round(n)),function(t){var a;return(null!=(a=e(t))?a:0)+n}},e.compareDateValues=B,e.compareValues=C,e.computeScale=U,e.computeXYScalesForSeries=function(e,t,n,a,r){var i=e.map((function(e){return function(e){return y({},e,{data:e.data.map((function(e){return{data:y({},e)}}))})}(e)})),o=j(i,t,n);"stacked"in t&&!0===t.stacked&&F(o,i),"stacked"in n&&!0===n.stacked&&H(o,i);var u=U(t,o.x,a,"x"),c=U(n,o.y,r,"y"),s=i.map((function(e){return y({},e,{data:e.data.map((function(e){return y({},e,{position:{x:P(e,"x",u),y:P(e,"y",c)}})}))})}));return y({},o,{series:s,xScale:u,yScale:c})},e.createBandScale=M,e.createDateNormalizer=x,e.createLinearScale=S,e.createLogScale=E,e.createPointScale=k,e.createPrecisionMethod=g,e.createSymlogScale=q,e.createTimeScale=w,e.generateSeriesAxis=O,e.generateSeriesXY=j,e.getOtherAxis=D,e.getScaleTicks=function(e,t){if(Array.isArray(t))return t;if("string"==typeof t&&"useUTC"in e){var n=t.match(Y);if(n){var a=n[1],r=n[2],i=R[r][e.useUTC?1:0];if("day"===r){var o,u,c=e.domain(),s=c[0],d=c[1],l=new Date(d);return l.setDate(l.getDate()+1),null!=(o=null==(u=i.every(Number(null!=a?a:1)))?void 0:u.range(s,l))?o:[]}if(void 0===a)return e.ticks(i);var f=i.every(Number(a));if(f)return e.ticks(f)}throw new Error("Invalid tickValues: "+t)}if("ticks"in e){if(void 0===t)return e.ticks();if("number"==typeof(m=t)&&isFinite(m)&&Math.floor(m)===m)return e.ticks(t)}var m;return e.domain()},e.precisionCutOffs=h,e.precisionCutOffsByType=p,e.stackAxis=A,e.timePrecisions=["millisecond","second","minute","hour","day","month","year"],Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=nivo-scales.umd.js.map

@@ -0,3 +1,5 @@

import { ScalePoint as D3ScalePoint } from 'd3-scale';
import { ComputedSerieAxis, ScalePoint, ScalePointSpec, StringValue } from './types';
export declare const createPointScale: <Input extends StringValue>(_spec: ScalePointSpec, data: ComputedSerieAxis<Input>, size: number) => ScalePoint<Input>;
export declare const castPointScale: <Input extends StringValue>(scale: D3ScalePoint<Input>) => ScalePoint<Input>;
//# sourceMappingURL=pointScale.d.ts.map

@@ -8,5 +8,5 @@ export declare const timePrecisions: readonly ["millisecond", "second", "minute", "hour", "day", "month", "year"];

format?: string | undefined;
precision?: "month" | "millisecond" | "second" | "minute" | "hour" | "day" | "year" | undefined;
precision?: "millisecond" | "second" | "minute" | "hour" | "day" | "month" | "year" | undefined;
useUTC?: boolean | undefined;
}) => (value: Date | string | undefined) => Date | undefined;
//# sourceMappingURL=timeHelpers.d.ts.map
{
"name": "@nivo/scales",
"version": "0.75.0",
"version": "0.76.0",
"license": "MIT",

@@ -37,3 +37,3 @@ "author": {

},
"gitHead": "bfe8126876bf0e46ad82251935ab78178e901bcf"
"gitHead": "0feb061ac0e4cd9ac6a27f5714e3629d1dcdcf4f"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc