Skip to content

Commit

Permalink
Allow table variables to take a string also in JSON syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Sep 28, 2023
1 parent 6a3a7d4 commit 2f7e81b
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/base/reportbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3303,17 +3303,37 @@ namespace Wisteria
}

std::vector<wxString> variables;
const auto readVariables = graphNode->GetProperty(L"variables")->GetValueStringVector();
for (const auto& readVar : readVariables)
const auto variablesNode = graphNode->GetProperty(L"variables");
if (variablesNode->IsOk() && variablesNode->IsValueString())
{
auto convertedVars = ExpandColumnSelections(readVar, foundPos->second);
auto convertedVars =
ExpandColumnSelections(variablesNode->GetValueString(), foundPos->second);
if (convertedVars)
{
variables.insert(variables.cend(),
convertedVars.value().cbegin(), convertedVars.value().cend());
}
else
{ variables.push_back(readVar); }
{
throw std::runtime_error(
wxString::Format(_(L"%s: unknown variable selection formula for table."),
variablesNode->GetValueString()).ToUTF8());
}
}
else if (variablesNode->IsOk() && variablesNode->IsValueArray())
{
const auto readVariables = variablesNode->GetValueStringVector();
for (const auto& readVar : readVariables)
{
auto convertedVars = ExpandColumnSelections(readVar, foundPos->second);
if (convertedVars)
{
variables.insert(variables.cend(),
convertedVars.value().cbegin(), convertedVars.value().cend());
}
else
{ variables.push_back(readVar); }
}
}

auto table = std::make_shared<Graphs::Table>(canvas);
Expand Down Expand Up @@ -5010,8 +5030,8 @@ namespace Wisteria
if (iconValue.has_value())
{ graph->SetStippleShape(iconValue.value()); }
if (const auto stippleShapeColor = ConvertColor(stippleShapeNode->GetProperty(L"color"));
stippleShapeColor.IsOk())
{ graph->SetStippleShapeColor(stippleShapeColor); }
stippleShapeColor.IsOk())
{ graph->SetStippleShapeColor(stippleShapeColor); }
}
}

Expand Down

0 comments on commit 2f7e81b

Please sign in to comment.