js/visualisation.js
/**
	 * When all colours are fixed for a discrete attribute
	 * Anything not specified will be shown in the first unused colour.
	 * Attributes can be grouped using labels that map attribute name -> label
	 **/
When all colours are fixed for a discrete attribute
Anything not specified will be shown in the first unused colour.
Attributes can be grouped using labels that map attribute name -> label
When all colours are fixed for a discrete attribute Anything not specified will be shown in the first unused colour . Attributes can be grouped using labels that map attribute name - > label
custom(data,attribute, values, labels) {
		this.attr = attribute;
		let usedIndices = new Set();
		for(let a in values) {
			if(values.hasOwnProperty(a)) {
				let index = -1;
				for(let i = 0; index == -1 && i < this.colourNames.length; i++) {
					if(this.colourNames[i] == values[a])
						index = i;
				}
				usedIndices.add(index);
				this.attrIndex[a] = index;
				this.labels[index] = a;
			}
		}
		this.baseIndex = -1;
		for(let i = 0; this.baseIndex == -1 && i < this.colours.length; i++)
			if(!usedIndices.has(i))
				this.baseIndex = i;
		for(let i = 0; i < data.data.length; i++) {
			let a = data.data[i][this.attr];
			if(!this.attrIndex.hasOwnProperty(a)) {
				this.labels[this.baseIndex] = "Other";
				this.attrIndex["Other"] = this.baseIndex;
				break;
			}
		}
		for(let a in this.attrIndex)
			if(this.attrIndex.hasOwnProperty(a) && this.attrIndex[a] == -1)
				this.attrIndex[a] = this.baseIndex;
		if(typeof labels != 'undefined') {
			for(let label in labels) { 
				if(this.attrIndex.hasOwnProperty(label)) {
					let index = this.attrIndex[label];
					this.labels[index] = labels[label];
				}
				else console.log("WARNING: grouping "+label+" but no such attribute.");
			}
		}
		return this;
	}
custom ( data , attribute , values , labels ) { this . attr = attribute ; let usedIndices = new Set ( ) ; for ( let a in values ) { if ( values . hasOwnProperty ( a ) ) { let index = - 1 ; for ( let i = 0 ; index == - 1 && i < this . colourNames . length ; i ++ ) { if ( this . colourNames [ i ] == values [ a ] ) index = i ; } usedIndices . add ( index ) ; this . attrIndex [ a ] = index ; this . labels [ index ] = a ; } } this . baseIndex = - 1 ; for ( let i = 0 ; this . baseIndex == - 1 && i < this . colours . length ; i ++ ) if ( ! usedIndices . has ( i ) ) this . baseIndex = i ; for ( let i = 0 ; i < data . data . length ; i ++ ) { let a = data . data [ i ] [ this . attr ] ; if ( ! this . attrIndex . hasOwnProperty ( a ) ) { this . labels [ this . baseIndex ] = "Other" ; this . attrIndex [ "Other" ] = this . baseIndex ; break ; } } for ( let a in this . attrIndex ) if ( this . attrIndex . hasOwnProperty ( a ) && this . attrIndex [ a ] == - 1 ) this . attrIndex [ a ] = this . baseIndex ; if ( typeof labels != 'undefined' ) { for ( let label in labels ) { if ( this . attrIndex . hasOwnProperty ( label ) ) { let index = this . attrIndex [ label ] ; this . labels [ index ] = labels [ label ] ; } else console . log ( "WARNING: grouping " + label + " but no such attribute." ) ; } } return this ; }
When all colours are fixed for a discrete attribute
 Anything not specified will be shown in the first unused colour.
When all colours are fixed for a discrete attribute Anything not specified will be shown in the first unused colour .
//assign colours to indices //now find an unused colour for all other attributes //TODO:.. if none are found, create a grey colour // if any other attribute values exist, assign an "other" label to the base index //overwrite any labels. For a labelled attribute, update its index