Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9310879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:13:30+00:00 2026-06-19T01:13:30+00:00

I have this table: Table public.transaction Column | Type | Modifiers ————+—————————–+———————————————————- id |

  • 0

I have this table:

                                 Table "public.transaction"
   Column   |            Type             |                        Modifiers                         
------------+-----------------------------+----------------------------------------------------------
 id         | integer                     | not null default nextval('transaction_id_seq'::regclass)
 account_id | integer                     | 
 note       | character varying           | 
 date       | timestamp without time zone | 
 amount     | numeric                     |

it contains transactions in the format:

 id | account_id |               note               |        date         | amount 
----+------------+----------------------------------+---------------------+--------
  1 |          1 | Loopia AB                        | 2013-02-07 00:00:00 |   -178
  2 |          1 | ÅSGATAN 2 KÖK &                  | 2013-02-07 00:00:00 |   -226
  3 |          1 | BURGER KING ODEN                 | 2013-02-06 00:00:00 |    -89
  4 |          1 | OLEARYS 917                      | 2013-02-06 00:00:00 |   -309
  5 |          1 | TAXI STOCKHOLM                   | 2013-02-06 00:00:00 |   -875
  6 |          1 | GRET INDIAN REST                 | 2013-02-06 00:00:00 |    -85
  8 |          1 | VIDEO RULLEN                     | 2013-02-04 00:00:00 |   -169
  9 |          1 | ICA SUPERMARKET                  | 2013-02-04 00:00:00 |   -196
 10 |          1 | ICA SUPERMARKET                  | 2013-02-03 00:00:00 |   -110

I then feed the data to D3 in the following format:

[
    {
        "note": "TEXAS LONGHORN",
        "date": "2013-01-10T00:00:00",
        "amount": 110,
        "id": 74,
        "account_id": 1
    },
    {
        "note": "GOOGLE *FEO Medi",
        "date": "2013-01-10T00:00:00",
        "amount": 22,
        "id": 73,
        "account_id": 1
    },
    {
        "note": "Pressbyran 5122",
        "date": "2013-01-10T00:00:00",
        "amount": 13,
        "id": 77,
        "account_id": 1
    },
    {
        "note": "ICA SUPERMARKET",
        "date": "2013-01-10T00:00:00",
        "amount": 106,
        "id": 76,
        "account_id": 1
    },
    {
        "note": "HÅR 3000",
        "date": "2013-01-10T00:00:00",
        "amount": 345,
        "id": 75,
        "account_id": 1
    },
    {
        "note": "Pressbyran 5122",
        "date": "2013-01-11T00:00:00",
        "amount": 19,
        "id": 72,
        "account_id": 1
    },
    {
        "note": "BIRKA PUNKTEN",
        "date": "2013-01-11T00:00:00",
        "amount": 79,
        "id": 71,
        "account_id": 1
    }
]

D3 streamgraphs however requires that all the data points are present. Thus I have to put all the dates, even those without any transactions, in the data that I feed to D3.

I would love your input on how to make this effiently with any of the tools available. You can play around with a live example at http://bl.ocks.org/joar/4747134/a702cf79bf10b1438cc665a2438b3f5cf9ab8bf0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T01:13:31+00:00Added an answer on June 19, 2026 at 1:13 am

    You want to generate_series a set of dates covering the target region, then left outer join your transaction table against it. See this SQLFiddle example.

    SELECT
      x.gendate,
      t.account_id, t.id, t.note, t.amount
    FROM 
      generate_series(
        (SELECT min("date") FROM transaction),
        (SELECT max("date") FROM transaction),
        INTERVAL '1' DAY
      ) AS x(gendate)
      LEFT OUTER JOIN transaction t ON (t."date" = x.gendate)
    ORDER BY x.gendate;
    

    You can generate the desired data format with PostgreSQL’s json functions, as per this SQLFiddle.

    WITH continuous_tx AS (
      SELECT
        x.gendate AS "date",
        t.account_id, t.id, t.note, t.amount
      FROM 
        generate_series(
          (SELECT min("date") FROM transaction),
          (SELECT max("date") FROM transaction),
          INTERVAL '1' DAY
        ) AS x(gendate)
        LEFT OUTER JOIN transaction t ON (t."date" = x.gendate)
      ORDER BY x.gendate
    )
    SELECT array_to_json(array_agg(continuous_tx ),'t')
    FROM continuous_tx;
    

    … though I haven’t tested feeding it into the graphing tool.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 mappings like this: <hibernate-mapping> <class name=A table=A> <id name=code column=aCode type=integer>
I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have a simple table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
Let's say I have following table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
I have this class: @Component @Scope(session) @Entity @Table(name = users) public class User {
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
I have this table Test as Id, SomeValue, SomeText contains about a mill records,
I have this table: UNIQUE_ID | WINNER_ID | FINALIST_ID ________1 | ________1 | __________2
I have this table structure on a SQL Server 2008 R2 database: CREATE TABLE
I have this table [Table 1] cid | arrived | date_arrived The [arrived field

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.