Skip to content

Commit

Permalink
Merge pull request #2030 from TerriaJS/colormap_enum
Browse files Browse the repository at this point in the history
Remove indices in TableColumn and add explicit colouring for enums
  • Loading branch information
RacingTadpole authored Sep 13, 2016
2 parents 533a003 + 4898377 commit f92c416
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 171 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Change Log
* Refactored Csv, AbsItt and Sdmx-Json catalog items to depend on a common `TableCatalogItem`. Deprecated `CsvCatalogItem.setActiveTimeColumn` in favour of `tableStructure.setActiveTimeColumn`.
* Error in geocoding addresses in csv files now shows in dialog box.
* Fixed css styling of the timeline and added padding to the feature info panel.
* Deprecated `indicesIntoUniqueValues`, `indicesOrValues`, `indicesOrNumericalValues` & `usesIndicesIntoUniqueValues` in `TableColumn` (`isEnum` replaces `usesIndicesIntoUniqueValues`).
* Added support for explicitly colouring enum columns using a `tableStyle.colorBins` array of `{"value":v, "color":c}` objects
* Improved rendering speed when changing the display variable for large lat/lon csv files.
* Default to moving feature csvs if a time, lat, lon and a column named `id` are present.
* Fixed a bug so units flow through to charts of moving csv features.
Expand Down
30 changes: 29 additions & 1 deletion lib/Map/TableColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var DataSourceClock = require('terriajs-cesium/Source/DataSources/DataSourceCloc
var defaultValue = require('terriajs-cesium/Source/Core/defaultValue');
var defined = require('terriajs-cesium/Source/Core/defined');
var defineProperties = require('terriajs-cesium/Source/Core/defineProperties');
var deprecationWarning = require('terriajs-cesium/Source/Core/deprecationWarning');
var destroyObject = require('terriajs-cesium/Source/Core/destroyObject');
var DeveloperError = require('terriajs-cesium/Source/Core/DeveloperError');
var Iso8601 = require('terriajs-cesium/Source/Core/Iso8601');
Expand Down Expand Up @@ -249,6 +250,7 @@ defineProperties(TableColumn.prototype, {
*/
indicesIntoUniqueValues: {
get: function() {
deprecationWarning('indicesIntoUniqueValues', 'indicesIntoUniqueValues is deprecated. Please use uniqueValues instead');
if (this.usesIndicesIntoUniqueValues && !defined(this._indicesIntoUniqueValues)) {
var uniqueValues = this.uniqueValues; // Do not use this._uniqueValues since it may not exist yet.
this._indicesIntoUniqueValues = this._values.map(function(value) {
Expand All @@ -268,6 +270,7 @@ defineProperties(TableColumn.prototype, {
*/
indicesOrValues: {
get: function() {
deprecationWarning('indicesOrValues', 'indicesOrValues is deprecated. Please use values instead');
if (this.usesIndicesIntoUniqueValues) {
return this.indicesIntoUniqueValues; // Do not use this._indicesIntoUniqueValues since it may not exist yet.
} else {
Expand All @@ -285,6 +288,7 @@ defineProperties(TableColumn.prototype, {
*/
indicesOrNumericalValues: {
get: function() {
deprecationWarning('indicesOrNumericalValues', 'indicesOrNumericalValues is deprecated');
if (this.usesIndicesIntoUniqueValues) {
return this.indicesIntoUniqueValues; // Do not use this._indicesIntoUniqueValues since it may not exist yet.
} else {
Expand All @@ -301,11 +305,35 @@ defineProperties(TableColumn.prototype, {
*/
usesIndicesIntoUniqueValues: {
get: function() {
deprecationWarning('usesIndicesIntoUniqueValues', 'usesIndicesIntoUniqueValues is deprecated. Please use isEnum instead');
// In previous versions, also required isNaN(this._minimumValue).
return this._type === VarType.ENUM;
}
},

/**
* Gets the column's numerical values only.
* This is the quantity used for the legend.
* @memberOf TableColumn.prototype
* @type {Array}
*/
numericalValues: {
get: function() {
return this._numericalValues;
}
},

/**
* Returns whether this column is an ENUM type.
* @memberOf TableColumn.prototype
* @type {Boolean}
*/
isEnum: {
get: function() {
return this._type === VarType.ENUM;
}
},

/**
* Gets formatted values of this column.
* @memberOf TableColumn.prototype
Expand Down Expand Up @@ -346,7 +374,7 @@ defineProperties(TableColumn.prototype, {
*/
uniqueValues: {
get: function() {
if (this.usesIndicesIntoUniqueValues && !defined(this._uniqueValues)) {
if (this.isEnum && !defined(this._uniqueValues)) {
this._uniqueValues = getUniqueValues(this._values).filter(function(value) { return (value !== null); });
sortMostCommonFirst(this._values, this._uniqueValues);
}
Expand Down
Loading

0 comments on commit f92c416

Please sign in to comment.