Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

361
Views
Creating infinite timeline using pure SVG and javascript, no libraries at all

As titled, and setting aside the hurdles and hardships, is this possible?

My idea is to create a simple horizontal timeline similar to a Gantt chart, and trying to build this in React. I got the custom SVG component that builds up the layout, but i still can't figure out about making the timeline, especially in making the ticks, and making the timeline infinite.

The problem is, i couldn't find proper example for this using just pure HTML, SVG and Javascript. Almost all my searches only shown results for timeline made using libraries.

This is the sample code i created so far

const grids = [
    { label: 'Q1', width: 200, height: 30, coord: { x: 190, y: 60 }, textcoord: { x: 260, y: 80 } },
    { label: 'Q2', width: 200, height: 30, coord: { x: 400, y: 60 }, textcoord: { x: 470, y: 80 } },
    { label: 'Q3', width: 200, height: 30, coord: { x: 610, y: 60 }, textcoord: { x: 680, y: 80 } },
    { label: 'Q4', width: 200, height: 30, coord: { x: 820, y: 60 }, textcoord: { x: 890, y: 80 } },
]

const blocks = [
    { label: 'Task 1', coord: { x: 30, y: 100 }, textcoord: { x: 70, y: 150 }, width: 150, height: 100 },
    { label: 'Task 2', coord: { x: 30, y: 205 }, textcoord: { x: 70, y: 235 }, width: 150, height: 100 },
    { label: 'Task 3', coord: { x: 30, y: 310 }, textcoord: { x: 70, y: 340 }, width: 150, height: 100 },
];

const data = [
    { label: 'Event A', coord: { x: 250, y: 100 }, width: 170, textcoord: { x: 300, y: 120 } },
    { label: 'Event B', coord: { x: 350, y: 140 }, width: 250, textcoord: { x: 400, y: 160 } },
    { label: 'Event C', coord: { x: 300, y: 205 }, width: 140, textcoord: { x: 350, y: 225 } },
];

const ChartContainer = props => {
    return (
        <div>
            <svg width="100%" height="1000" className={styles.cc_container}>
                <text x="30" y="40">ROADMAP TEST</text>
                {
                    grids.map( v => <ChartBlock { ...v }  />)
                }
                {
                    blocks.map( v => <ChartBlock { ...v }  />)
                }
                {
                    data.map( v => <Rectangle { ...v }  />)
                }
            </svg>
        </div>
    );
}

And it look like this

chart sample

I want the Rectangle (the event) to be in the infinite timeline. But since the whole things are already in SVG parent, i wonder how to put or create the infinite timeline inside it.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!