diff --git a/src/plugins/graph/models/data-configuration-model.ts b/src/plugins/graph/models/data-configuration-model.ts index 95be8dff56..f017054f3a 100644 --- a/src/plugins/graph/models/data-configuration-model.ts +++ b/src/plugins/graph/models/data-configuration-model.ts @@ -716,7 +716,14 @@ export const DataConfigurationModel = types removeAttributeFromRole(role: GraphAttrRole) { self._setAttributeDescription(role); }, - setAttributeForRole(role: GraphAttrRole, desc?: IAttributeDescriptionSnapshot) { + /** + * Assign the Attribute to the given graph role. + * By default will also select the attribute. + * @param role graph role. + * @param desc attribute description, including the attribute ID and optionally a type. + * @param select boolean default true to select the attribute. + */ + setAttributeForRole(role: GraphAttrRole, desc?: IAttributeDescriptionSnapshot, select: boolean=true) { if (role === 'y') { // Setting "Y" role implies that user only wants one, or no Y attributes. while (self._yAttributeDescriptions.length) { @@ -724,20 +731,16 @@ export const DataConfigurationModel = types } if (desc && desc.attributeID !== '') { self._yAttributeDescriptions.push(desc); - self.dataset?.setSelectedAttributes([desc.attributeID]); } } else if (role === 'yPlus' && desc && desc.attributeID !== '') { self._yAttributeDescriptions.push(desc); } else if (role === 'rightNumeric') { this.setY2Attribute(desc); - if (desc) { - self.dataset?.setSelectedAttributes([desc.attributeID]); - } } else { self._setAttributeDescription(role, desc); - if (desc) { - self.dataset?.setSelectedAttributes([desc.attributeID]); - } + } + if (desc && select) { + self.dataset?.setSelectedAttributes([desc.attributeID]); } this.syncFilteredCasesCount(true); if (role === 'legend') { diff --git a/src/plugins/graph/models/graph-model.ts b/src/plugins/graph/models/graph-model.ts index c9db305713..1fa5aa82e8 100644 --- a/src/plugins/graph/models/graph-model.ts +++ b/src/plugins/graph/models/graph-model.ts @@ -375,8 +375,8 @@ export const GraphModel = TileContentModel const dataConfiguration = DataConfigurationModel.create(); layer.setDataConfiguration(dataConfiguration); dataConfiguration.setDataset(dataset, metadata); - dataConfiguration.setAttributeForRole("x", { attributeID: xAttr.id, type: "numeric" }); - dataConfiguration.setAttributeForRole("y", { attributeID: yAttr.id, type: "numeric" }); + dataConfiguration.setAttributeForRole("x", { attributeID: xAttr.id, type: "numeric" }, false); + dataConfiguration.setAttributeForRole("y", { attributeID: yAttr.id, type: "numeric" }, false); } }, setXAttributeLabel(label: string) {