Design a visually engaging Gantt chart with the power of d3.js

Here is the type of data I have on hand:

[
  {'TotalTime': 10, 'Hour': 0, 'Name': 'Sam'}, 
  {'TotalTime': 15, 'Hour': 1, 'Name': 'Bob'}, 
  {'TotalTime': 300, 'Hour': 2, 'Name': 'Tom'},
  ... and so forth until, 
  {'TotalTime': 124, 'Hour': 23, 'Name': 'Jon'}
]

I have data available for each hour of the day and my goal is to generate a Gantt Chart using this data. The bar sizes should be determined by the TotalTime.

The y-axis will display Names while the x-axis will represent Hour.

Is it feasible to create a Gantt chart in d3.js without specifying start and end times?

Answer №1

To create a Gantt-style chart using D3.js, you will need to draw it yourself. Start by setting up the axes and adding them to an SVG. Next, convert your data into rectangles that represent different tasks or time blocks on the chart. Label each rectangle with the corresponding data name.

D3.js does not have a built-in layout for Gantt charts, so you will have to implement this customization from scratch. If you are new to creating bar charts or working with D3.js, it's recommended to go through some tutorials like Let’s Make a Bar Chart, Parts I, II, and III before diving into this project.

While there are other libraries like C3 that offer prefabricated charts similar to D3 layouts, finding one specifically designed for Gantt-style charts may be challenging. You can explore examples like this Gantt chart which demonstrates a random task allocation across various time scales.

If you prefer a more calendar-like approach, check out the example provided at: https://github.com/dlamblin/timeblocks. This example showcases how you can adapt D3.js for different data formatting needs while maintaining a visually appealing design.

For a simplified JSfiddle example demonstrating a vertical layout of scheduled time blocks over a 7-day week, follow this link: JSfiddle Example.

The provided JavaScript snippet offers insights into structuring and updating the Gantt-style chart effectively. It includes functions for updating scales, rendering data elements, transitioning animations, and managing axes for improved visualization.

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

display upcoming schedule and time

How can I display the future date and time in the respective field components? See below for a sample code snippet: require([ "dojo/_base/lang", "dijit/registry", "dojo/ready", "dijit/form/TimeTextBox", "dojo/parser" ], function(lang, registry, ready ...

forming an instance from JSON information

In a .json file, I have data that includes information on countries such as their currency, major language, and land area in square kilometers or square miles. { "countries": { "sweden": { "currency": "Swedish krona", " ...

Arrange array of objects based on a specific key

I am currently working with an array of objects that looks like this: [ { '1485958472927784961': { name: 'bruno fiverr', points: 6, user_id: '1485958472927784961', tweets: [Array] }, &apos ...

tag containing inner text of span tag tagged with anchor tag

Using JavaScript, I have dynamically assigned an anchor tag within a span tag. However, the href attribute of the anchor tag is being formed incorrectly. Here is the JavaScript code: var HF1Id , HF2Id , SpanId , HF1Id = '<%=Request("HF1Id") %> ...

Creating a test harness for HTML JSON AJAX with a prettified display of syntax-highlighted JSON results

Having completed a JSON API, I am now looking to test it using a simple webpage that displays the JSON result in a prettified, syntax-highlighted format. To illustrate, let's consider the following example of a GET API call: http://www.google.com/ca ...

Braintree drop-in feature now allows for automatic disabling of the submit button while the transaction

I've been struggling with a seemingly simple task that I just can't seem to figure out. I'm using Braintree's dropin UI and I have a submit button that I need to disable while the processing is happening, but I can't seem to find t ...

What happens when there is no match found while attempting to edit a form with the UI-Bootstrap typeahead directive?

Here is the code that demonstrates how my typeahead input box functions. Users can enter a name, and the relevant information will populate the rest of the form. If no match is found, users should still be able to input the name and related details into th ...

The responsiveness of Slick Slider's breakpoints is malfunctioning

After implementing a slider using slick slider, I encountered an issue with the width when testing it online and in a normal HTML file. If anyone could assist me in resolving this issue, I would greatly appreciate it. Please inspect the code for both scen ...

Ways to conceal text that is not wrapped in an HTML tag

<div class="padd10_m"> <a href="http://www.caviarandfriends.com/job_board/user-profile/admin/" class="grid_view_url_thing1">admin</a> <img src="http://www.caviarandfriends.com/job_board/wp-content/themes/PricerrTheme/images/flags/us.pn ...

Retrieving display format or formatted value from an object with Moment.js

I am currently working on a project using Angular and Material2. Within this project, I have created a moment object in the following way: myDate = moment.utc(new Date()).format("YYYY-MM-DD HH:mm:ss"); This object is then passed as an argument to ano ...

Transferring elements from one array to multiple arrays

I have been working with the basics of JavaScript arrays and here is my code snippet: let arr = ['students', 'exams', [{'sub1':80, 'sub2':60},{'grade_sub1':'A', 'grade_sub2':'B&apos ...

The POST request functions smoothly in Postman, however, encounters an error when executed in node.js

Just recently I began learning about node.js and attempted to send a post request to an external server, specifically Oracle Commmerce Cloud, in order to export some data. Check out this screenshot of the request body from Postman: View Request Body In Pos ...

AngularJS - Using filters to extract specific options from multiple <select> components

There are N "select" components generated based on JSON data, with the "options" populated by an external API. I am trying to implement a custom filter that ensures when an option is selected in one "select" component, it should not appear in the other com ...

a guide on monitoring the status of a stripe transaction through a straightforward form and javascript

Currently, I am in the process of setting up Stripe checkout for my website. I have successfully implemented the payment form, but now I need to figure out how to redirect the user to another page after a successful payment. Below is the JavaScript code th ...

Using jQuery and regex to only allow alphanumeric characters, excluding symbols and spaces

Seeking advice, I am using a jquery function called alphanumers var alphanumers = /^[a-zA-Z0-9- ]*$/; which currently does not allow all symbols. However, I now wish to disallow the space character as well. Any suggestions? ...

Enhance your JSON formatting with dynamic fields

I am currently working on creating a form with dynamic fields in order to generate a JSON format for posting. The challenge lies in the structure of the JSON, particularly with the "envname" and "value" fields which need to be dynamically added based on us ...

What is the best way to incorporate a PHP/JavaScript photo gallery into a page on an HTML/CSS website?

I recently discovered Minishowcase, a free photo gallery software that I downloaded from . The gallery itself functions perfectly as its own website, but I am struggling to figure out how to integrate it into my existing site, which is primarily coded in C ...

React Error boundary is failing to perform as anticipated

Having issues implementing an error boundary in React. Here is the code snippet: ErrorBoundary.js import React from 'react'; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: fal ...

Increase the identifier of my input text when a table row is duplicated through Javascript

I have a table with only one row that contains various elements like textboxes and buttons. I want to clone the table row using the append() function when a button is clicked. However, I am facing an issue - how can I increment the id of the textboxes and ...

Issue with Ajax response and JSON parsing in Jquery

I recently made a POST call to a Rest API for logging in and received a successful response with various data. To confirm the information and determine what details I need to keep, I decided to log this data. Here is the code snippet I used: $.aja ...