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

@evidence-dev/components

Package Overview
Dependencies
Maintainers
2
Versions
648
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evidence-dev/components - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

LICENSE

126

modules/countDates.js

@@ -0,71 +1,71 @@

function countDays(dateFrom, dateTo){
const diffTime = Math.abs(dateTo - dateFrom) + 1;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays;
}
export default function countDates(dateFrom, dateTo, interval){
function countDays(dateFrom, dateTo){
const diffTime = Math.abs(dateTo - dateFrom) + 1;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays;
}
function countMonths(dateFrom, dateTo) {
return dateTo.getMonth() - dateFrom.getMonth() + 1 +
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
}
function countMonths(dateFrom, dateTo) {
return dateTo.getMonth() - dateFrom.getMonth() + 1 +
(12 * (dateTo.getFullYear() - dateFrom.getFullYear()))
}
function countYears(dateFrom, dateTo) {
return Math.abs(dateTo.getFullYear() - dateFrom.getFullYear() + 1);
}
function countYears(dateFrom, dateTo) {
return Math.abs(dateTo.getFullYear() - dateFrom.getFullYear() + 1);
function countQuarters(dateFrom, dateTo) {
// Add 1 to getMonth function to make output 1-based:
const month1 = dateFrom.getMonth() + 1;
const month2 = dateTo.getMonth() + 1;
const qtr1 = Math.ceil(month1/3);
const qtr2 = Math.ceil(month2/3);
const qtrDiff = Math.abs(qtr2 - qtr1);
const year1 = dateFrom.getFullYear();
const year2 = dateTo.getFullYear();
const qtrCount = qtrDiff + 1 + (4 * Math.abs(year2-year1))
return qtrCount;
}
function getWeek(date, dowOffset) {
/**
* Returns the week number for this date. dowOffset is the day of week the week
* "starts" on for your locale - it can be from 0 to 6. If dowOffset is 1 (Monday),
* the week returned is the ISO 8601 week number.
*/
/*getWeek() was developed by Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com */
dowOffset = typeof(dowOffset) == 'number' ? dowOffset : 0; //default dowOffset to zero
var newYear = new Date(date.getFullYear(),0,1);
var day = newYear.getDay() - dowOffset; //the day of week the year begins on
day = (day >= 0 ? day : day + 7);
var daynum = Math.floor((date.getTime() - newYear.getTime() -
(date.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
var weeknum;
var nYear;
var nday;
//if the year starts before the middle of a week
if(day < 4) {
weeknum = Math.floor((daynum+day-1)/7) + 1;
if(weeknum > 52) {
nYear = new Date(date.getFullYear() + 1,0,1);
nday = nYear.getDay() - dowOffset;
nday = nday >= 0 ? nday : nday + 7;
/*if the next year starts before the middle of
the week, it is week #1 of that year*/
weeknum = nday < 4 ? 1 : 53;
}
function countQuarters(dateFrom, dateTo) {
// Add 1 to getMonth function to make output 1-based:
const month1 = dateFrom.getMonth() + 1;
const month2 = dateTo.getMonth() + 1;
const qtr1 = Math.ceil(month1/3);
const qtr2 = Math.ceil(month2/3);
const qtrDiff = Math.abs(qtr2 - qtr1);
const year1 = dateFrom.getFullYear();
const year2 = dateTo.getFullYear();
const qtrCount = qtrDiff + 1 + (4 * Math.abs(year2-year1))
return qtrCount;
}
}
else {
weeknum = Math.floor((daynum+day-1)/7);
}
return weeknum;
};
function getWeek(date, dowOffset) {
/**
* Returns the week number for this date. dowOffset is the day of week the week
* "starts" on for your locale - it can be from 0 to 6. If dowOffset is 1 (Monday),
* the week returned is the ISO 8601 week number.
*/
/*getWeek() was developed by Nick Baicoianu at MeanFreePath: http://www.meanfreepath.com */
function countWeeks(dateFrom, dateTo) {
return getWeek(dateTo,0) - getWeek(dateFrom,0) + 1 +
(52 * (dateTo.getFullYear() - dateFrom.getFullYear()))
}
dowOffset = typeof(dowOffset) == 'number' ? dowOffset : 0; //default dowOffset to zero
var newYear = new Date(date.getFullYear(),0,1);
var day = newYear.getDay() - dowOffset; //the day of week the year begins on
day = (day >= 0 ? day : day + 7);
var daynum = Math.floor((date.getTime() - newYear.getTime() -
(date.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
var weeknum;
var nYear;
var nday;
//if the year starts before the middle of a week
if(day < 4) {
weeknum = Math.floor((daynum+day-1)/7) + 1;
if(weeknum > 52) {
nYear = new Date(date.getFullYear() + 1,0,1);
nday = nYear.getDay() - dowOffset;
nday = nday >= 0 ? nday : nday + 7;
/*if the next year starts before the middle of
the week, it is week #1 of that year*/
weeknum = nday < 4 ? 1 : 53;
}
}
else {
weeknum = Math.floor((daynum+day-1)/7);
}
return weeknum;
};
export default function countDates(dateFrom, dateTo, interval){
function countWeeks(dateFrom, dateTo) {
return getWeek(dateTo,0) - getWeek(dateFrom,0) + 1 +
(52 * (dateTo.getFullYear() - dateFrom.getFullYear()))
}
dateFrom = new Date(dateFrom);

@@ -72,0 +72,0 @@ dateTo = new Date(dateTo);

@@ -8,3 +8,3 @@ import * as d3 from 'd3';

formatHour = d3.timeFormat("%I %p"),
formatDay = d3.timeFormat("%a %d"),
formatDay = d3.timeFormat("%b %e"),
formatWeek = d3.timeFormat("%b %e"),

@@ -37,3 +37,3 @@ formatMonth = d3.timeFormat("%b"),

case "pct":
data = firstTick ? data.toLocaleString(undefined, { style: 'percent' }) : data.toLocaleString();
data = firstTick ? data.toLocaleString(undefined, { style: 'percent' }) : data.toLocaleString(undefined, { style: 'percent' }).replace("%","");
break;

@@ -74,9 +74,3 @@ case "usd":

case "week":
data = (d3.timeSecond(data) < data ? formatMillisecond
: d3.timeMinute(data) < data ? formatSecond
: d3.timeHour(data) < data ? formatMinute
: d3.timeDay(data) < data ? formatHour
: d3.timeMonth(data) < data ? (d3.timeWeek(data) < data ? formatDay : formatWeek)
: d3.timeYear(data) < data ? formatMonth
: formatYear)(data);
data = formatWeek(data);
break;

@@ -83,0 +77,0 @@ case "qtr":

@@ -27,5 +27,7 @@

let fmt = columnFormat;
try{
switch(fmt){
case "pct":
value = value.toLocaleString(undefined, { style: 'percent' })
value = value.toLocaleString(undefined, { style: 'percent', minimumFractionDigits: 0, maximumFractionDigits: 2 })
break;

@@ -71,8 +73,19 @@ case "usd":

break;
case "str":
value = value.toLocaleString();
break;
case "num":
value = value.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 2}) + suffix
break;
case "num2":
value = value.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + suffix
break;
default:
value = value.toLocaleString(undefined, {minimumFractionDigits: 0, maximumFractionDigits: 2}) + suffix
}
} catch(error) {
value = value.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + suffix
}
}
return value;
}

@@ -17,3 +17,5 @@ export default function getColumnFormat(fmtTag, columnType) {

"id",
"pct"]
"pct",
"num",
"num2"]
let colFmt;

@@ -20,0 +22,0 @@ if(columnType === "date" && dateFmts.includes(fmtTag)){

@@ -0,1 +1,8 @@

function checkDataType(data, column){
let dataType;
data = data.filter(d => d[column] != null);
dataType = typeof data[0][column];
return dataType;
}
export default function getColumnType(data, column, fmtTag) {

@@ -7,9 +14,2 @@ // Takes query result and column to check type

function checkDataType(data, column){
let dataType;
data = data.filter(d => d[column] != null);
dataType = typeof data[0][column];
return dataType;
}
// Get original data type:

@@ -16,0 +16,0 @@ let colType = checkDataType(data, column);

@@ -40,2 +40,4 @@ export default function getFormatTag(columnName) {

"pct",
"num",
"num2",

@@ -42,0 +44,0 @@ // Strings:

@@ -0,21 +1,21 @@

function isLeapYear(year) {
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
}
function getDaysInMonth(year, month) {
return [31, (isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}
function addMonths(date, value) {
var n = date.getDate();
date.setDate(1);
date.setMonth(date.getMonth() + value);
date.setDate(Math.min(n, getDaysInMonth(date.getFullYear(), date.getMonth())));
return date;
}
export default function incrementDate(date, interval, change) {
let tempDate = new Date(date);
function isLeapYear(year) {
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
}
function getDaysInMonth(year, month) {
return [31, (isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}
function addMonths(date, value) {
var n = date.getDate();
date.setDate(1);
date.setMonth(date.getMonth() + value);
date.setDate(Math.min(n, getDaysInMonth(date.getFullYear(), date.getMonth())));
return date;
}
switch(interval) {

@@ -26,3 +26,3 @@ case "date":

case "week":
tempDate.setDate(tempDate.getDate() + (change * 7));
tempDate.setDate(tempDate.getDate() + (change * 3));
break;

@@ -38,3 +38,4 @@ case "month":

case "year":
tempDate.setFullYear(tempDate.getFullYear() + (change));
tempDate.setDate(tempDate.getDate() + (change * 180));
// tempDate.setFullYear(tempDate.getFullYear() + (change));
break;

@@ -41,0 +42,0 @@ default:

{
"name": "@evidence-dev/components",
"version": "0.1.3",
"version": "0.1.4",
"devDependencies": {

@@ -39,3 +39,3 @@ "@sveltejs/adapter-static": "1.0.0-next.13",

"./modules/getStackedData.js": "./modules/getStackedData.js",
"./modules/getStackedDomainMax.js": "./modules/getStackedDomainMax.js",
"./modules/getStackedExtents.js": "./modules/getStackedExtents.js",
"./modules/getThresholds.js": "./modules/getThresholds.js",

@@ -42,0 +42,0 @@ "./modules/incrementDate.js": "./modules/incrementDate.js",

@@ -12,2 +12,3 @@ /** @typedef {typeof __propDef.props} BarProps */

stackOrder?: string;
seriesNames?: any[];
}, {

@@ -30,2 +31,3 @@ [evt: string]: CustomEvent<any>;

stackOrder?: string;
seriesNames?: any[];
};

@@ -32,0 +34,0 @@ events: {

@@ -16,3 +16,2 @@ /** @typedef {typeof __propDef.props} BarChartProps */

yGridlines?: string;
xAxisTitle?: any;
series?: any;

@@ -40,3 +39,2 @@ }, {

yGridlines?: string;
xAxisTitle?: any;
series?: any;

@@ -43,0 +41,0 @@ };

@@ -11,2 +11,3 @@ /** @typedef {typeof __propDef.props} ChartProps */

sort?: any;
reverseAxes?: boolean;
heightMultiplier?: any;

@@ -19,3 +20,2 @@ marginTop?: string;

paddingBottom?: number;
reverseAxes?: boolean;
xType?: string;

@@ -48,2 +48,3 @@ yType?: string;

sort?: any;
reverseAxes?: boolean;
heightMultiplier?: any;

@@ -56,3 +57,2 @@ marginTop?: string;

paddingBottom?: number;
reverseAxes?: boolean;
xType?: string;

@@ -59,0 +59,0 @@ yType?: string;

@@ -12,3 +12,3 @@ /** @typedef {typeof __propDef.props} ColumnChartProps */

fillTransparency?: any;
xType?: string;
xType?: any;
yMin?: number;

@@ -36,3 +36,3 @@ units?: string;

fillTransparency?: any;
xType?: string;
xType?: any;
yMin?: number;

@@ -39,0 +39,0 @@ units?: string;

@@ -5,3 +5,3 @@ /** @typedef {typeof __propDef.props} HistProps */

export default class Hist extends SvelteComponentTyped<{
data: any;
data: any[];
x?: any;

@@ -26,3 +26,3 @@ fillColor?: any;

props: {
data: any;
data: any[];
x?: any;

@@ -29,0 +29,0 @@ fillColor?: any;

@@ -7,5 +7,5 @@ /** @typedef {typeof __propDef.props} ValueProps */

data?: any;
fmt?: string;
row?: number;
column?: string;
fmt?: any;
}, {

@@ -23,5 +23,5 @@ [evt: string]: CustomEvent<any>;

data?: any;
fmt?: string;
row?: number;
column?: string;
fmt?: any;
};

@@ -28,0 +28,0 @@ events: {

@@ -17,3 +17,3 @@ /** @typedef {typeof __propDef.props} XAxisProps */

axisTitle?: string;
tickMarks?: string;
tickMarks?: any;
tickMarkColor?: any;

@@ -47,3 +47,3 @@ labels?: string;

axisTitle?: string;
tickMarks?: string;
tickMarks?: any;
tickMarkColor?: any;

@@ -50,0 +50,0 @@ labels?: string;

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

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

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