From ce78b5cc0fc0cfb0f7da3471db4c6cb5674bcbb3 Mon Sep 17 00:00:00 2001 From: marohrdanz Date: Tue, 11 Aug 2020 13:32:21 -0500 Subject: [PATCH 1/5] Add option to choose draw order for points Added an option to the gear menu for user to choose which order to draw points: random (same seed each time), random (different seed each time), original (same order as NGCHM), or according to batch size (largest batch drawn first, then second largest, etc). Addresses #2 --- canvasDraw.js | 40 ++++++++++++++++++++++++++++++++++++++++ demo-only.html | 2 +- ngchm.js | 18 +++++++++++++++--- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/canvasDraw.js b/canvasDraw.js index 88ccc44..215bb3d 100755 --- a/canvasDraw.js +++ b/canvasDraw.js @@ -370,6 +370,11 @@ function initializeOptions(plotOptions) { op.yLabel = plotOptions.hasOwnProperty('yLabel') ? plotOptions.yLabel : 'y data'; op.plotTitle = plotOptions.hasOwnProperty('plotTitle') ? plotOptions.plotTitle : 'Plot Title'; op.legendTitle = plotOptions.hasOwnProperty('legendTitle') ? plotOptions.legendTitle : 'Legend Title'; + op.drawOrder = plotOptions.hasOwnProperty('drawOrder') ? plotOptions.drawOrder : 'original'; + if (!['original','randomSameSeed','randomDifferentSeed','batches'].includes(op.drawOrder)) { + console.warn("Invalid draw order for points. Setting to 'original'") + op.drawOrder = 'original'; + } return op } @@ -521,6 +526,40 @@ function findDuplicates(array) { return array.filter(a => a in objTmp ? true : (objTmp[a] = true) && false, objTmp) } +/* Function to set the order of points for drawing + * + * Parameters: + * data: array of objects, each representing one data point, and of the form: + * { batch: , color: , id: , text: