@baravak/risloo-profile-cli 3.1.0
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/.github/workflows/push.yml +14 -0
- package/.prettierrc +16 -0
- package/.yarn/releases/yarn-1.22.19.cjs +147529 -0
- package/.yarnrc.yml +1 -0
- package/README.md +98 -0
- package/bin/risloo.js +9 -0
- package/package.json +44 -0
- package/src/Gift.js +29 -0
- package/src/Profile.js +405 -0
- package/src/cli-commands/Executor.js +118 -0
- package/src/cli-commands/ExtractExecutor.js +194 -0
- package/src/cli-commands/GiftExecutor.js +56 -0
- package/src/cli-commands/utilities/BaseOps.js +71 -0
- package/src/cli-commands/utilities/Benchmarker.js +88 -0
- package/src/cli-commands/utilities/CustomErrors.js +14 -0
- package/src/cli-commands/utilities/Response.js +59 -0
- package/src/cli-commands/utilities/STATUSES.js +16 -0
- package/src/cli-commands/utilities/Status.js +9 -0
- package/src/cli.js +125 -0
- package/src/handlebars/helpers/abs.js +8 -0
- package/src/handlebars/helpers/addCommas.js +8 -0
- package/src/handlebars/helpers/array.js +8 -0
- package/src/handlebars/helpers/assignGlobal.js +9 -0
- package/src/handlebars/helpers/boolean.js +19 -0
- package/src/handlebars/helpers/ceil.js +8 -0
- package/src/handlebars/helpers/concat.js +8 -0
- package/src/handlebars/helpers/cos.js +8 -0
- package/src/handlebars/helpers/displacePoint.js +11 -0
- package/src/handlebars/helpers/ellipsisChars.js +10 -0
- package/src/handlebars/helpers/ellipsisLines.js +11 -0
- package/src/handlebars/helpers/first.js +11 -0
- package/src/handlebars/helpers/floor.js +8 -0
- package/src/handlebars/helpers/forLoop.js +15 -0
- package/src/handlebars/helpers/getArrOfProp.js +8 -0
- package/src/handlebars/helpers/isArray.js +8 -0
- package/src/handlebars/helpers/join.js +10 -0
- package/src/handlebars/helpers/last.js +11 -0
- package/src/handlebars/helpers/lineWrap.js +28 -0
- package/src/handlebars/helpers/math.js +24 -0
- package/src/handlebars/helpers/modulo.js +8 -0
- package/src/handlebars/helpers/normalizeAngle.js +7 -0
- package/src/handlebars/helpers/object.js +8 -0
- package/src/handlebars/helpers/objectEntries.js +8 -0
- package/src/handlebars/helpers/polarToCartesian.js +14 -0
- package/src/handlebars/helpers/prepend.js +10 -0
- package/src/handlebars/helpers/profiles/bar.js +45 -0
- package/src/handlebars/helpers/profiles/calcGaugeSidePoints.js +34 -0
- package/src/handlebars/helpers/profiles/gauge.js +61 -0
- package/src/handlebars/helpers/profiles/polygon.js +40 -0
- package/src/handlebars/helpers/reverse.js +9 -0
- package/src/handlebars/helpers/roundToTwo.js +8 -0
- package/src/handlebars/helpers/setVar.js +8 -0
- package/src/handlebars/helpers/sin.js +8 -0
- package/src/handlebars/helpers/split.js +8 -0
- package/src/handlebars/helpers/tan.js +8 -0
- package/src/handlebars/helpers/ternary.js +9 -0
- package/src/handlebars/helpers/toDeg.js +8 -0
- package/src/handlebars/helpers/toRad.js +8 -0
- package/src/handlebars/helpers/withGroup.js +20 -0
- package/src/handlebars/helpers/wrapOnNewline.js +11 -0
- package/src/handlebars/helpers.js +86 -0
- package/src/handlebars/importPartials.js +40 -0
- package/src/handlebars/init.js +15 -0
- package/src/publish/bot.js +91 -0
- package/src/publish/json/gift/gift.json +16 -0
- package/src/publish/json/profiles/16PF93.json +201 -0
- package/src/publish/json/profiles/AEQ93.json +96 -0
- package/src/publish/json/profiles/AMS93.json +102 -0
- package/src/publish/json/profiles/AMS9A.json +102 -0
- package/src/publish/json/profiles/BAOMEIS93.json +99 -0
- package/src/publish/json/profiles/BEQI93.json +1589 -0
- package/src/publish/json/profiles/CAATS93.json +11355 -0
- package/src/publish/json/profiles/CADS93.json +351 -0
- package/src/publish/json/profiles/CARSP93.json +96 -0
- package/src/publish/json/profiles/CERQ93.json +106 -0
- package/src/publish/json/profiles/CRAAS93.json +98 -0
- package/src/publish/json/profiles/CSI93.json +143 -0
- package/src/publish/json/profiles/DSWLS93.json +93 -0
- package/src/publish/json/profiles/EMSS93.json +116 -0
- package/src/publish/json/profiles/FACES93.json +106 -0
- package/src/publish/json/profiles/FTEPT93.json +102 -0
- package/src/publish/json/profiles/GMIT93.json +98 -0
- package/src/publish/json/profiles/HPL93.json +102 -0
- package/src/publish/json/profiles/IBT93.json +106 -0
- package/src/publish/json/profiles/IUS93.json +93 -0
- package/src/publish/json/profiles/JCSI93.json +102 -0
- package/src/publish/json/profiles/JPFQ93.json +1 -0
- package/src/publish/json/profiles/KJGI93.json +100 -0
- package/src/publish/json/profiles/LMIQ93.json +109 -0
- package/src/publish/json/profiles/MMFAD93.json +103 -0
- package/src/publish/json/profiles/MMFAD9A.json +103 -0
- package/src/publish/json/profiles/MOCI93.json +100 -0
- package/src/publish/json/profiles/OBQ4493.json +96 -0
- package/src/publish/json/profiles/PIES93.json +104 -0
- package/src/publish/json/profiles/PIES9A.json +104 -0
- package/src/publish/json/profiles/PMCIEF93.json +1 -0
- package/src/publish/json/profiles/PSWQ93.json +97 -0
- package/src/publish/json/profiles/RIASEC93.json +2511 -0
- package/src/publish/json/profiles/SAFE93.json +110 -0
- package/src/publish/json/profiles/SASQ93.json +92 -0
- package/src/publish/json/profiles/SCASP93.json +611 -0
- package/src/publish/json/profiles/SDCAQ93.json +96 -0
- package/src/publish/json/profiles/STAIY93.json +98 -0
- package/src/publish/json/profiles/WAQ93.json +100 -0
- package/src/publish/json/profiles/YBOCS93.json +1322 -0
- package/src/publish/json/profiles/empty.json +139 -0
- package/src/publish/new-version.hbs +11 -0
- package/src/publish/test.js +109 -0
- package/src/qrcode/qrCodeGenerator.js +14 -0
- package/src/qrcode/qrRender.js +229 -0
- package/src/samples/16PF93.js +158 -0
- package/src/samples/AEQ93.js +121 -0
- package/src/samples/AMS93.js +139 -0
- package/src/samples/AMS9A.js +9 -0
- package/src/samples/BAOMEIS93.js +146 -0
- package/src/samples/BEQI93.js +255 -0
- package/src/samples/CAATS93.js +218 -0
- package/src/samples/CADS93.js +161 -0
- package/src/samples/CARSP93.js +134 -0
- package/src/samples/CERQ93.js +195 -0
- package/src/samples/CRAAS93.js +141 -0
- package/src/samples/CSI93.js +315 -0
- package/src/samples/DSWLS93.js +112 -0
- package/src/samples/EMSS93.js +178 -0
- package/src/samples/FACES93.js +225 -0
- package/src/samples/FTEPT93.js +167 -0
- package/src/samples/GMIT93.js +142 -0
- package/src/samples/HPL93.js +132 -0
- package/src/samples/IBT93.js +99 -0
- package/src/samples/IUS93.js +204 -0
- package/src/samples/JCSI93.js +174 -0
- package/src/samples/JPFQ93.js +74 -0
- package/src/samples/KJGI93.js +136 -0
- package/src/samples/LMIQ93.js +188 -0
- package/src/samples/MMFAD93.js +135 -0
- package/src/samples/MMFAD9A.js +31 -0
- package/src/samples/MOCI93.js +128 -0
- package/src/samples/OBQ4493.js +132 -0
- package/src/samples/PIES93.js +228 -0
- package/src/samples/PIES9A.js +32 -0
- package/src/samples/PMCIEF93.js +64 -0
- package/src/samples/PSWQ93.js +126 -0
- package/src/samples/RIASEC93.js +144 -0
- package/src/samples/SAFE93.js +64 -0
- package/src/samples/SASQ93.js +130 -0
- package/src/samples/SCASP93.js +207 -0
- package/src/samples/SDCAQ93.js +174 -0
- package/src/samples/STAIY93.js +159 -0
- package/src/samples/WAQ93.js +208 -0
- package/src/samples/YBOCS93.js +583 -0
- package/src/samples/empty.js +53 -0
- package/views/gift.hbs +160 -0
- package/views/profiles/fonts.css +18 -0
- package/views/profiles/layout.hbs +27 -0
- package/views/profiles/samples/16PF93.hbs +54 -0
- package/views/profiles/samples/AEQ93.hbs +31 -0
- package/views/profiles/samples/AMS93.hbs +97 -0
- package/views/profiles/samples/AMS9A.hbs +1 -0
- package/views/profiles/samples/BAOMEIS93.hbs +48 -0
- package/views/profiles/samples/BEQI93.hbs +118 -0
- package/views/profiles/samples/CAATS93.hbs +251 -0
- package/views/profiles/samples/CADS93.hbs +104 -0
- package/views/profiles/samples/CARSP93.hbs +26 -0
- package/views/profiles/samples/CERQ93.hbs +115 -0
- package/views/profiles/samples/CRAAS93.hbs +88 -0
- package/views/profiles/samples/CSI93_1.hbs +110 -0
- package/views/profiles/samples/CSI93_2.hbs +76 -0
- package/views/profiles/samples/DSWLS93.hbs +26 -0
- package/views/profiles/samples/EMSS93.hbs +101 -0
- package/views/profiles/samples/FACES93_1.hbs +107 -0
- package/views/profiles/samples/FACES93_2.hbs +51 -0
- package/views/profiles/samples/FTEPT93.hbs +67 -0
- package/views/profiles/samples/GMIT93.hbs +45 -0
- package/views/profiles/samples/HPL93.hbs +36 -0
- package/views/profiles/samples/IBT93.hbs +67 -0
- package/views/profiles/samples/IUS93.hbs +123 -0
- package/views/profiles/samples/JCSI93.hbs +65 -0
- package/views/profiles/samples/JPFQ93.hbs +44 -0
- package/views/profiles/samples/KJGI93.hbs +57 -0
- package/views/profiles/samples/LMIQ93.hbs +82 -0
- package/views/profiles/samples/MMFAD93.hbs +35 -0
- package/views/profiles/samples/MMFAD9A.hbs +1 -0
- package/views/profiles/samples/MOCI93.hbs +60 -0
- package/views/profiles/samples/OBQ4493.hbs +61 -0
- package/views/profiles/samples/PIES93.hbs +67 -0
- package/views/profiles/samples/PIES9A.hbs +1 -0
- package/views/profiles/samples/PMCIEF93.hbs +8 -0
- package/views/profiles/samples/PSWQ93.hbs +32 -0
- package/views/profiles/samples/RIASEC93.hbs +38 -0
- package/views/profiles/samples/SAFE93.hbs +118 -0
- package/views/profiles/samples/SASQ93.hbs +45 -0
- package/views/profiles/samples/SCASP93.hbs +94 -0
- package/views/profiles/samples/SDCAQ93.hbs +68 -0
- package/views/profiles/samples/STAIY93.hbs +67 -0
- package/views/profiles/samples/WAQ93.hbs +74 -0
- package/views/profiles/samples/YBOCS93_1.hbs +96 -0
- package/views/profiles/samples/YBOCS93_2.hbs +115 -0
- package/views/profiles/samples/YBOCS93_3.hbs +93 -0
- package/views/profiles/samples/empty.hbs +10 -0
- package/views/profiles/sidebar.hbs +193 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ellipsisChars Helper
|
|
2
|
+
// Putting Ellipsis onto String if Exceeded Our Limit
|
|
3
|
+
|
|
4
|
+
function ellipsisChars(string, maxChar, options) {
|
|
5
|
+
if (string.length <= maxChar) return string;
|
|
6
|
+
const output = string.slice(0, maxChar) + " ...";
|
|
7
|
+
return output;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = ellipsisChars;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ellipsisLines Helper
|
|
2
|
+
// Putting Ellipsis onto Lines if Exceeded Our Limit
|
|
3
|
+
|
|
4
|
+
function ellipsisLines(lines, maxLines, options) {
|
|
5
|
+
if (lines.length <= maxLines) return lines;
|
|
6
|
+
const output = lines.slice(0, maxLines);
|
|
7
|
+
output[maxLines - 1] += " ...";
|
|
8
|
+
return output;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = ellipsisLines;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// forLoop Helper
|
|
2
|
+
// Implement For Loop in Handlebars
|
|
3
|
+
|
|
4
|
+
function forLoop(from, to, incr, block) {
|
|
5
|
+
let accum = "";
|
|
6
|
+
for (let i = from; i < to; i += incr) {
|
|
7
|
+
block.data.i = i;
|
|
8
|
+
block.data.first = i === 0;
|
|
9
|
+
block.data.last = i === to - 1;
|
|
10
|
+
accum += block.fn({i});
|
|
11
|
+
}
|
|
12
|
+
return accum;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = forLoop;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// join Helper
|
|
2
|
+
// Join all elements of array into a string, optionally using a given separator
|
|
3
|
+
|
|
4
|
+
function join(array, separator) {
|
|
5
|
+
if (typeof array === 'string') return array;
|
|
6
|
+
if (!Array.isArray(array)) return '';
|
|
7
|
+
return array.join(separator);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
module.exports = join;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// lineWrap Helper
|
|
2
|
+
// Wrapping Words into Lines
|
|
3
|
+
|
|
4
|
+
function lineWrap(string, maxChar, options) {
|
|
5
|
+
let tokens = string.split(" ");
|
|
6
|
+
let lines = [];
|
|
7
|
+
let i = 0;
|
|
8
|
+
let L = 0;
|
|
9
|
+
while(true) {
|
|
10
|
+
let tokenLength = tokens[i].replace(//g, '').length;
|
|
11
|
+
L += tokenLength + 1;
|
|
12
|
+
if (L - 1 > maxChar) {
|
|
13
|
+
lines.push(tokens.slice(0, i).join(" ").trim());
|
|
14
|
+
tokens = tokens.slice(i);
|
|
15
|
+
i = 0;
|
|
16
|
+
L = 0;
|
|
17
|
+
continue;
|
|
18
|
+
} else if (i >= tokens.length - 1) {
|
|
19
|
+
lines.push(tokens.slice(0, i + 1).join(" "));
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
i++;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return lines;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = lineWrap;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// math Helper
|
|
2
|
+
// Implements Arithmetic Operations in Handlebars
|
|
3
|
+
|
|
4
|
+
function math(lvalue, operator, rvalue, options) {
|
|
5
|
+
if (arguments.length < 4) {
|
|
6
|
+
// Operator omitted, assuming "+"
|
|
7
|
+
options = rvalue;
|
|
8
|
+
rvalue = operator;
|
|
9
|
+
operator = "+";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
lvalue = parseFloat(lvalue);
|
|
13
|
+
rvalue = parseFloat(rvalue);
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
"+": lvalue + rvalue,
|
|
17
|
+
"-": lvalue - rvalue,
|
|
18
|
+
"*": lvalue * rvalue,
|
|
19
|
+
"/": lvalue / rvalue,
|
|
20
|
+
"%": lvalue % rvalue,
|
|
21
|
+
}[operator];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = math;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// polarToCartesian Helper
|
|
2
|
+
// Convert Polar Coordinates to Cartesian
|
|
3
|
+
|
|
4
|
+
function polarToCartesian(r, theta) {
|
|
5
|
+
return {
|
|
6
|
+
x: +(r * Math.cos(theta)).toFixed(2),
|
|
7
|
+
y: +(r * Math.sin(theta)).toFixed(2),
|
|
8
|
+
get toString() {
|
|
9
|
+
return `${this.x} ${this.y}`
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = polarToCartesian;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// bar Helper
|
|
2
|
+
// This helper is used to provide the path tag for the bar chart
|
|
3
|
+
|
|
4
|
+
const Handlebars = require("handlebars");
|
|
5
|
+
const polarToCartesian = require("../polarToCartesian");
|
|
6
|
+
|
|
7
|
+
const P2C = polarToCartesian;
|
|
8
|
+
const PI = Math.PI;
|
|
9
|
+
|
|
10
|
+
function bar(W, H, brs, angle, options) {
|
|
11
|
+
// W: width
|
|
12
|
+
// H: height
|
|
13
|
+
// brs: border radiuses : {tl: top-left, tr: top-right, bl: bottom-left, br: bottom-right}
|
|
14
|
+
|
|
15
|
+
const attributes = [];
|
|
16
|
+
|
|
17
|
+
Object.keys(options.hash).forEach((key) => {
|
|
18
|
+
const escapedKey = Handlebars.escapeExpression(key);
|
|
19
|
+
const escapedValue = Handlebars.escapeExpression(options.hash[key]);
|
|
20
|
+
attributes.push(escapedKey + '="' + escapedValue + '"');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Calculate "d" Attribute of Path
|
|
24
|
+
let dAttr = `M ${P2C(W / 2, angle).toString}`;
|
|
25
|
+
|
|
26
|
+
dAttr += `L ${P2C(brs.tl, angle).toString}`;
|
|
27
|
+
dAttr += brs.tl ? `A ${brs.tl} ${brs.tl} 90 0 0 ${P2C(brs.tl, PI / 2 + angle).toString}` : "";
|
|
28
|
+
|
|
29
|
+
dAttr += `L ${P2C(H - brs.bl, PI / 2 + angle).toString}`;
|
|
30
|
+
dAttr += brs.bl ? `a ${brs.bl} ${brs.bl} 90 0 0 ${P2C(1.414 * brs.bl, PI / 4 + angle).toString}` : "";
|
|
31
|
+
|
|
32
|
+
dAttr += `l ${P2C(W - brs.bl - brs.br, angle).toString}`;
|
|
33
|
+
dAttr += brs.br ? `a ${brs.br} ${brs.br} 90 0 0 ${P2C(1.414 * brs.br, -PI / 4 + angle).toString}` : "";
|
|
34
|
+
|
|
35
|
+
dAttr += `l ${P2C(-(H - brs.br - brs.tr), PI / 2 + angle).toString}`;
|
|
36
|
+
dAttr += brs.tr ? `A ${brs.tr} ${brs.tr} 90 0 0 ${P2C(W - brs.tr, angle).toString}` : "";
|
|
37
|
+
|
|
38
|
+
dAttr += `L ${P2C(W / 2, angle).toString}`;
|
|
39
|
+
|
|
40
|
+
let result = `<path d="${dAttr}" ${attributes.join(" ")}/>`;
|
|
41
|
+
|
|
42
|
+
return new Handlebars.SafeString(result);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = bar;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// This Function is Used in the Gauge Helper and It's not an Independant Helper Itself.
|
|
2
|
+
|
|
3
|
+
const polarToCartesian = require("../polarToCartesian");
|
|
4
|
+
const P2C = polarToCartesian;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This function is used to calculate gauge element side points
|
|
8
|
+
* @param {number} R - outer radius
|
|
9
|
+
* @param {number} r - inner radius
|
|
10
|
+
* @param {object} br - border radiuses: {top, bottom}
|
|
11
|
+
* @param {number} angle - angle of the end in radians
|
|
12
|
+
* @param {boolean} start - whether the corresponding side is start or end of the gauge element
|
|
13
|
+
* @param {boolean} direction - direction of the gauge (false: clockwise, true: counterclockwise)
|
|
14
|
+
*/
|
|
15
|
+
function calcGaugeSidePoints(R, r, brs, angle, start, direction) {
|
|
16
|
+
const alpha = {},
|
|
17
|
+
theta = {};
|
|
18
|
+
for (let key in brs) {
|
|
19
|
+
alpha[key] = Math.asin(brs[key] / (R - brs[key]));
|
|
20
|
+
theta[key] = angle + (start ^ direction ? 1 : -1) * alpha[key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let points = {
|
|
24
|
+
P1: P2C(R, theta.top),
|
|
25
|
+
P2: P2C(r, theta.bottom),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
if (brs.top) points["P1_PRIME"] = P2C((R - brs.top) * Math.cos(alpha.top), angle);
|
|
29
|
+
if (brs.bottom) points["P2_PRIME"] = P2C((r + brs.bottom) * Math.cos(alpha.bottom), angle);
|
|
30
|
+
|
|
31
|
+
return points;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = calcGaugeSidePoints;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// gauge Helper
|
|
2
|
+
// This helper is used to provide the path tag for the gauge chart
|
|
3
|
+
|
|
4
|
+
const Handlebars = require("handlebars");
|
|
5
|
+
const calcGaugeSidePoints = require("./calcGaugeSidePoints");
|
|
6
|
+
const normalizeAngle = require("../normalizeAngle");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create path tag for the gauge element used in the profiles
|
|
10
|
+
* @param {number} R - outer radius
|
|
11
|
+
* @param {number} r - inner radius
|
|
12
|
+
* @param {object} brs - border radiuses: {tl: top-left, tr: top-right, bl: bottom-left, br: bottom-right}
|
|
13
|
+
* @param {object} angles - angles of sides of the gauge: {start, end}
|
|
14
|
+
* @param {boolean} direction - direction of the gauge (false: clockwise, true: counterclockwise)
|
|
15
|
+
* @param {object} options
|
|
16
|
+
*/
|
|
17
|
+
function gauge(R, r, brs, angles, direction, options) {
|
|
18
|
+
// Extract attributes out of options
|
|
19
|
+
const attributes = [];
|
|
20
|
+
|
|
21
|
+
Object.keys(options.hash).forEach((key) => {
|
|
22
|
+
const escapedKey = Handlebars.escapeExpression(key);
|
|
23
|
+
const escapedValue = Handlebars.escapeExpression(options.hash[key]);
|
|
24
|
+
attributes.push(escapedKey + '="' + escapedValue + '"');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Normalize the angles to be in the range (-PI, PI]
|
|
28
|
+
for (let key in angles) angles[key] = normalizeAngle(angles[key]);
|
|
29
|
+
|
|
30
|
+
let isGreater = true;
|
|
31
|
+
if (angles.end < angles.start) isGreater = false;
|
|
32
|
+
|
|
33
|
+
const totalAngle =
|
|
34
|
+
direction ^ isGreater ? Math.abs(angles.end - angles.start) : 2 * Math.PI - Math.abs(angles.end - angles.start);
|
|
35
|
+
|
|
36
|
+
const sidePoints = {
|
|
37
|
+
start: calcGaugeSidePoints(R, r, { top: brs.tl, bottom: brs.bl }, angles.start, true, direction),
|
|
38
|
+
end: calcGaugeSidePoints(R, r, { top: brs.tr, bottom: brs.br }, angles.end, false, direction),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Calculate "d" Attribute of Path
|
|
42
|
+
let dAttr = `M ${sidePoints.start.P1.toString}`;
|
|
43
|
+
|
|
44
|
+
dAttr += `A ${R} ${R} 1 ${totalAngle > Math.PI ? 1 : 0} ${direction ? 0 : 1} ${sidePoints.end.P1.toString}`;
|
|
45
|
+
|
|
46
|
+
dAttr += brs.tr ? `A ${brs.tr} ${brs.tr} 1 0 ${direction ? 0 : 1} ${sidePoints.end.P1_PRIME.toString}` : "";
|
|
47
|
+
dAttr += `L ${sidePoints.end.P2_PRIME?.toString || sidePoints.end.P2.toString}`;
|
|
48
|
+
dAttr += brs.br ? `A ${brs.br} ${brs.br} 1 0 ${direction ? 0 : 1} ${sidePoints.end.P2.toString}` : "";
|
|
49
|
+
|
|
50
|
+
dAttr += `A ${r} ${r} 1 ${totalAngle > Math.PI ? 1 : 0} ${direction ? 1 : 0} ${sidePoints.start.P2.toString}`;
|
|
51
|
+
|
|
52
|
+
dAttr += brs.bl ? `A ${brs.bl} ${brs.bl} 1 0 ${direction ? 0 : 1} ${sidePoints.start.P2_PRIME.toString}` : "";
|
|
53
|
+
dAttr += `L ${sidePoints.start.P1_PRIME?.toString || sidePoints.start.P1.toString}`;
|
|
54
|
+
dAttr += brs.tl ? `A ${brs.tl} ${brs.tl} 1 0 ${direction ? 0 : 1} ${sidePoints.start.P1.toString}` : "";
|
|
55
|
+
|
|
56
|
+
let result = `<path d="${dAttr}" ${attributes.join(" ")}/>`;
|
|
57
|
+
|
|
58
|
+
return new Handlebars.SafeString(result);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = gauge;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// bar Helper
|
|
2
|
+
// This helper is used to provide the path tag for the radar chart
|
|
3
|
+
|
|
4
|
+
const Handlebars = require("handlebars");
|
|
5
|
+
const polarToCartesian = require("../polarToCartesian");
|
|
6
|
+
|
|
7
|
+
const P2C = polarToCartesian;
|
|
8
|
+
const PI = Math.PI;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create path tag for the polygon of the radar chart
|
|
12
|
+
* @param {number} n - number of the vertices of the polygon
|
|
13
|
+
* @param {array} radiuses - array of radius of the corresponding vertice of the polygon
|
|
14
|
+
* @param {number} angle - angle of one vertice in radians
|
|
15
|
+
* @param {object} options
|
|
16
|
+
*/
|
|
17
|
+
function polygon(n, radiuses, angle, options) {
|
|
18
|
+
if (!Array.isArray(radiuses)) radiuses = Array(n).fill(radiuses);
|
|
19
|
+
|
|
20
|
+
const attributes = [];
|
|
21
|
+
|
|
22
|
+
Object.keys(options.hash).forEach((key) => {
|
|
23
|
+
const escapedKey = Handlebars.escapeExpression(key);
|
|
24
|
+
const escapedValue = Handlebars.escapeExpression(options.hash[key]);
|
|
25
|
+
attributes.push(escapedKey + '="' + escapedValue + '"');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// theta is the angle of the polygon
|
|
29
|
+
const theta = (2 * PI) / n;
|
|
30
|
+
|
|
31
|
+
const points = radiuses.map((radius, index) => P2C(radius, angle - index * theta));
|
|
32
|
+
|
|
33
|
+
let pointsAttr = points.reduce((accm, point) => accm + `${point.x},${point.y} `, "");
|
|
34
|
+
|
|
35
|
+
let result = `<polygon points="${pointsAttr}" ${attributes.join(" ")}/>`;
|
|
36
|
+
|
|
37
|
+
return new Handlebars.SafeString(result);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = polygon;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// withGroup Helper
|
|
2
|
+
// Block Helper that Groups Array Elements by Given Group Size
|
|
3
|
+
|
|
4
|
+
function withGroup(array, size, options) {
|
|
5
|
+
var result = '';
|
|
6
|
+
if (Array.isArray(array) && array.length > 0) {
|
|
7
|
+
var subcontext = [];
|
|
8
|
+
for (var i = 0; i < array.length; i++) {
|
|
9
|
+
if (i > 0 && (i % size) === 0) {
|
|
10
|
+
result += options.fn(subcontext);
|
|
11
|
+
subcontext = [];
|
|
12
|
+
}
|
|
13
|
+
subcontext.push(array[i]);
|
|
14
|
+
}
|
|
15
|
+
result += options.fn(subcontext);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports = withGroup;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// wrapOnNewline Helper
|
|
2
|
+
// Used to split a string by \n to create lines
|
|
3
|
+
|
|
4
|
+
const Handlebars = require("handlebars");
|
|
5
|
+
|
|
6
|
+
function wrapOnNewline(string) {
|
|
7
|
+
string = string.replace(/\\n/gm, '\n');
|
|
8
|
+
return string.split(/\n/gm);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = wrapOnNewline;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const isArray = require("./helpers/isArray");
|
|
2
|
+
const addCommas = require("./helpers/addCommas");
|
|
3
|
+
const boolean = require("./helpers/boolean");
|
|
4
|
+
const math = require("./helpers/math");
|
|
5
|
+
const modulo = require("./helpers/modulo");
|
|
6
|
+
const ternary = require("./helpers/ternary");
|
|
7
|
+
const lineWrap = require("./helpers/lineWrap");
|
|
8
|
+
const wrapOnNewline = require("./helpers/wrapOnNewline");
|
|
9
|
+
const ellipsisLines = require("./helpers/ellipsisLines");
|
|
10
|
+
const ellipsisChars = require("./helpers/ellipsisChars");
|
|
11
|
+
const setVar = require("./helpers/setVar");
|
|
12
|
+
const assignGlobal = require("./helpers/assignGlobal");
|
|
13
|
+
const forLoop = require("./helpers/forLoop");
|
|
14
|
+
const concat = require("./helpers/concat");
|
|
15
|
+
const sin = require("./helpers/sin");
|
|
16
|
+
const cos = require("./helpers/cos");
|
|
17
|
+
const tan = require("./helpers/tan");
|
|
18
|
+
const toDeg = require("./helpers/toDeg");
|
|
19
|
+
const toRad = require("./helpers/toRad");
|
|
20
|
+
const roundToTwo = require("./helpers/roundToTwo");
|
|
21
|
+
const objectEntries = require("./helpers/objectEntries");
|
|
22
|
+
const object = require("./helpers/object");
|
|
23
|
+
const array = require("./helpers/array");
|
|
24
|
+
const reverse = require("./helpers/reverse");
|
|
25
|
+
const prepend = require("./helpers/prepend");
|
|
26
|
+
const polarToCartesian = require("./helpers/polarToCartesian");
|
|
27
|
+
const abs = require("./helpers/abs");
|
|
28
|
+
const getArrOfProp = require("./helpers/getArrOfProp");
|
|
29
|
+
const displacePoint = require("./helpers/displacePoint");
|
|
30
|
+
const normalizeAngle = require("./helpers/normalizeAngle");
|
|
31
|
+
const withGroup = require("./helpers/withGroup");
|
|
32
|
+
const join = require("./helpers/join");
|
|
33
|
+
const split = require("./helpers/split");
|
|
34
|
+
const first = require("./helpers/first");
|
|
35
|
+
const last = require("./helpers/last");
|
|
36
|
+
const ceil = require("./helpers/ceil");
|
|
37
|
+
const floor = require("./helpers/floor");
|
|
38
|
+
|
|
39
|
+
const polygon = require("./helpers/profiles/polygon");
|
|
40
|
+
const gauge = require("./helpers/profiles/gauge");
|
|
41
|
+
const bar = require("./helpers/profiles/bar");
|
|
42
|
+
|
|
43
|
+
const helpers = {
|
|
44
|
+
isArray,
|
|
45
|
+
addCommas,
|
|
46
|
+
boolean,
|
|
47
|
+
math,
|
|
48
|
+
modulo,
|
|
49
|
+
ternary,
|
|
50
|
+
lineWrap,
|
|
51
|
+
wrapOnNewline,
|
|
52
|
+
ellipsisLines,
|
|
53
|
+
ellipsisChars,
|
|
54
|
+
setVar,
|
|
55
|
+
assignGlobal,
|
|
56
|
+
forLoop,
|
|
57
|
+
concat,
|
|
58
|
+
sin,
|
|
59
|
+
cos,
|
|
60
|
+
tan,
|
|
61
|
+
toDeg,
|
|
62
|
+
toRad,
|
|
63
|
+
roundToTwo,
|
|
64
|
+
objectEntries,
|
|
65
|
+
object,
|
|
66
|
+
array,
|
|
67
|
+
reverse,
|
|
68
|
+
prepend,
|
|
69
|
+
polarToCartesian,
|
|
70
|
+
abs,
|
|
71
|
+
getArrOfProp,
|
|
72
|
+
displacePoint,
|
|
73
|
+
normalizeAngle,
|
|
74
|
+
withGroup,
|
|
75
|
+
join,
|
|
76
|
+
split,
|
|
77
|
+
first,
|
|
78
|
+
last,
|
|
79
|
+
ceil,
|
|
80
|
+
floor,
|
|
81
|
+
polygon,
|
|
82
|
+
gauge,
|
|
83
|
+
bar,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = helpers;
|