Update the header on the vis.js timeline for better visibility on the page

The updated library now includes fixed headers within the chart itself, which is a great improvement. However, we feel that it only solves half of the issue at hand.

Customizing the headers is still a challenge, so I implemented a separate row to display specific numbers for each month. While users prefer scrolling through a large HTML page rather than a vertically expanding timeline, this approach eliminates the functionality of fixed headers.

I have been trying to find a way to float either the original header or my custom content on the page to allow for scrolling while keeping the headers in place. My CSS skills are not very advanced, so I have referenced this technique for basic reports. However, I am unsure if this method is suitable for our project, especially in terms of horizontal scrolling for the timeline.

Does anyone have any suggestions, pointers, or ideas on how to address this challenge?

Answer №1

My approach involved identifying a specific set of boxes and setting their position to fixed under certain conditions, particularly when scrolling down. This strategy reminded me of a similar tactic used to keep headers fixed in a report while scrolling.

Although the final line felt a bit unconventional, it effectively achieved the desired result (function not provided).

   offset_applied = false; // keeping track of offset application
   $boxes = $('#p71_timeline .foreground div.group .topbox');

  // trigger this when scrolling the page
  $( document ).scroll(function() {
    // if scrolling past a certain point, hover over the months
    if ($(document).scrollTop() > 200) {
       $boxes
          .css(
            {'position':'fixed'  // float month boxes by setting position fixed
            ,'z-index':100       // ensure hover over everything
            ,'top':'44px'        // float below the menu
        });
        // enhancing the floating boxes visually
        $('#shade,#shade_left').show(); 
        // shade_left added to lighten extra months shown when hovering.

      if (!offset_applied) {
        // initially shift all boxes by an offset, likely dependent on y-axis label widths
        apex.debug('shift right');
        $boxes.css('left','+=247px');
      }
      // only need to do it once, otherwise it quickly zooms to the right
      offset_applied = true;
    }
    else {
      // page scrolled back to the top, maintain original position
      $boxes.css({'position':'absolute','top':'5px'});
      $('#shade,#shade_left').hide(); 
      if (offset_applied){
        // reverse the offset only once
        apex.debug('shift left');
        $boxes.css('left','-=247px');
      }
      offset_applied = false;

    } // scroll position

  });
  // Check box placement after allowing the chart to render
  // Reapply if page was loaded with scrolling down
  setTimeout(function(){_check_placement();}, 1000);

In addition, I included a region with partial opacity (#shade) to provide a background for the hovering boxes and enhance the overall presentation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The timing of jQuery's .load function appears to be off, catching us by surprise

My current challenge involves loading returned html from an .aspx page through AJAX, but facing a timing issue with a click event that needs to occur before executing some essential tasks. Specifically, the process begins when a user types in a text field ...

Collapsible Rows in Material-UI Table seamlessly integrated with regular rows

While using material-ui v4, I encountered an issue where my collapsible row columns are not aligning properly with my regular columns. Below is a photo and the code snippet for reference. As you can see in the image, when I expand the Frozen Yogurt row, th ...

Troubleshooting alignment problems with a responsive gallery (Bootstrap-gallery & justifyGallery)

Looking to showcase a gallery of images using jquery-justifyGallery and bootstrap-gallery. Want to display 4 images in a row, but running into issues when trying to display 5 images where the last image in the row ends up with a larger width. Bootstrap has ...

Using JavaScript, you can add an article and section to your webpage

Currently, I am utilizing AJAX to showcase posts. My objective is to extract each property from a JSON object that is returned and generate an <article> for the title followed by a subsequent <section> for the content. While I can successfully ...

The straightforward hyperlink to a specific section within a webpage is not functioning as expected

Having trouble with my HTML navigation in Angular, can't pinpoint the issue. When I click on a navigation button, the URL changes from http://localhost:8018/#/WebDev to http://localhost:8018/#WebDev Something off in my code? <head> < ...

Creating a table using data from an Angular form

As I attempt to create a table that takes user-entered form data, stores it on the client-side, and organizes each input property into a group to form an object, I encounter an issue. Despite starting the code below, nothing seems to be working. Can anyone ...

Guide on retrieving data from two separate tables within a single database using PHP

I am currently working on a shopping website where I have a table called "products" that stores all the product data. Additionally, there is a separate table named "cart" which contains the products added to the cart, including product ID and user ID. On t ...

Ending a div tag inside another div element

I have set up a listings page with individual divs for each listing, loading content from a separate php script using $.post The issue I'm facing is hiding the listing, possibly related to this line of code: $('div.close_listing') I can o ...

positioning a window.confirm dialog box in the center of the screen

I'm currently facing an issue with a dialog box that I have implemented successfully. However, I can't seem to get it centered on the page: <Button variant="danger" onClick={() => { if (window.confirm('Delete character?')) handle ...

The success callback is not triggered with $.ajax

Does anyone know why this api call only succeeds when an alert is left on the page? <button class="login100-form-btn" onclick="CheckUser();">Entrar</button> function CheckUser() { const result = Auth(); alert(); ...

When viewing on smaller devices, columns in Bootstrap will have varying height ratios except for the 1:1 ratio

Initially, I was unsure about the kind of research I needed to conduct, which led me to asking a potentially duplicate question. Nevertheless, the code I am working with is quite simple: #my-container { height: 100vh; } <link rel="stylesheet" hr ...

Which method is best for extracting content from a WebView - using Regx, implementing JQuery, or utilizing HTML parsing?

Criteria for Acceptance I am working with a website in a WebView that is not under my ownership. I want to be able to trigger native button clicks based on the content of the page. Tasks at Hand I need to determine if the HTML content contains specific UR ...

Creating a customized tooltip without the need for calling $(document).foundation() and using modernizr

I'm facing an issue with initializing the foundation tool-tip without having to initialize everything (such as $(document).foundation()). It seems like a simple task, but I am struggling. I have two questions in mind: (1) How can I utilize new Founda ...

Storing additional data from extra text boxes into your database can be achieved using AJAX or PHP. Would you

A dynamic text box has been created using Jquery/JavaScript, allowing users to click on an "Add More" button to add additional input boxes for entering data. However, a challenge arises when attempting to store this user-generated data in a database. Assi ...

Issues with scrolling navigation have been identified in IE8

I am puzzled by the fact that the main navigation on this website is not functioning in IE8. redacted The code for the navigation is quite simple, with a localScroll feature attached to enable the scrolling effect. <ul> <li><a href=" ...

Is there a way to upload files in AngularJS without using AJAX or jQuery?

Currently, I am looking to create a gallery that allows for the uploading of multiple images. While I have come across some options that utilize ajax to immediately send the files, I prefer a solution that involves form submission. In addition, I would li ...

Choosing the subsequent div after the current one using Jquery

I am currently in the process of creating a drop-down menu button that, when clicked, reveals the previously hidden div underneath it. The code is functioning properly without the use of $(this).next, but it is displaying all divs with the class .menudrop ...

Collecting, gathering content repeatedly

Hey there, just checking in. I'm currently working on extracting information related to CEO Pay Ratio and compiling links to this section for processing by a function. My goal is for the function to capture content starting from a specified tag and en ...

"Displaying <canvas> at its true resolution even when zoomed in, thanks to Retina technology

I am currently working with a <canvas> element to create vector graphics and I want to ensure that it displays in the highest quality possible while using minimal resources across various viewing conditions. Specifically, I aim to achieve a 1:1 mappi ...

Troubleshooting issue with Onchange in select HTML element within Django

I'm working with a Problems model in my project. In my Models file models.py class Problems(models.Model): Easy = 'Easy' Medium = 'Medium' Hard = 'Hard' NA = 'NA' DIFFICULTY = [ (NA ...