(
node: TreemapLayoutNode,
nodeModel: NodeModel,
nodeLayout: TreemapItemLayout,
nodeItemStyleModel: NodeItemStyleModel,
visuals: TreemapVisual,
viewChildren: TreemapLayoutNode[]
)
| 170 | } |
| 171 | |
| 172 | function buildVisualMapping( |
| 173 | node: TreemapLayoutNode, |
| 174 | nodeModel: NodeModel, |
| 175 | nodeLayout: TreemapItemLayout, |
| 176 | nodeItemStyleModel: NodeItemStyleModel, |
| 177 | visuals: TreemapVisual, |
| 178 | viewChildren: TreemapLayoutNode[] |
| 179 | ) { |
| 180 | if (!viewChildren || !viewChildren.length) { |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | const rangeVisual = getRangeVisual(nodeModel, 'color') |
| 185 | || ( |
| 186 | visuals.color != null |
| 187 | && visuals.color !== 'none' |
| 188 | && ( |
| 189 | getRangeVisual(nodeModel, 'colorAlpha') |
| 190 | || getRangeVisual(nodeModel, 'colorSaturation') |
| 191 | ) |
| 192 | ); |
| 193 | |
| 194 | if (!rangeVisual) { |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | const visualMin = nodeModel.get('visualMin'); |
| 199 | const visualMax = nodeModel.get('visualMax'); |
| 200 | const dataExtent = nodeLayout.dataExtent.slice() as [number, number]; |
| 201 | visualMin != null && visualMin < dataExtent[0] && (dataExtent[0] = visualMin); |
| 202 | visualMax != null && visualMax > dataExtent[1] && (dataExtent[1] = visualMax); |
| 203 | |
| 204 | const colorMappingBy = nodeModel.get('colorMappingBy'); |
| 205 | const opt: VisualMappingOption = { |
| 206 | type: rangeVisual.name, |
| 207 | dataExtent: dataExtent, |
| 208 | visual: rangeVisual.range |
| 209 | }; |
| 210 | if (opt.type === 'color' |
| 211 | && (colorMappingBy === 'index' || colorMappingBy === 'id') |
| 212 | ) { |
| 213 | opt.mappingMethod = 'category'; |
| 214 | opt.loop = true; |
| 215 | // categories is ordinal, so do not set opt.categories. |
| 216 | } |
| 217 | else { |
| 218 | opt.mappingMethod = 'linear'; |
| 219 | } |
| 220 | |
| 221 | const mapping = new VisualMapping(opt); |
| 222 | inner(mapping).drColorMappingBy = colorMappingBy; |
| 223 | |
| 224 | return mapping; |
| 225 | } |
| 226 | |
| 227 | // Notice: If we don't have the attribute 'colorRange', but only use |
| 228 | // attribute 'color' to represent both concepts of 'colorRange' and 'color', |
no test coverage detected
searching dependent graphs…