Skip to content

Conversation

@ghtmtt
Copy link
Owner

@ghtmtt ghtmtt commented Jun 13, 2022

Fix the selection behavior for scatterplots using the same js expression and qgsexpression as the other plot types.

We had problems with NULL values: js gave different id for the same feature(s) AND we have some problems when a feature subset was created.

@Gustry do you mind having a quick quick look at the js part?

@ghtmtt ghtmtt requested a review from Gustry June 13, 2022 16:07
Copy link
Collaborator

@Gustry Gustry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the first commit was supposed to stay in #288

elif dic["mode"] == 'clicking':
if dic['type'] == 'scatter':
self.layer_combo.currentLayer().selectByIds([dic['fidd']])
exp = """ {} = '{}' """.format(dic['field'], dic['id'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange, I can't do code suggestion ...

exp = QgsExpression.createFieldEqualityExpression(dic['field'], dic['id'])
self.layer_combo.currentLayer().selectByExpression(exp)

This function createFieldEqualityExpression will manage if dic['id'] is integer or string for instance instance. I'm don't know what is the value

It's possible to make a selection straight from a expression string

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmmm.. ok then we can stick with this patch. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to stick to the current patch ?

You can make your code easier :
L484, L486 and L495 by using selectByExpression instead of selectByIds and having to create a loop.
getFeatures is not very efficient, even if you use a QgsFeatureRequest if you don't specify just the fields you need (ID in your example). You can read the blogpost https://nyalldawson.net/2016/10/speeding-up-your-pyqgis-scripts/

@ghtmtt
Copy link
Owner Author

ghtmtt commented Jun 23, 2022

closing this PR because it's a little bit messy with the commits. See #293

@ghtmtt ghtmtt closed this Jun 23, 2022
@ghtmtt ghtmtt deleted the fix_selection branch October 30, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants