Bar charts did not display labels in x axis when NULL values present

The problem was signaled by an error when calling addTicks:
[...]AddTicks[...] passed unequal length vectors for positions and labels

See comment in issue #2286
This commit is contained in:
mgrojo
2020-06-20 16:58:52 +02:00
parent 9481bd8ef6
commit 3485a52e16
+10 -5
View File
@@ -360,11 +360,16 @@ void PlotDock::updatePlot(SqliteTableModel* model, BrowseDataTableSettings* sett
{
tdata[j] = j;
// NULL values produce gaps in the graph. We use NaN values in
// that case as required by QCustomPlot.
if(x != RowNumId && model->data(model->index(j, x), Qt::EditRole).isNull())
xdata[j] = qQNaN();
else {
if(x != RowNumId && model->data(model->index(j, x), Qt::EditRole).isNull()) {
// NULL values produce gaps in the linear graphs. We use NaN values in
// that case as required by QCustomPlot.
// Bar plots will display the configured string for NULL values.
if(xtype == QVariant::String) {
xdata[j] = j+1;
labels << model->data(model->index(j, x), Qt::DisplayRole).toString();
} else
xdata[j] = qQNaN();
} else {
// convert x type axis if it's datetime
switch (xtype) {