From 3485a52e16b4d8ebfaf6f96b61ab221c5189dce5 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Sat, 20 Jun 2020 16:58:52 +0200 Subject: [PATCH] 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 --- src/PlotDock.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/PlotDock.cpp b/src/PlotDock.cpp index f101d74e..2ed6b58c 100644 --- a/src/PlotDock.cpp +++ b/src/PlotDock.cpp @@ -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) {