diff --git a/package-lock.json b/package-lock.json index 5a65b45..9fd1fe5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "safety-outlier-explorer", - "version": "2.5.4", + "version": "2.5.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -11,22 +11,21 @@ "dev": true }, "@types/node": { - "version": "10.12.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.21.tgz", - "integrity": "sha512-CBgLNk4o3XMnqMc0rhb6lc77IwShMEglz05deDcn2lQxyXEZivfwgYJu7SMha9V5XcrP6qZuevTHV/QrN2vjKQ==", + "version": "12.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.1.tgz", + "integrity": "sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==", "dev": true }, "acorn": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.7.tgz", - "integrity": "sha512-HNJNgE60C9eOTgn974Tlp3dpLZdUr+SoxxDwPaY9J/kDNOLQTkaDgwBUXAF4SSsrAwD9RpdxuHK/EbuF+W9Ahw==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.1.tgz", + "integrity": "sha512-JD0xT5FCRDNyjDda3Lrg/IxFscp9q4tiYtxE1/nOzlKCk7hIRuYjhq1kCNkbPjMRMZuFq20HNQn1I9k8Oj0E+Q==", "dev": true }, "adler-32": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", "integrity": "sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=", - "optional": true, "requires": { "exit-on-epipe": "~1.0.1", "printj": "~1.1.0" @@ -803,15 +802,23 @@ "dev": true }, "cfb": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.1.0.tgz", - "integrity": "sha512-ZqfxNGWTMKhd0a/n6YKJLq8hWbd5kR3cA4kXwUj9vVEdHlwJ09werR8gN15Z7Y1FTXqdD6dE3GGCxv4uc28raA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.1.3.tgz", + "integrity": "sha512-joXBW0nMuwV9no7UTMiyVJnQL6XIU3ThXVjFUDHgl9MpILPOomyfaGqC290VELZ48bbQKZXnQ81UT5HouTxHsw==", "optional": true, "requires": { "adler-32": "~1.2.0", "commander": "^2.16.0", "crc-32": "~1.2.0", "printj": "~1.1.2" + }, + "dependencies": { + "commander": { + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", + "optional": true + } } }, "chalk": { @@ -833,7 +840,7 @@ "integrity": "sha1-Ty5dfAl13ij4hJgFjcta/KtqX3E=", "optional": true, "requires": { - "commander": "^2.20.0", + "commander": "^3.0.0", "concat-stream": "^2.0.0", "voc": "^1.1.0" } @@ -845,10 +852,9 @@ "optional": true }, "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "optional": true + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-3.0.0.tgz", + "integrity": "sha512-pl3QrGOBa9RZaslQiqnnKX2J068wcQw7j9AIaBQ9/JEp5RY6je4jKTImg0Bd+rpoONSe7GUFSgkxLeo17m3Pow==" }, "concat-map": { "version": "0.0.1", @@ -878,7 +884,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.0.tgz", "integrity": "sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==", - "optional": true, "requires": { "exit-on-epipe": "~1.0.1", "printj": "~1.1.0" @@ -934,8 +939,7 @@ "exit-on-epipe": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", - "optional": true + "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" }, "frac": { "version": "0.3.1", @@ -953,10 +957,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": false, - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "optional": true + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "invariant": { "version": "2.2.2", @@ -991,7 +994,7 @@ "adler-32": "^1.2.0", "cfb": ">=0.10.0", "codepage": "~1.3.6", - "commander": "^2.20.0", + "commander": "^3.0.0", "crc-32": "^1.2.0", "jszip": "2.4.0", "ssf": "~0.8.1" @@ -999,7 +1002,6 @@ }, "jsesc": { "version": "0.5.0", - "resolved": false, "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", "dev": true }, @@ -1094,16 +1096,15 @@ "dev": true }, "prettier": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.17.1.tgz", - "integrity": "sha512-TzGRNvuUSmPgwivDqkZ9tM/qTGW9hqDKWOE9YHiyQdixlKbv7kvEqsmDPrcHJTKwthU774TQwZXVtaQ/mMsvjg==", + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", + "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", "dev": true }, "printj": { "version": "1.1.2", "resolved": "http://registry.npmjs.org/printj/-/printj-1.1.2.tgz", - "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==", - "optional": true + "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" }, "private": { "version": "0.1.8", @@ -1112,9 +1113,9 @@ "dev": true }, "readable-stream": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz", - "integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "optional": true, "requires": { "inherits": "^2.0.3", @@ -1147,7 +1148,6 @@ }, "regexpu-core": { "version": "2.0.0", - "resolved": false, "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", "dev": true, "requires": { @@ -1158,13 +1158,11 @@ }, "regjsgen": { "version": "0.2.0", - "resolved": false, "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", "dev": true }, "regjsparser": { "version": "0.1.5", - "resolved": false, "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", "dev": true, "requires": { @@ -1181,14 +1179,14 @@ } }, "rollup": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.1.2.tgz", - "integrity": "sha512-OkdMxqMl8pWoQc5D8y1cIinYQPPLV8ZkfLgCzL6SytXeNA2P7UHynEQXI9tYxuAjAMsSyvRaWnyJDLHMxq0XAg==", + "version": "1.19.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.19.4.tgz", + "integrity": "sha512-G24w409GNj7i/Yam2cQla6qV2k6Nug8bD2DZg9v63QX/cH/dEdbNJg8H4lUm5M1bRpPKRUC465Rm9H51JTKOfQ==", "dev": true, "requires": { "@types/estree": "0.0.39", - "@types/node": "*", - "acorn": "^6.0.5" + "@types/node": "^12.6.9", + "acorn": "^6.2.1" } }, "rollup-plugin-babel": { @@ -1211,9 +1209,9 @@ } }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", + "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", "optional": true }, "semver": { @@ -1246,12 +1244,12 @@ } }, "string_decoder": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", - "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "optional": true, "requires": { - "safe-buffer": "~5.1.0" + "safe-buffer": "~5.2.0" } }, "strip-ansi": { @@ -1277,7 +1275,6 @@ }, "trim-right": { "version": "1.0.1", - "resolved": false, "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, @@ -1289,20 +1286,18 @@ }, "util-deprecate": { "version": "1.0.2", - "resolved": false, "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "optional": true }, "voc": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/voc/-/voc-1.1.0.tgz", - "integrity": "sha512-fthgd8OJLqq8vPcLjElTk6Rcl2e3v5ekcXauImaqEnQqd5yUWKg1+ZOBgS2KTWuVKcuvZMQq4TDptiT1uYddUA==", - "optional": true + "integrity": "sha512-fthgd8OJLqq8vPcLjElTk6Rcl2e3v5ekcXauImaqEnQqd5yUWKg1+ZOBgS2KTWuVKcuvZMQq4TDptiT1uYddUA==" }, "webcharts": { - "version": "1.11.5", - "resolved": "https://registry.npmjs.org/webcharts/-/webcharts-1.11.5.tgz", - "integrity": "sha512-dI5Jr/O/A0m92e4PWLxzZSJ6d220r6s9IQgGeQm1hfM2LUUGH0HrEHcLGmf8yseN//31aT8QMFmlJEjOsQ7uew==", + "version": "1.11.6", + "resolved": "https://registry.npmjs.org/webcharts/-/webcharts-1.11.6.tgz", + "integrity": "sha512-sKbCxVoJhdP827oIaaVMgKVyQRJSfRQeKG8x2LuV0J4hmnkhBjs0iXkRd3uEA0nVfjB4HORdFKiAue2zLVxGNA==", "requires": { "d3": "^3", "js-xlsx": "^0.8.22" diff --git a/package.json b/package.json index 0cc3f60..bf6ab7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "safety-outlier-explorer", - "version": "2.5.4", + "version": "2.5.5", "description": "Chart showing participant trajectories of lab measures, vital signs and other related measures in clinical trials.", "module": "./src/index.js", "main": "./safetyOutlierExplorer.js", @@ -8,7 +8,7 @@ "license": "MIT", "dependencies": { "d3": "^3", - "webcharts": "^1.11.5" + "webcharts": "^1.11.6" }, "scripts": { "build": "npm audit fix && npm run bundle && npm run format && npm run build-wiki && npm run check-settings-schema", @@ -28,8 +28,8 @@ "babel-plugin-external-helpers": "^6.22.0", "babel-preset-env": "^1.7.0", "babel-register": "^6.26.0", - "prettier": "^1.17.1", - "rollup": "^1.1.2", + "prettier": "^1.18.2", + "rollup": "^1.19.4", "rollup-plugin-babel": "^3.0.7" } } diff --git a/safetyOutlierExplorer.js b/safetyOutlierExplorer.js index 45120c8..77b49bb 100644 --- a/safetyOutlierExplorer.js +++ b/safetyOutlierExplorer.js @@ -859,6 +859,12 @@ updateNormalRangeControl.call(this); } + function initCustomEvents() { + var chart = this; + chart.participantsSelected = []; + chart.events.participantsSelected = new CustomEvent('participantsSelected'); + } + function onInit() { // 1. Count number of unique participant IDs in data prior to data cleaning. countParticipants.call(this); @@ -874,6 +880,9 @@ // 5. Check controls. checkControls.call(this); + + // 6. Initialize custom events + initCustomEvents.call(this); } function identifyControls() { @@ -1587,6 +1596,11 @@ }); if (this.multiples.chart) this.multiples.chart.destroy(); delete this.selected_id; + + //Trigger participantsSelected event + this.participantsSelected = []; + this.events.participantsSelected.data = this.participantsSelected; + this.wrap.node().dispatchEvent(this.events.participantsSelected); } function addOverlayEventListener() { @@ -2009,6 +2023,11 @@ context.selected_id = context.multiples.id; highlightSelected.call(context); smallMultiples.call(context); + + //Trigger participantsSelected event + context.participantsSelected = [context.selected_id]; + context.events.participantsSelected.data = context.participantsSelected; + context.wrap.node().dispatchEvent(context.events.participantsSelected); }); } @@ -2060,6 +2079,11 @@ highlightSelected.call(_this); reorderMarks.call(_this); smallMultiples.call(_this); + + //Trigger participantsSelected event + _this.participantsSelected = [_this.selected_id]; + _this.events.participantsSelected.data = _this.participantsSelected; + _this.wrap.node().dispatchEvent(_this.events.participantsSelected); }); } @@ -2085,6 +2109,11 @@ highlightSelected.call(_this); reorderMarks.call(_this); smallMultiples.call(_this); + + //Trigger participantsSelected event + _this.participantsSelected = [_this.selected_id]; + _this.events.participantsSelected.data = _this.participantsSelected; + _this.wrap.node().dispatchEvent(_this.events.participantsSelected); }); } diff --git a/src/callbacks/onDraw/updateParticipantCount.js b/src/callbacks/onDraw/updateParticipantCount.js index 6180758..a1bcce4 100644 --- a/src/callbacks/onDraw/updateParticipantCount.js +++ b/src/callbacks/onDraw/updateParticipantCount.js @@ -14,8 +14,6 @@ export default function updateParticipantCount() { //update the annotation this.participantCount.container.text( - `\n${this.participantCount.n} of ${this.participantCount.N} participant(s) shown (${ - this.participantCount.percentage - })` + `\n${this.participantCount.n} of ${this.participantCount.N} participant(s) shown (${this.participantCount.percentage})` ); } diff --git a/src/callbacks/onInit.js b/src/callbacks/onInit.js index eef7572..3ad41b3 100644 --- a/src/callbacks/onInit.js +++ b/src/callbacks/onInit.js @@ -3,6 +3,7 @@ import cleanData from './onInit/cleanData'; import addVariables from './onInit/addVariables'; import defineSets from './onInit/defineSets'; import checkControls from './onInit/checkControls'; +import initCustomEvents from './onInit/initCustomEvents'; export default function onInit() { // 1. Count number of unique participant IDs in data prior to data cleaning. @@ -19,4 +20,7 @@ export default function onInit() { // 5. Check controls. checkControls.call(this); + + // 6. Initialize custom events + initCustomEvents.call(this); } diff --git a/src/callbacks/onInit/checkControls/removeFilters.js b/src/callbacks/onInit/checkControls/removeFilters.js index f495cef..8c20ed2 100644 --- a/src/callbacks/onInit/checkControls/removeFilters.js +++ b/src/callbacks/onInit/checkControls/removeFilters.js @@ -6,18 +6,14 @@ export default function removeFilters() { return true; } else if (!this.raw_data[0].hasOwnProperty(input.value_col)) { console.warn( - `The [ ${ - input.label - } ] filter has been removed because the variable does not exist.` + `The [ ${input.label} ] filter has been removed because the variable does not exist.` ); } else { const levels = set(this.raw_data.map(d => d[input.value_col])).values(); if (levels.length === 1) console.warn( - `The [ ${ - input.label - } ] filter has been removed because the variable has only one level.` + `The [ ${input.label} ] filter has been removed because the variable has only one level.` ); return levels.length > 1; diff --git a/src/callbacks/onInit/checkControls/updateMeasureFilter.js b/src/callbacks/onInit/checkControls/updateMeasureFilter.js index 63abc93..b742680 100644 --- a/src/callbacks/onInit/checkControls/updateMeasureFilter.js +++ b/src/callbacks/onInit/checkControls/updateMeasureFilter.js @@ -13,9 +13,7 @@ export default function updateMeasureFilter() { } else if (this.config.start_value && this.soe_measures.indexOf(this.config.start_value) < 0) { measureInput.start = this.soe_measures[this.measures.indexOf(this.config.start_value)]; console.warn( - `${this.config.start_value} is missing the units value. Defaulting to ${ - measureInput.start - }.` + `${this.config.start_value} is missing the units value. Defaulting to ${measureInput.start}.` ); } else measureInput.start = this.config.start_value || this.soe_measures[0]; } diff --git a/src/callbacks/onInit/cleanData/removeMissingResults.js b/src/callbacks/onInit/cleanData/removeMissingResults.js index efb258f..cfb8d6f 100644 --- a/src/callbacks/onInit/cleanData/removeMissingResults.js +++ b/src/callbacks/onInit/cleanData/removeMissingResults.js @@ -29,9 +29,7 @@ export default function removeMissingResults() { .map(d => d.key); if (this.removedRecords.placeholderRecords.length) console.log( - `${ - this.removedRecords.placeholderRecords.length - } participants without results have been detected.` + `${this.removedRecords.placeholderRecords.length} participants without results have been detected.` ); //Count the number of records with missing results. diff --git a/src/callbacks/onInit/initCustomEvents.js b/src/callbacks/onInit/initCustomEvents.js new file mode 100644 index 0000000..fb9ee21 --- /dev/null +++ b/src/callbacks/onInit/initCustomEvents.js @@ -0,0 +1,5 @@ +export default function initCustomEvents() { + var chart = this; + chart.participantsSelected = []; + chart.events.participantsSelected = new CustomEvent('participantsSelected'); +} diff --git a/src/callbacks/onResize/addEventListeners/addLineEventListeners.js b/src/callbacks/onResize/addEventListeners/addLineEventListeners.js index 9dbcea3..075f50e 100644 --- a/src/callbacks/onResize/addEventListeners/addLineEventListeners.js +++ b/src/callbacks/onResize/addEventListeners/addLineEventListeners.js @@ -23,5 +23,10 @@ export default function addLineEventListeners() { highlightSelected.call(this); reorderMarks.call(this); smallMultiples.call(this); + + //Trigger participantsSelected event + this.participantsSelected = [this.selected_id]; + this.events.participantsSelected.data = this.participantsSelected; + this.wrap.node().dispatchEvent(this.events.participantsSelected); }); } diff --git a/src/callbacks/onResize/addEventListeners/addPointEventListeners.js b/src/callbacks/onResize/addEventListeners/addPointEventListeners.js index eb39f28..338569d 100644 --- a/src/callbacks/onResize/addEventListeners/addPointEventListeners.js +++ b/src/callbacks/onResize/addEventListeners/addPointEventListeners.js @@ -23,5 +23,10 @@ export default function addPointEventListeners() { highlightSelected.call(this); reorderMarks.call(this); smallMultiples.call(this); + + //Trigger participantsSelected event + this.participantsSelected = [this.selected_id]; + this.events.participantsSelected.data = this.participantsSelected; + this.wrap.node().dispatchEvent(this.events.participantsSelected); }); } diff --git a/src/callbacks/onResize/addEventListeners/functions/clearSelected.js b/src/callbacks/onResize/addEventListeners/functions/clearSelected.js index 8756615..4d1867f 100644 --- a/src/callbacks/onResize/addEventListeners/functions/clearSelected.js +++ b/src/callbacks/onResize/addEventListeners/functions/clearSelected.js @@ -8,4 +8,9 @@ export default function clearSelected() { }); if (this.multiples.chart) this.multiples.chart.destroy(); delete this.selected_id; + + //Trigger participantsSelected event + this.participantsSelected = []; + this.events.participantsSelected.data = this.participantsSelected; + this.wrap.node().dispatchEvent(this.events.participantsSelected); } diff --git a/src/callbacks/onResize/addEventListeners/functions/smallMultiples/callbacks/onLayout/updateParticipantDropdown.js b/src/callbacks/onResize/addEventListeners/functions/smallMultiples/callbacks/onLayout/updateParticipantDropdown.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/callbacks/onResize/addEventListeners/functions/smallMultiples/updateParticipantDropdown.js b/src/callbacks/onResize/addEventListeners/functions/smallMultiples/updateParticipantDropdown.js index 6aae72b..b3a5c90 100644 --- a/src/callbacks/onResize/addEventListeners/functions/smallMultiples/updateParticipantDropdown.js +++ b/src/callbacks/onResize/addEventListeners/functions/smallMultiples/updateParticipantDropdown.js @@ -27,5 +27,10 @@ export default function updateParticipantDropdown() { context.selected_id = context.multiples.id; highlightSelected.call(context); smallMultiples.call(context); + + //Trigger participantsSelected event + context.participantsSelected = [context.selected_id]; + context.events.participantsSelected.data = context.participantsSelected; + context.wrap.node().dispatchEvent(context.events.participantsSelected); }); } diff --git a/src/configuration/syncSettings.js b/src/configuration/syncSettings.js index c0c6cfb..0e91b36 100644 --- a/src/configuration/syncSettings.js +++ b/src/configuration/syncSettings.js @@ -27,9 +27,7 @@ export default function syncSettings(settings) { //points const points = settings.marks.find(mark => mark.type === 'circle'); points.per = [settings.id_col, settings.measure_col, time_col.value_col, settings.value_col]; - points.tooltip = `Participant = [${settings.id_col}]\n[${settings.measure_col}] = [${ - settings.value_col - }] [${settings.unit_col}]\n${settings.x.label} = [${settings.x.column}]`; + points.tooltip = `Participant = [${settings.id_col}]\n[${settings.measure_col}] = [${settings.value_col}] [${settings.unit_col}]\n${settings.x.label} = [${settings.x.column}]`; //add custom tooltip values if (settings.tooltip_cols) { diff --git a/src/util/polyfills.js b/src/util/polyfills.js index 32225f3..b8097c7 100644 --- a/src/util/polyfills.js +++ b/src/util/polyfills.js @@ -125,3 +125,17 @@ Math.log10 = function(x) { return Math.log(x) * Math.LOG10E; }; + + + (function() { + if (typeof window.CustomEvent === 'function') return false; + + function CustomEvent(event, params) { + params = params || { bubbles: false, cancelable: false, detail: null }; + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + return evt; + } + + window.CustomEvent = CustomEvent; + })(); diff --git a/test-page/index.js b/test-page/index.js index 6a24c42..e8d4269 100644 --- a/test-page/index.js +++ b/test-page/index.js @@ -44,5 +44,11 @@ d3.csv( settings ); instance.init(data); + + //quick test of participantSelected event + instance.wrap.on("participantsSelected",function(){ + console.log("Participant Selected Event:") + console.log(d3.event.data) + }) } );