Skip to content

Commit

Permalink
Show the right implicit empty values in tooltip (#5747)
Browse files Browse the repository at this point in the history
* Show the right implicit empty values in tooltip

If you set a nominal or ordinal variable in a scale VariablesList, a tooltip tells you how the values are transformed into scale.
It gives also a list of 'implicit' empty values: that is the not empty values that could not be converted into a double value. This list was not correct, it gave all the convertable values.

* The implicit empty values are derived from value not being doubles

also make sure empty values are also checked on the original value now

* remove ugly parentheses

* less crazy if elses

* also less count++

---------

Co-authored-by: Joris Goosen <[email protected]>
  • Loading branch information
boutinb and JorisGoosen authored Nov 28, 2024
1 parent 96137bb commit aef9532
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2372,20 +2372,28 @@ stringvec Column::previewTransform(columnType transformType)
}

{
std::stringstream someEmptyValues;
std::stringstream someImplicitEmptyValues;

if(transformType == columnType::scale && labelsTempCount() > _labelsTempNumerics)
{
int count = 0;

for(Label * label : _labels)
if(!label->isEmptyValue() && count < showThisMany)
someEmptyValues << (count++ > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"';
else if(!label->isEmptyValue() && count++ == showThisMany)
someEmptyValues << ", ...";
if(!label->isEmptyValue() && !ColumnUtils::isDoubleValue(label->originalValueAsString()))
{
if(count < showThisMany)
someImplicitEmptyValues << (count > 0 ? ", " : "") << '"' << label->originalValueAsString() << '"';
else
{
someImplicitEmptyValues << ", ...";
break; // Do not need to loop further over the labels.
}

count++;
}
}

out.push_back(someEmptyValues.str());
out.push_back(someImplicitEmptyValues.str());
}

return out;
Expand Down
2 changes: 1 addition & 1 deletion CommonData/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ std::string Label::labelIgnoreEmpty() const

bool Label::isEmptyValue() const
{
return _column->isEmptyValue(_label);
return _column->isEmptyValue(originalValueAsString(false)) || _column->isEmptyValue(label());
}

std::string Label::originalValueAsString(bool fancyEmptyValue) const
Expand Down

0 comments on commit aef9532

Please sign in to comment.