Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ class BarChartOpDesc extends PythonOperatorDescriptor {
isPatternSelected = "True"

var isCategoryColumn = "False"
if (categoryColumn != "No Selection")
// "" is the Scala default ("No Selection" is only JSON metadata); an empty
// column must also count as "no category", else px.bar(color="") fails.
if (categoryColumn.nonEmpty && categoryColumn != "No Selection")
isCategoryColumn = "True"

val finalCode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,14 @@ class BarChartOpDescSpec extends AnyFlatSpec with BeforeAndAfter with Matchers {
ex.getMessage should (include("Value column") or include("Fields"))
}

"BarChartOpDesc.generatePythonCode" should "treat an unset categoryColumn as no category (color guarded to None)" in {
// An empty categoryColumn (its Scala default) must guard color to None, not
// emit `... if True else None` with an empty column name for px.bar(color=).
opDesc.value = "score"
opDesc.fields = "name"
val code = opDesc.generatePythonCode()
code should include("color=self.decode_python_template('') if False else None")
code should not include "color=self.decode_python_template('') if True else None"
}

}
Loading