@measurequick/measurequick-report-generator 1.0.97 → 1.0.99

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.
@@ -1,525 +0,0 @@
1
- import * as graphics from "../templates/js/graphics.js";
2
- import * as templates from "../templates/js/templates.js";
3
- import * as request from "../templates/js/request.js";
4
-
5
- let jsPDF = require("jspdf");
6
- let doc;
7
- let reportData;
8
- let currentSnapshot;
9
-
10
- export function generateReport(reportType, payload) {
11
- try {
12
- doc = new jsPDF(templates.docOptions);
13
- reportData = JSON.parse(JSON.stringify(payload));
14
- printBoilerPlateStandard();
15
- printHeaderData();
16
- printBodyData(reportData.test);
17
- printFooterData();
18
- resizeAndPrintStaticImages();
19
- printDiagnosticPage();
20
- printInfoPage();
21
- printPhotoPages();
22
- return doc.output("datauristring");
23
- } catch (e) {
24
- return doc.output("datauristring");
25
- }
26
- }
27
-
28
- function printBoilerPlateStandard() {
29
- let theme = JSON.parse(reportData.reportSettings).colorTheme;
30
- if (theme == "dark") {
31
- doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
32
- doc.addImage(graphics.footerMeasureQuick, "JPEG", 0, 7.75, 8.5, 4.5);
33
- }
34
- let mqLogo = theme == "dark" ? graphics.companyLogoMeasureQuickLight : graphics.companyLogoMeasureQuickDark;
35
- doc.addImage(mqLogo, "JPEG", .25, 10, 2.15625, .5);
36
- doc.setLineWidth(0.025);
37
- doc.setDrawColor(0);
38
- doc.setFillColor(242, 242, 242);
39
- doc.rect(.125, 1.125, 2.667, 3, "F");
40
- doc.rect(2.917, 1.125, 2.667, 3, "F");
41
- doc.rect(5.709, 1.125, 2.667, 3, "F");
42
- doc.rect(.125, 4.25, 4.0625, 3.375, "F");
43
- let bgIcons = templates[`${reportData.meta.reportType}BgIcons`];
44
- doc.addImage(graphics[bgIcons.iconSection1], "JPEG", .4585, 1.625, 2, 2);
45
- doc.addImage(graphics[bgIcons.iconSection2], "JPEG", 3.252, 1.625, 2, 2);
46
- doc.addImage(graphics[bgIcons.iconSection3], "JPEG", 6.044, 1.625, 2, 2);
47
- doc.addImage(graphics[bgIcons.iconSection4], "JPEG", 1.15625, 4.9375, 2, 2);
48
- doc.setFontStyle("bold");
49
- doc.setFontSize(9);
50
- let headers = templates[`${reportData.meta.reportType}Headers`];
51
- doc.text(headers.headerSection1, .25, 1.33);
52
- doc.text(headers.headerSection2, 3.042, 1.33);
53
- doc.text(headers.headerSection3, 5.834, 1.33);
54
- doc.text(headers.headerSection4, .25, 4.435);
55
- doc.setFontSize(8);
56
- doc.text(headers.headerSection4Subsection1, .25, 4.655);
57
- doc.text(headers.headerSection4Subsection2, 2.25, 4.655);
58
- let subsectionY = headers.headerSection4Subsection3 == 'Energy' ? 5.855 : 5.655;
59
- doc.text(headers.headerSection4Subsection3, 2.25, subsectionY);
60
- doc.setFontSize(6.5);
61
- doc.setFontStyle("bolditalic");
62
- theme == "dark" ? doc.setTextColor(255, 255, 255) : doc.setTextColor(0, 0, 0);
63
- let disclaimer = `Disclaimer: This report was prepared by your service technician who is solely responsible for its content. This report is provided “as-is” excluding all warranties expressed or implied including without limitation the warranty of merchantability. ©2017-${new Date().getFullYear()} Manifold Cloud Services Ltd.`;
64
- disclaimer = doc.splitTextToSize(disclaimer.toUpperCase(), 8);
65
- doc.text(disclaimer, .125, 10.66);
66
- doc.setTextColor(255, 255, 255);
67
- }
68
-
69
- function printBoilerPlateDiagnostic() {
70
- if (JSON.parse(reportData.reportSettings).colorTheme == "dark") doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
71
- doc.setFontSize(12);
72
- doc.setFontStyle("bold");
73
- JSON.parse(reportData.reportSettings).colorTheme == "dark" ? doc.setTextColor(255, 255, 255) : doc.setTextColor(0, 0, 0);
74
- doc.text("Diagnostic Report", .25, .35);
75
- doc.setTextColor(255, 255, 255);
76
- doc.setLineWidth(0.025);
77
- doc.setDrawColor(0);
78
- doc.setFillColor(242, 242, 242);
79
- doc.setTextColor(0, 0, 0);
80
- doc.setFontSize(9);
81
- doc.setFontStyle('bold');
82
- doc.rect(.125, 3.3, 8.25, 7.6, "F");
83
- doc.rect(.125, .6, 4.0625, 2.6, "F");
84
- doc.rect(4.3125, .6, 4.0625, 2.6, "F");
85
- doc.text("System Diagnostics", 4.4375, .8);
86
- doc.text("Subsystem Review", .25, .8);
87
- doc.text('Corrective Actions', .25, 3.5);
88
- doc.setFontSize(8);
89
- doc.setFontStyle('normal');
90
- }
91
-
92
- function printHeaderData() {
93
- let size = 13.5;
94
- do { size -= .5; } while ((doc.getStringUnitWidth(reportData.meta.reportName) * size / 72) > 4.5);
95
- doc.setFontSize(size);
96
- doc.setFontStyle("bold");
97
- JSON.parse(reportData.reportSettings).colorTheme == "dark" ? doc.setTextColor(255, 255, 255) : doc.setTextColor(0, 0, 0);
98
- doc.text(reportData.meta.reportName, 0.25, .75);
99
- doc.setTextColor(255, 255, 255);
100
- }
101
-
102
- function printBodyData(currentSnapshot) {
103
- doc.setTextColor(0, 0, 0);
104
- doc.setFontType("normal");
105
- doc.setFontSize(8);
106
- if (reportData.meta.reportType == "mqCooling") {
107
- printBodySection(currentSnapshot, "outdoorMeasurements", .25, 2.317, 1.55);
108
- printBodySection(currentSnapshot, "indoorMeasurements", 3.042, 5.109, 1.55);
109
- printBodySection(currentSnapshot, "systemProfileWeatherData", 5.834, 7.9, 1.55);
110
- printBodySection(currentSnapshot, "performanceData", .25, 2, 4.855);
111
- } else if (reportData.meta.reportType == "mqHeating") {
112
- printBodySection(currentSnapshot, "combustion", .25, 2.317, 1.55);
113
- printBodySection(currentSnapshot, "electricalMeasurements", 3.042, 5.109, 1.55);
114
- printBodySection(currentSnapshot, "systemProfileWeatherDataGas", 5.834, 7.9, 1.55);
115
- printBodySection(currentSnapshot, "performanceMetrics", .25, 2, 4.855);
116
- }
117
- printGeolocationMap();
118
- }
119
-
120
- function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y) {
121
- let dataPoints = JSON.parse(currentSnapshot[measurementSection]);
122
- let units = "";
123
- let labelText = "";
124
- let valueText = "";
125
- let yTop = y;
126
- let s = .18;
127
- // let sMultiplier = measurementSection == "performanceData" ? 2 : 1;
128
- let sMultiplier = 1;
129
-
130
- for (let key in dataPoints.values) {
131
- if (key == "condenserVoltageSource" || key == "condenserAmperageSource" || key == "airHandlerVoltageSource" || key == "airHandlerAmperageSource") break;
132
- let dataPoint = dataPoints.values[key];
133
- let valueBeforeEditing = dataPoint;
134
- let templateRef = templates[measurementSection][key];
135
- if (templateRef) {
136
- labelText = templateRef.label;
137
- if (templateRef.hasOwnProperty("units")) {
138
- units = Array.isArray(templateRef.units) ? `(${templateRef.units[0]} / ${templateRef.units[1]})` : `(${templateRef.units})`;
139
- labelText += ` ${units}:`;
140
- if ((key == "condenserVoltage" || key == "condenserAmperage" || key == "airHandlerVoltage" || key == "airHandlerAmperage") && dataPoints.values[`${key}Source`])
141
- doc.addImage(graphics[dataPoints.values[`${key}Source`]], "JPEG", xRight + .25, y - .12, .16, .16);
142
- } else labelText += ':';
143
- if (templateRef.hasOwnProperty("roundTo")) {
144
- dataPoint *= 1;
145
- dataPoint = dataPoint.toFixed(templateRef.roundTo);
146
- }
147
- if (templateRef.hasOwnProperty("secondaryValue")) {
148
- let secondaryDataPoint = dataPoints.values[templateRef.secondaryValue];
149
- if (templateRef.hasOwnProperty("roundTo")) {
150
- secondaryDataPoint *= 1;
151
- secondaryDataPoint = secondaryDataPoint.toFixed(templateRef.roundTo);
152
- }
153
- valueText = `${dataPoint} / ${secondaryDataPoint}`;
154
- } else valueText = `${dataPoint}`;
155
- if (templateRef.label) doc.text(labelText, xLeft, y);
156
- if (!valueText) valueText = "--";
157
- let fs = 8;
158
- if (key == "capacityActualNormalized" || key == "capacitySensibleNormalized" || key == "capacityLatentNormalized") {
159
- doc.setFontSize(6);
160
- fs = 6;
161
- y -= .05;
162
- }
163
- doc.text(valueText, alignRight(valueText, xRight, fs), y);
164
- if (key == "capacityActualNormalized" || key == "capacitySensibleNormalized" || key == "capacityLatentNormalized") {
165
- doc.setFontSize(8);
166
- y += .05;
167
- }
168
- if (JSON.parse(reportData.reportSettings).includeRangeIndicators) {
169
- let rangeIconRef = getRangeIcon(key, valueBeforeEditing, currentSnapshot);
170
- if (rangeIconRef) doc.addImage(graphics[rangeIconRef], "JPEG", xRight + .05, y - .12, .16, .16);
171
- }
172
- let toolIconRef = getToolIcon(JSON.parse(currentSnapshot.toolIcons)[key]);
173
- if (toolIconRef) doc.addImage(graphics[toolIconRef], "JPEG", xRight + .25, y - .12, .16, .16);
174
- else if (currentSnapshot.calculated && JSON.parse(currentSnapshot.calculated)[key]) doc.addImage(graphics.iconCalculator, "JPEG", xRight + .25, y - .12, .16, .16);
175
- y += (s * sMultiplier);
176
- } else if (key == "newColumn") {
177
- sMultiplier = 1;
178
- xLeft = 2.25;
179
- xRight = 3.9;
180
- y = yTop;
181
- } else if (key == "newRow") {
182
- y += .35;
183
- } else console.log("No Template Found for: " + key);
184
- }
185
- }
186
-
187
- function printGeolocationMap() {
188
- doc.addImage(reportData.staticPhotos.geolocationMap, "PNG", 4.3125, 4.25, 4.0625, 3.375);
189
- }
190
-
191
- function printProfilePicture() {
192
- let coords = templates.profilePictureCoordinates[reportData.project.profilePicturePlacement];
193
- doc.addImage(reportData.staticPhotos.profilePicture, "JPEG", coords.x, coords.y, coords.w, coords.h);
194
- doc.text(reportData.meta.techName, alignRight(reportData.meta.techName, 8.4, 8), coords.y + 1.2);
195
- }
196
-
197
- function printCompanyLogo() {
198
- let coords = templates.companyLogoCoordinates[reportData.meta.companyLogoPlacement];
199
- doc.addImage(reportData.staticPhotos.companyLogo, "JPEG", coords.x, coords.y, coords.w, coords.h);
200
- }
201
-
202
- function printFooterData() {
203
- let s = .15;
204
- let x = .2;
205
- let y = 8;
206
- let equipmentLabels = ["Make", "Model", "Serial"];
207
- let i = -1;
208
- doc.setTextColor(255, 255, 255);
209
- doc.setFontType("bold");
210
- doc.setFontSize(12);
211
- doc.text("Customer", x, y);
212
- doc.text("Equipment", x + 2.5, y);
213
- doc.setFontSize(8);
214
- y += .2;
215
- doc.setFontSize(10);
216
- y += .05;
217
- let footer = JSON.parse(reportData.footerData);
218
- for (let key in footer) {
219
- doc.setFontType("normal");
220
- if (key.includes("header")) {
221
- i = 0;
222
- doc.setFontStyle("bold");
223
- y += .1;
224
- } else if (key == "systemCoords") {
225
- s = .12;
226
- x += 2.5;
227
- y = 8.2;
228
- doc.setFontStyle("bold");
229
- doc.setFontSize(8);
230
- doc.text("ID", x, y);
231
- doc.setFontStyle("normal");
232
- y += s;
233
- }
234
- let prefix = "";
235
- if (i > -1) {
236
- prefix = `${equipmentLabels[i]}: `;
237
- i++;
238
- }
239
- doc.text(`${prefix}${footer[key]}`, x, y);
240
- y += s;
241
- }
242
- }
243
-
244
- function printDiagnosticPage() {
245
- doc.addPage();
246
- printBoilerPlateDiagnostic();
247
- printSubsystemReview();
248
- printSystemDiagnostics();
249
- printCorrectiveActions();
250
- }
251
-
252
- function printSubsystemReview() {
253
- let y = 1;
254
- let templateRef = templates[`${reportData.meta.reportType}SubsystemReview`];
255
- let ssr = JSON.parse(reportData.subsystemReview);
256
- for (let i = 0; i < Object.keys(ssr).length; i++) {
257
- let key = Object.keys(ssr)[i];
258
- doc.setTextColor(0, 0, 0);
259
- doc.text(templateRef[key], .25, y);
260
- setColor(ssr[key]);
261
- doc.text(ssr[key], 3, y);
262
- y += .15;
263
- };
264
- }
265
-
266
- function printSystemDiagnostics() {
267
- let y = 1;
268
- let diagnostics = JSON.parse(reportData.systemDiagnostics);
269
- for (let i = 0; i < Object.keys(diagnostics).length; i++) {
270
- let key = Object.keys(diagnostics)[i];
271
- let score = diagnostics[key].score;
272
- let diagnosticIcon = graphics.iconFlagGreen;
273
- if (diagnostics[key].type === 'stability') diagnosticIcon = graphics.iconStability;
274
- else if (score > 1 && score < 10) diagnosticIcon = graphics.iconFlagRed;
275
- else if (score >= 10 && score < 15) diagnosticIcon = graphics.iconFlagYellow;
276
- else if (score >= 15) diagnosticIcon = graphics.iconFlagBlack;
277
- if (diagnosticIcon) doc.addImage(diagnosticIcon, "PNG", 7.8, y + .1, .18, .18);
278
- y += .2;
279
- doc.text(diagnostics[key].title, 4.4375, y);
280
- doc.text(`${diagnostics[key].score}`, 7.5, y);
281
- }
282
- }
283
-
284
- function printCorrectiveActions() {
285
- let y = 3.8;
286
- doc.setFontSize(9);
287
- doc.setTextColor(0, 0, 0);
288
- let ca = JSON.parse(reportData.correctiveActions);
289
- for (let i = 0; i < Object.keys(ca).length; i++) {
290
- let sectionKey = Object.keys(ca)[i];
291
- for (let j = 0; j < Object.keys(ca[sectionKey]).length; j++) {
292
- let actionKey = Object.keys(ca[sectionKey])[j];
293
- let action = ca[sectionKey][actionKey];
294
- if (actionKey == "header") {
295
- doc.setFontSize(9);
296
- doc.setFontStyle("bold");
297
- doc.text(action, .25, y);
298
- } else {
299
- doc.setFontSize(8);
300
- doc.setFontStyle("normal");
301
- doc.text(getCorrectiveActionNameFromTag(actionKey), .25, y);
302
- }
303
- y += .18;
304
- }
305
- y += .1;
306
- }
307
- }
308
-
309
- function printPhotoPages() {
310
- let photoSectionMapping = ["project", "equipment", "site", "customer"];
311
- let x, y, header, currentQuadrant, currentSection;
312
- for (let i = 0; i < 4; i++) { // loops through the 4 main sections of photos, listed above (photoSectionMapping)
313
- currentSection = reportData[`${photoSectionMapping[i]}Photos`];
314
- if (Object.keys(currentSection).length > 0) doc.addPage();
315
- else break;
316
- currentQuadrant = 1;
317
- x = templates.photoCoordinates[`quadrant${currentQuadrant}`].x;
318
- y = templates.photoCoordinates[`quadrant${currentQuadrant}`].y;
319
- doc.setFontStyle("bold");
320
- doc.text(`${photoSectionMapping[i][0].toUpperCase()}${photoSectionMapping[i].slice(1)} Photos`, x, y - .2);
321
- doc.setFontStyle("normal");
322
- for (let key in currentSection) { // loops through the "subsections" of each main photo section
323
- if (currentSection[key].photos) {
324
- for (let j = 0; j < currentSection[key].photos.length; j++) { // loops through the photos[] array within each subsection, of each main photo section
325
- let currentPhoto = currentSection[key].photos[j];
326
- if (currentQuadrant === 3) {
327
- doc.setLineWidth(0.025);
328
- doc.setDrawColor(194, 197, 204);
329
- doc.line(.25, 5.5, 8.25, 5.5);
330
- } else if (currentQuadrant === 5) {
331
- doc.addPage();
332
- currentQuadrant = 1;
333
- }
334
- x = templates.photoCoordinates[`quadrant${currentQuadrant}`].x;
335
- y = templates.photoCoordinates[`quadrant${currentQuadrant}`].y;
336
- if (currentPhoto.base64) {
337
- doc.text(getPhotoSectionNameFromTag(currentPhoto.tag), x, y);
338
- let wPicMax = 3.75,
339
- hPicMax = 4,
340
- wPic = wPicMax,
341
- hPic = hPicMax,
342
- r = currentPhoto.aspect_ratio * 1;
343
- if (r >= 1) { // logo is a landscape image
344
- wPic = wPicMax;
345
- hPic = wPic / r;
346
- if (hPic > hPicMax) { // calculated h is too large for the available space
347
- hPic = hPicMax;
348
- wPic = hPic * r;
349
- }
350
- } else { // logo is a portrait image
351
- hPic = hPicMax;
352
- wPic = hPic * r;
353
- if (wPic > wPicMax) { // calculated w is too large for the available space
354
- wPic = wPicMax;
355
- hPic = wPic / r;
356
- }
357
- }
358
- doc.addImage(currentPhoto.base64, "JPEG", x, y + .1, wPic, hPic);
359
- }
360
- currentQuadrant++;
361
- }
362
- if (currentSection[key].hasNotes && currentSection[key].notes != "") {
363
- let notes = doc.splitTextToSize(`${currentSection[key].notes}`, 7.5);
364
- doc.setFontStyle("bold");
365
- doc.text("Notes:", x, y + hPic + .3);
366
- doc.setFontStyle("normal");
367
- doc.text(notes, x, y + hPic + .4);
368
- }
369
- }
370
- }
371
- }
372
- }
373
-
374
- function printInfoPage() {
375
- let infoPage = templates[`${reportData.meta.reportType}InfoPage`];
376
- doc.addPage();
377
- doc.setTextColor(0, 0, 0);
378
- doc.setFontStyle("bold");
379
- doc.setFontSize(14);
380
- doc.text(infoPage.header, .5, .6);
381
- doc.setFontSize(12);
382
- for (let i = 0; i < infoPage.subheader.length; i++) {
383
- let y = infoPage.y[i];
384
- if (y == .6) doc.addPage();
385
- doc.setFontStyle("bold");
386
- doc.text(infoPage.subheader[i], .5, y);
387
- y += .2;
388
- doc.setFontStyle("normal");
389
- doc.text(doc.splitTextToSize(infoPage.body[i], 7.5), .5, y);
390
- }
391
- }
392
-
393
- function getPhotoSectionNameFromTag(tag) {
394
- let tagPrefixRemoved = tag.substr(tag.indexOf('_'));
395
- let tagUnderscoresReplaced = tagPrefixRemoved.replaceAll('_', ' ');
396
- let sectionName = `${tagUnderscoresReplaced.charAt(0).toUpperCase()}${tagUnderscoresReplaced.slice(1)}`;
397
- return sectionName;
398
- }
399
-
400
- function getCorrectiveActionNameFromTag(tag) {
401
- let tagUnderscoresReplaced = tag.replaceAll('_', ' ');
402
- let sectionName = `${tagUnderscoresReplaced.charAt(0).toUpperCase()}${tagUnderscoresReplaced.slice(1)}`;
403
- return sectionName;
404
- }
405
-
406
- function resizeAndPrintStaticImages() {
407
- if (!reportData.reportSettings || !reportData.profileSettings) return null;
408
- let pdfSettings = JSON.parse(reportData.reportSettings);
409
- let profileSettings = JSON.parse(reportData.profileSettings);
410
- let wMax = 2.25,
411
- hMax = .7,
412
- x_profile = 6.9,
413
- y_profile = 8.13,
414
- size_profile = 1.25,
415
- x_name = 8.15,
416
- y_name = 8.025,
417
- r = profileSettings.aspectRatioCompanyPhoto,
418
- xOffset = 0,
419
- yOffset = 0,
420
- w = 0,
421
- h = 0,
422
- x = 6,
423
- y = .2;
424
- if (pdfSettings.locationCompanyLogo !== "header") {
425
- x = 6;
426
- y = 8;
427
- x_profile = 7.375;
428
- y_profile = .15;
429
- size_profile = pdfSettings.colorTheme === 'dark' ? .8 : .9;
430
- x_name = 7.25;
431
- y_name = .5;
432
- wMax = 2.25;
433
- hMax = .8
434
- }
435
- if (r >= 1) {
436
- w = wMax;
437
- h = w / r;
438
- if (h > hMax) {
439
- h = hMax;
440
- w = h * r;
441
- }
442
- } else {
443
- h = hMax;
444
- w = h * r;
445
- if (w > wMax) {
446
- w = wMax;
447
- h = w / r;
448
- }
449
- }
450
- if (w < wMax) x = 8.5 - .25 - w;
451
- doc.setFontSize(12);
452
- doc.setFontType("bold");
453
- doc.setTextColor(255, 255, 255);
454
-
455
- if (pdfSettings.locationCompanyLogo == "Header" && h < hMax)
456
- y = y + ((hMax - h) / 2);
457
-
458
- if (profileSettings.base64CompanyPhoto && pdfSettings.includeCompanyLogo)
459
- doc.addImage(profileSettings.base64CompanyPhoto, "PNG", x, y, w, h);
460
-
461
- if ((profileSettings.base64ProfilePhotoCircle || profileSettings.base64ProfilePhotoSquare) && pdfSettings.includeProfileImage) {
462
- let profileImage = profileSettings.base64ProfilePhotoCircle;
463
- if (profileSettings.shapeProfileImage == "circle")
464
- profileImage = profileSettings.base64ProfilePhotoSquare;
465
- if (profileImage)
466
- doc.addImage(profileImage, "PNG", x_profile, y_profile, size_profile, size_profile);
467
- if (profileSettings.techName) {
468
- doc.setTextColor(0, 0, 0);
469
- doc.text(profileSettings.techName, x_profile, y_profile + size_profile);
470
- doc.setTextColor(255, 255, 255);
471
- }
472
- }
473
- }
474
-
475
- function getToolIcon(measurementSource) {
476
- switch (measurementSource) {
477
- case "Fieldpiece": return "companyLogoFieldpiece";
478
- case "Testo": return "companyLogoTesto";
479
- case "UEi HUB": return "companyLogoUei";
480
- case "iManifold Model 900M": return "companyLogoImanifold";
481
- case "iConnect Model 900C": return "companyLogoIconnect";
482
- case "Sporlan Pro/R": return "companyLogoSporlanPro";
483
- case "Sporlan Legacy": return "companyLogoSporlanLegacy";
484
- case "iDVM550": return "companyLogoRedfish550";
485
- case "iDVM510": return "companyLogoRedfish510333";
486
- case "iDVM510": return "companyLogoRedfish510";
487
- case "BluFlame": return "companyLogoBluflame";
488
- case "ComfortGuard": return "companyLogoSensi";
489
- default: return null;
490
- }
491
- }
492
-
493
- function setColor(measure) {
494
- if (measure == 'Pass') doc.setTextColor(55, 99, 45);
495
- else if (measure == 'Fail') doc.setTextColor(157, 45, 54);
496
- else doc.setTextColor(0,0,0);
497
- }
498
-
499
- function getRangeIcon(key, actualValue, currentSnapshot) {
500
- // Special Case
501
- let rangeIconRef = null;
502
- if (key == 'systemBenchmarked') {
503
- if (actualValue == 'Yes') rangeIconRef = "iconThumbprintGreen";
504
- else if (actualValue == 'Yes, under duress') rangeIconRef = "iconCautionTriangleYellow";
505
- else rangeIconRef = "iconThumbprintRed";
506
- } else {
507
- let ranges = JSON.parse(currentSnapshot.rangeIcons);
508
- let target = null, low = null, high = null;
509
- if (ranges[key]) {
510
- target = parseFloat(ranges[key]);
511
- if (ranges[`${key}_ideal_low`]) low = target - parseFloat(ranges[`${key}_ideal_low`]);
512
- if (ranges[`${key}_ideal_high`]) high = target + parseFloat(ranges[`${key}_ideal_high`]);
513
- if (target && low && high) {
514
- if (actualValue < low) rangeIconRef = "iconRangeLow";
515
- else if (actualValue > high) rangeIconRef = "iconRangeHigh";
516
- else rangeIconRef = "iconRangeNormal";
517
- }
518
- }
519
- }
520
- return rangeIconRef;
521
- }
522
-
523
- function alignRight(text, rightAlign, fontSize) {
524
- return rightAlign - doc.getStringUnitWidth(text) * fontSize / 72;
525
- }