Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove indices in TableColumn and add explicit colouring for enums #2030

Merged
merged 10 commits into from
Sep 13, 2016
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