Skip to content

Commit

Permalink
Don't select attribute when adding manual dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoldowsky committed Mar 12, 2024
1 parent 28f86aa commit 3b317e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 11 additions & 8 deletions src/plugins/graph/models/data-configuration-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,28 +716,31 @@ 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) {
this.removeYAttributeWithID(self._yAttributeDescriptions[0].attributeID);
}
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') {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/graph/models/graph-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3b317e0

Please sign in to comment.