Is it possible to hide the remove button gap in Vis timeline?

When using vis-timeline without stacking enabled (which is the default setting), there appears to be a predefined gap between two items on the same line, preventing them from touching. It seems that this enforced gap is to accommodate the remove button that appears next to each item. However, even if editable.remove is set to false in the options for vis.Timeline, this gap still persists.

Is there a way to eliminate this gap without enabling stacking? (I want to avoid overlapping, except at a specific point in time.)

Below is an example (simplified version from the GitHub page of vis-timeline):

<!doctype html>
<html>
<head>
  <title>Timeline</title>
  <script type="text/javascript" src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"></script>
  <link href="https://unpkg.com/vis-timeline@latest/styles/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  <style type="text/css">
    #visualization {
      width: 600px;
      height: 400px;
      border: 1px solid lightgray;
    }
  </style>
</head>
<body>
<div id="visualization"></div>
<script type="text/javascript">
  // DOM element where the Timeline will be attached
  var container = document.getElementById('visualization');

  // Create a DataSet (allows two way data-binding)
  var items = new vis.DataSet([
    {id: 1, content: 'item 1', start: '2014-04-14T00:00:00', end: '2014-04-14T00:15:00'},
    {id: 2, content: 'item 2', start: '2014-04-14T00:15:00', end: '2014-04-14T00:30:00'},
  ]);

  // Configuration for the Timeline
  var options = {editable: true};

  // Create a Timeline
  var timeline = new vis.Timeline(container, items, options);
</script>
</body>
</html>

If you run this snippet, you'll notice that the two items created are placed on separate lines.

Trying to move these items onto the same line reveals that only a small gap between them is possible. This gap appears to be approximately the size of the remove button for the items. Disabling this button through framework or CSS does not alter this behavior.

Answer №1

To customize the spacing between items in vis-timeline horizontally, you can utilize the margin.item.horizontal option outlined in detail in the documentation located at . By default, this value is set to 10, but adjusting it to 0 will enable the items to be positioned next to each other.

Here is an example of how to modify the options object:

var options = {
  editable: true,
  margin : { 
    item: {
      horizontal:0
    }
  }
};

Check out the updated code snippet below for a visual representation:

<!doctype html>
<html>
<head>
  <title>Timeline</title>
  <script type="text/javascript" src="https://unpkg.com/vis-timeline@latest/standalone/umd/vis-timeline-graph2d.min.js"></script>
  <link href="https://unpkg.com/vis-timeline@latest/styles/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
  <style type="text/css">
    #visualization {
      width: 600px;
      height: 400px;
      border: 1px solid lightgray;
    }
  </style>
</head>
<body>
<div id="visualization"></div>
<script type="text/javascript">
  // DOM element where the Timeline will be attached
  var container = document.getElementById('visualization');

  // Create a DataSet (allows two way data-binding)
  var items = new vis.DataSet([
    {id: 1, content: 'item 1', start: '2014-04-14T00:00:00', end: '2014-04-14T00:15:00'},
    {id: 2, content: 'item 2', start: '2014-04-14T00:15:00', end: '2014-04-14T00:30:00'},
  ]);

  // Configuration for the Timeline
  var options = {
    editable: true,
    margin : { 
      item: {
        horizontal:0
      }
    }
  };

  // Create a Timeline
  var timeline = new vis.Timeline(container, items, options);
</script>
</body>
</html>

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

Divide the elements of the array separated by white space into individual components within the array

Scenario I am in the process of creating a basic webpage that will allow me to showcase and filter bookmarks. Each bookmark can be associated with multiple tags, and tags may be duplicated across different bookmarks. The tags for each bookmark are stored ...

Vue's intelligent element loading feature ensures that elements that are not displayed are delayed

My Vue gallery component includes a lightbox feature defined by the following code: <div id="lightbox" class="modal" v-if="photo !== null" v-show="showModal" @click.self="closeModal"> <div clas ...

Struggling to incorporate blocks into Jade for Express. Encountering errors like "Max Stack Size Exceeded" and issues with setHeader

I am currently using Express along with a simple express-generator server that I created. My first task was to focus on creating the view layout and extending the index page, but unfortunately, I have encountered some challenges. Throughout my process, I& ...

Determining if data from two separate lists in Vue.js matches in order to display in the template

I need to compare two sets of data - one fetched from the server and the other being default data. Data retrieved from the server: [ { "id": 7, "day": "14 April 2017", "time_list": [ { "id": 25, "time": "11:00 AM", ...

Guide on integrating HTML from a response into the render function in React JS

I've been doing some research but I'm struggling to find a good solution for this issue. I have a response that looks like this: "name": "another test", "description": "para hacer el aseo", &quo ...

Can someone clarify if there is a distinction between using x.f.call(x, ...) and x.f(...) in JavaScript?

Reviewing some code reveals the following: this.f.call(this); Or in other scenarios: this.someObj.f.call(this.someObj); Is there a distinction between these and: this.f(); this.someObj.f(); Under what circumstances might the behavior differ? (e.g. if ...

javascript snippet for extracting the dynamically created div IDs

Currently, I am developing an application using Java and AngularJS. Within this project, there is an HTML page that iterates through an object to display the values on the page. Here is the snippet of the HTML code: <div id="{{value.pageIndex}}" ng-re ...

Helping JavaScript determine my current location on the website

One issue I am facing is with a single template file that renders pages that may look similar but have slightly different behaviors. The header and text boxes are filled by the template language, while the canvas content distinguishes the pages. Different ...

The issue persists with the addEventListener function not working multiple times

My issue is that the addEventListener function is only working for the 'scroll' event and not for 'addMoreFields' or 'removeFields'. If I move the scroll section down, then it works for 'addMoreFields' and 'remo ...

How can we effectively map Typescript Enums using their keys without relying on a Map?

Consider the following Enum instances: export enum TopicCategories { GUIDES = 'Guides', TASKS = 'Tasks', CONCEPTS = 'Concepts', FORMULAS = 'Formulas', BLOGS = 'Blogs' } export enum Top ...

What is the reason for Firefox displaying the "excessive recursion" error message?

I have been working on generating an area Google chart using the code below, but I am running into an issue where Firefox is showing me a "too much recursion" error. The chart currently only has one point for testing purposes. Can anyone provide some gui ...

Reduce the number of days from a specified ISO date

How can I calculate the number of days between today and a date that's stored in my MongoDB database in ISO format? Your help is greatly appreciated. let ISOdate = ISODate("2020-12-25T20:40:08.295Z") let difference = newDate() - ISOdate; i ...

Is the data fetched by getStaticProps consistently the same each time I revisit the page?

When utilizing routes to access a specific page like page/[id].js, the concern arises whether data will be refetched each time the page is visited. For instance, if you navigate to another page through a link and then return to this original page by pres ...

Troubleshooting: Issue with append function not functioning properly after click event in Angular

I am struggling to implement a basic tooltip in AngularJS. Below is the HTML I have: <span class="afterme" ng-mouseover="showToolTip('this is something', $event)" ng-mouseleave="hideToolTip();"> <i class="glyphicon glyphicon-exclama ...

Incorporate the xml2js JavaScript library with Angular 2 for enhanced functionality

I've been attempting to utilize xml2js as an XML parser within my Angular 2 (RC 1 with TypeScript) web application. Unfortunately, I've encountered several errors without finding a solution that works. Here is the detailed process I followed: ...

Load Bootstrap and Popper using Require.js and CDN

My goal is to utilize require.js to load bootstrap and jquery from a CDN. Although similar questions have been asked previously (such as Steve Eynon's response in Issue Loading PopperJS and Bootstrap via RequireJS, Even After Using Recommended Popper ...

Learn how to effortlessly download a file from Amazon S3 using Angular and ng-click technology

When attempting to download a file from my Amazon S3 bucket using Angular's ng-click, I am receiving a blank file instead of the expected content. HTML <div class="details-field"> RC Book <font class="digit" >({{rcCount}})</font> ...

What is the process for fetching a texture from a MySql database using three.js?

Is it possible to load a model's texture from a MySql database using three.js and php, based on the logged-in user? My goal is to display the texture on the model that corresponds to the current user. Can I simply use "echo" to retrieve the column con ...

Looking to include a sub element in my menu items using jQuery and CSS

Using jQuery and CSS, I have created a menu item. How can I navigate from one menu item to another sub menu item, as illustrated in the image below? Below is my HTML markup: <link rel="stylesheet" href="css/style_j.css" type="text/css" media="screen"/ ...

Guide on adding pictures to an ExpressJS server

Working on this project has been quite a challenge for me as I delve deeper into web development. As a relatively new developer, creating a one-page application with image upload functionality has proven to be quite the task, especially considering this is ...