diff --git a/canvasDraw.js b/canvasDraw.js index 88ccc44..44c90cc 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: