Skip to content

Commit

Permalink
Bar charts did not display labels in x axis when NULL values present
Browse files Browse the repository at this point in the history
The problem was signaled by an error when calling addTicks:
[...]AddTicks[...] passed unequal length vectors for positions and labels

See comment in issue sqlitebrowser#2286
  • Loading branch information
mgrojo committed Jun 20, 2020
1 parent 9481bd8 commit 3485a52
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/PlotDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3485a52

Please sign in to comment.