Skip to content

Commit

Permalink
If there is a single X column in the list - use it.
Browse files Browse the repository at this point in the history
Refs #7579
  • Loading branch information
arturbekasov committed Sep 24, 2013
1 parent 3ec7e38 commit 478032b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Code/Mantid/MantidPlot/src/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3147,8 +3147,9 @@ bool Graph::addCurves(Table* w, const QStringList& names, int style, double lWid
else {
QStringList drawableNames;
int noOfErrorCols = 0;
QString xColNameGiven;

// Select only those column names which we can draw
// Select only those column names which we can draw and search for any X columns specified
for (int i = 0; i < names.count(); i++)
{
int d = w->colPlotDesignation(w->colIndex(names[i]));
Expand All @@ -3160,6 +3161,13 @@ bool Graph::addCurves(Table* w, const QStringList& names, int style, double lWid
// Count error columns
if(d == Table::xErr || d == Table::yErr)
noOfErrorCols++;
} else if(d == Table::X)
{
// If multiple X columns are specified, it's an error, as we don't know which one to use
if(!xColNameGiven.isEmpty())
return false;

xColNameGiven = names[i];
}
}

Expand All @@ -3181,7 +3189,13 @@ bool Graph::addCurves(Table* w, const QStringList& names, int style, double lWid
// For other column types, we find associated Y column
yColName = w->colName(w->colY(colIndex));

QString xColName = w->colName(w->colX(colIndex));
QString xColName;
if(!xColNameGiven.isEmpty())
// If X column is given - use it
xColName = xColNameGiven;
else
// Otherise, use associated one
xColName = w->colName(w->colX(colIndex));

if (xColName.isEmpty() || yColName.isEmpty())
return false;
Expand Down

0 comments on commit 478032b

Please sign in to comment.