Class

Column

columns.Column(info, data, columnNames)

Constructor

# new Column(info, data, columnNames)

Initialize a column with checks, defaults, and stats calculation.

Parameters:
Name Type Description
info module:columns~ColumnInfo

column configuration

data Array

array of data for the column

columnNames Array.<string>

names of the columns in the dataset, to do cross-checks

Properties:
Name Type Description
id string

column id in the dataset

numeric boolean

whether the column is numeric, computed from the data. See isNumeric for details.

categorical boolean

whether the column is categorical, computed from the data

name string

name of the column to display above the column

group string

name of the group the column belongs to

id_size string

id of the column that will determine the size for display

id_color string

id of the column that will determine the color for display

colorByRank boolean

whether to color by rank per column instead of by value, only for numeric columns

scaleColumn boolean

whether to scale the column data to [0, 1]

label string

id of the column that has the values to display as labels over the geoms

id_hover_text string

id of the column that has the values to display as hover text

geom string

type of the geom to display

data Array

array of data for the column

min number

minimum value in the column, for numeric columns. 0 if scaleColumn === false

max number

maximum value in the column, for numeric columns. 1 if scaleColumn === false

range number

range of the column, for numeric columns

scale d3.scaleLinear

scale for the column, for numeric columns

colorScale d3.scaleLinear

scale for the color, for colorByRank numeric columns

rankedData Array.<number>

ranks of the data, for colorByRank numeric columns

normalizedRanks Object.<number, number>

mapping of rank to normalized rank, for colorByRank numeric columns. See maybeCalculateStats

View Source columns.js, line 85

Methods

# getColorValue(item, itemPos) → {number|string}

Get value for coloring the item.

Parameters:
Name Type Description
item Object

data item with our column

itemPos number

data item position in the dataframe. Needed for getting the rank with ties.

View Source columns.js, line 255

  • value for coloring the item
number | string

# getHoverText(item, floatPrecision) → {string}

Get text to display in a tooltip over the geom when mouse hovers it.

Parameters:
Name Type Description
item Object

data item with our column

floatPrecision number

number of decimal places to display for float values

View Source columns.js, line 274

  • text to display in tooltip when mouse hovers the geom
string

# getValue(item) → {number|string|Array.<number>}

Get value for the item, which is size for numeric or display for text/pie.

Parameters:
Name Type Description
item Object

data item with our column

View Source columns.js, line 237

  • value for sizing or displaying the item
number | string | Array.<number>

# maybeCalculateStats()

Calculate stats, scales and maybe ranks for the column. Should be called only for numeric columns. If colorByRank is set, data is ranked, and ranks with ties are normalized to unique ranks.

Sets min, max, range, scale, colorScale, rankedData, normalizedRanks properties.

In case there are ties in ranks, d3 will return ranks like [0, 0, 2] skipping rank 1. So we renormalize the ranks from [0, 2] to [0, 1], and map the colors to the number of unique ranks only. Otherwise we allocate 3 colors for [0, 0, 2] data, and the display colors won't fully map the palette. In this case normalizedRanks will be {0: 0, 2: 1}.

View Source columns.js, line 212