Skip to content

Plot only allows Axis Type = Numeric #2286

Closed

Description

@ecanfi

Details for the issue

What did you do?

Attempted to plot results from a SQL statement.

What did you expect to see?

In the previous release, I was able to display my record results with text labels as a bar chart

What did you see instead?

The Axis Type for all columns is set to Numeric and cannot be changed.

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • Windows: ( _version:10 )
  • Linux: ( distro: ___ )
  • macOS: ( version: ___ )
  • Other: ___

What is your DB4S version?

  • 3.12.0-(alpha or betas)
  • 3.11.2
  • 3.11.1
  • 3.10.1
  • Other: 3.12.0 released version

Did you also

Activity

  1. added
    bugConfirmed bugs or reports that are very likely to be bugs.
    on Jun 18, 2020
  2. justinclift commented on Jun 18, 2020

    @justinclift
    Member

    Out of curiosity, was the database loaded using a project file (eg it should have restored existing settings), or was it loaded directly (eg from File -> Open)? 😄

  3. ecanfi commented on Jun 18, 2020

    @ecanfi
    Author

    Update: The plot feature works correctly when viewing tables, but when executing a sql statement in the "Execute SQL" tab, all the Axis Type fields are numeric only. Same results if loading database from "Open Database" or loading from "Open Project"

  4. justinclift commented on Jun 19, 2020

    @justinclift
    Member

    Interesting. Sounds like something we should fix for the upcoming 3.12.1 update. No firm plans for an ETA yet though. 😉

  5. self-assigned this
    on Jun 19, 2020
  6. mgrojo commented on Jun 20, 2020

    @mgrojo
    Member

    I couldn't reproduce the problem, but I've found a bug which wasn't present in 3.11. If there are NULL values in a column used as labels for a bar chart, the plot is done, but the labels are not displayed and the zoom is not reset. This should be fixed in tomorrow's nightly build.

    Regarding your issue, I can only guess that the type detection is not working. We check the first 10 values for valid data type. If the first 10 values are numbers or NULL (even if the column affinity is string) the type for the axis is guessed as numeric. But that behaviour hasn't changed since 3.11. Does it make any sense for you? Otherwise, could you publish the table structure and data for reproducing the problem?

  7. grumble1965 commented on Jun 24, 2020

    @grumble1965

    I think I'm seeing something similar since upgrading. Before upgrading this query showed time series plot, with version 3.12.0 I see a vertical line of data. I assume that X axis is being interpreted differently than before.

    Thanks!

    FYI - data is NYTimes US Covid-19 data

    Schema:
    CREATE TABLE ss( "date" TEXT, "state" TEXT, "fips" TEXT, "cases" TEXT, "deaths" TEXT )

    Select:

    select
    a.date,
    a.cases,
    a.deaths,
    (a.cases-b.cases)/7 as 'Avg new Cases',
    (a.deaths-b.deaths)/7 as 'Avg new Deaths'
    from ss a, ss b
    where a.state = 'California' AND
    a.state=b.state AND
    date(a.date, '-7 days')=b.date ;

    Sample Data:

    2020-06-23 191039 5637 4558 62
    2020-06-22 184620 5561 4136 63
    2020-06-21 178807 5517 3693 61
    2020-06-20 174854 5495 3488 62
    2020-06-19 170843 5425 3365 62
    2020-06-18 167135 5359 3346 59
    2020-06-17 163381 5283 3320 59
    2020-06-16 159131 5202 3126 61
    2020-06-15 155662 5120 3053 63
    2020-06-14 152953 5089 2993 62

  8. mgrojo commented on Jun 27, 2020

    @mgrojo
    Member

    @grumble1965 I wasn't able to reproduce the problem. I couldn't get any data out of the query and the database, but the sample data is working for me:

    image

    Could you provide more data to analyse the problem, like a screenshot, more detailed steps or anything that could be useful?

  9. justinclift commented on Jun 27, 2020

    @justinclift
    Member

    @grumble1965 The database you created when importing the data... do you still have it around? 😄

  10. grumble1965 commented on Jun 28, 2020

    @grumble1965

    Thanks for trying to repro this. This is not an obvious thing, but I think I can reproduce this.

    The data is from https://github.com/nytimes/covid-19-data

    sqlite> .schema
    CREATE TABLE cc(
    "date" TEXT,
    "county" TEXT,
    "state" TEXT,
    "fips" TEXT,
    "cases" TEXT,
    "deaths" TEXT
    );
    CREATE TABLE ss(
    "date" TEXT,
    "state" TEXT,
    "fips" TEXT,
    "cases" TEXT,
    "deaths" TEXT
    );
    CREATE INDEX idx_state on ss (state);
    CREATE INDEX idx_state_county on cc (state, county);
    CREATE TABLE us(
    "date" TEXT,
    "cases" TEXT,
    "deaths" TEXT
    );

    sqlite> .import /mnt/g/Code/covid-19-data/us.csv us
    sqlite> .import /mnt/g/Code/covid-19-data/us-counties.csv cc
    sqlite> .import /mnt/g/Code/covid-19-data/us-states.csv ss
    sqlite> delete from ss where date='date'; delete from cc where date='date'; delete from us where date='date' ;

    I open DB Browser, open that database, and try a simple query - no problems and things look good (date column is flagged as type 'date'). See screen caps named 'before'.
    Before-plot
    Before-query

    I try increasingly complex queries, and after maybe 5 or 6 tries, the date column is now recognized as type 'numeric' and the plot is broken. See screen caps named 'after'.
    After-query
    After-plot

    Trying simpler queries doesn't change the type back to 'date', neither does closing and reopening the database. The only fix is to close and reload DB Browser.

    Hope this helps!

  11. mgrojo commented on Jun 29, 2020

    @mgrojo
    Member

    Ok, thank you. I'm reproducing it now, although in my case, a simple reexecution of the query, or pressing the button to load all data, solves the problem.

    This seems a race condition, because each time the query is executed, the plot loads more or less data. When I reproduce it, only three dots are present from two different columns, and the date value seems to be 0. I guess the plot is drawn before the model has enough data.

    image

    @MKleusberg I suppose you can help with the concurrent code.

  12. mgrojo commented on Aug 9, 2020

    @mgrojo
    Member

    @MKleusberg could you take a quick look to this? What I've seen so far is that when the SqliteTableModel::finishedFetch signal is emitted, which is connected to the plot update, the cache isn't still loaded. That means the plot dock reads data which is still in the "loading..." state (null data when read in the edit role). Then the plot has only a few elements or even in some cases, there isn't any value to make the guess of type, causing it to default to Numeric. Is it expected that finishedFetch is emitted and the cache is not yet complete?

  13. justinclift commented on Aug 9, 2020

    @justinclift
    Member

    @mgrojo Is there any change in the behaviour after my two changes to signal and slots related code today?

    In theory I'm thinking there shouldn't be, but am mentioning just in case there's some unexpected side effect. 😉

  14. mgrojo commented on Aug 9, 2020

    @mgrojo
    Member

    @justinclift No, I've just pulled them and the behaviour is the same 😄 This is related to the model between the table widgets (and the plot in this case) and the SQLite database.

  15. added this to the 3.12.1 milestone on Aug 16, 2020
  16. mgrojo commented on Aug 16, 2020

    @mgrojo
    Member

    @ecanfi, we think we have fixed this issue in our development version. The fix is included in our nightly build. Would you mind installing it to confirm that we can close this issue?

  17. grumble1965 commented on Oct 1, 2020

    @grumble1965

    I cannot reproduce this issue in 1.12.1-RC1.

    Thank you very much!

  18. mgrojo commented on Oct 1, 2020

    @mgrojo
    Member

    Thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugConfirmed bugs or reports that are very likely to be bugs.plot

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions