| 156 | } |
| 157 | |
| 158 | private identifyModes() { |
| 159 | //based on the data, identify the mode in which the heatmap should |
| 160 | //be plotted. |
| 161 | const scales = this.getScales(); |
| 162 | const rowScale = scales.row; |
| 163 | const columnScale = scales.column; |
| 164 | const nRows = this.colors.length; |
| 165 | const nColumns = this.colors[0].length; |
| 166 | this.modes = { column: AxisMode.Middle, row: AxisMode.Middle }; |
| 167 | |
| 168 | if (rowScale.type === 'ordinal') { |
| 169 | this.modes.row = AxisMode.Middle; |
| 170 | } else { |
| 171 | if (nRows === this.rows.length - 1) { |
| 172 | this.modes.row = AxisMode.Boundaries; |
| 173 | } else if (nRows === this.rows.length) { |
| 174 | this.modes.row = AxisMode.ExpandOne; |
| 175 | } else if (nRows === this.rows.length + 1) { |
| 176 | this.modes.row = AxisMode.ExpandTwo; |
| 177 | } |
| 178 | } |
| 179 | if (columnScale.type === 'ordinal') { |
| 180 | this.modes.column = AxisMode.Middle; |
| 181 | } else { |
| 182 | if (nColumns === this.columns.length - 1) { |
| 183 | this.modes.column = AxisMode.Boundaries; |
| 184 | } else if (nColumns === this.columns.length) { |
| 185 | this.modes.column = AxisMode.ExpandOne; |
| 186 | } else if (nColumns === this.columns.length + 1) { |
| 187 | this.modes.column = AxisMode.ExpandTwo; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | static serializers = { |
| 193 | ...MarkModel.serializers, |