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 9166255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:06:46+00:00 2026-06-17T15:06:46+00:00

I have been working on two different approaches to create a graphical canvas with

  • 0

I have been working on two different approaches to create a graphical canvas with html5 code, allowing graphical representation and horizontal scrolling of the graph. the canvas represents a timeline of sorts. as we scroll horizontally, the idea is to represent several years in the format of a timeline… example: say the historical development of computers… I m plotting points on the graph in reference to xy co-ordinates. this is currently se manually. later on I plan to make it based on sql queries. then as i scroll more, points plotted in future years/past years are displayed accordingly…giving it a continuous timeline feeling.

I have been trying to attempt this with 2 approaches in html5 canvas..some have suggested using SVG, silverlight, GDI +….

approach 1:-

http://jsfiddle.net/7KaKf/1/

method – a grid is created, points are plotted on the grid with a variable list, click mouse on the canvas – triggering is activated, drag canvas to scroll horizontally, click again on the canvas and scrolling is disabled.

advantage to this approach – horizontal scrolling works like a charm!!!

however, the issue in this approach is that i am not sure how to bind y axis lables on this grid such that every scrollable frame has a consistent label for both x axis and y axis.

note: you can view my next approach to see what i mean by labels.

approach 2:-

http://jsfiddle.net/WNpKE/10/

The issue with the 2nd approach, is mostly like in the function that capture the mouse scrolling/dragging event and tries to repaint the canvas elements:-

window.onmousemove = function (e) {
  var evt = e || event;
  if (dragging) {
    var delta = evt.offsetX - lastX;
    translated += delta;

    //console.log(translated);

    ctx.restore();
    ctx.clearRect(0, 0, 930, 900);
    ctx.save();
    ctx.translate(translated, 0);
    lastX = evt.offsetX;
    timeline();
  }
}

Another issue could be, even though timeline() is being recalled as the canvas scrolls, the grid is painted statically, between x = 65 and x = 930/ hence no other grid is being drawn.

Although labeling is possible with this approach (which was proving to be difficult with the first approach), the grid is not consistent and once i scroll out of the first frame, the grid dissappears…. although the plotted points in the future are still visible when we scroll.

In my first approach I use a grid that keeps repeating itself as we scroll on the canvas…however labeling becomes difficult with that…and in the 2nd approach, i label, however creating that style of repeating grid becomes difficult. I have come to quite the roadblock. somehow I need to combine both methods to create the solution. Can anyone help ?

If someone could also give me links to cool canvas related theory material. I would appreciate it. 🙂

updated 2nd approach and the solution :-

http://jsfiddle.net/WNpKE/12/

With this approach the y axis labels remain constant. the background grid is replicating. Although this is sort of the solution that I was looking for (it is not perfect), any modifications are most welcome.

  • 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-17T15:06:47+00:00Added an answer on June 17, 2026 at 3:06 pm

    Although my solution is not perfect yet, but the solution can be found on:-

    http://jsfiddle.net/WNpKE/12/

    Solution:- creating the x-y grid separately as a function.

    grid = (function (dX, dY) {
                            var can = document.createElement("canvas"),
                                ctx = can.getContext('2d');
                            can.width = dX;
                            can.height = dY;
                            // fill canvas color
                            ctx.fillStyle = 'black';
                            ctx.fillRect(0, 0, dX, dY);
    
                            // x axis
                            ctx.strokeStyle = 'orange';
                            ctx.moveTo(.5, 0.5);
                            ctx.lineTo(dX + .5, 0.5);
                            ctx.stroke();
    
                            // y axis
                            ctx.moveTo(.5, .5);
                            ctx.lineTo(.5, dY + .5);
                            ctx.stroke();
    
                            return ctx.createPattern(can, 'repeat');
                        })(72, 50);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have now been working as a web developer for two weeks and have
I've been working at this for two days and have not had much luck.
I've been working on an application for a little over two years and have
In the past years I have been working on different projects that required creating
I have been working on encryptor && decryptor in C#.I have two buttons for
I've been working with lots of Fragments recently and have been using two distinct
I have been trying to work on a simple code for two days now.
Have been working on this question for a couple hours and have come close
I have been working with SQL Server as a Developer a while. One thing
I have been working on a large java application. It is quite parallel, and

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.