Hi Grist Team !
(Every time I’m coming there I’m feeling so happy and grateful !)
Short suggestion for Gantt + TimeLine visualisation tool …
Hi Grist Team !
(Every time I’m coming there I’m feeling so happy and grateful !)
Short suggestion for Gantt + TimeLine visualisation tool …
The timeline view is also a feature I’m looking forward. Never used the Gantt myself in alternatives.
Well, I guess someone with good coding skills might able to create one as a Custom Widget?
To display a Gantt chart using D3.js, you would need to build the chart from the data. Here’s an example of how you might modify the code to display a Gantt chart:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>onRecord</title>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://docs.getgrist.com/grist-plugin-api.js"></script>
</head>
<body>
<div id="gantt-chart"></div>
<script>
grist.ready();
grist.onRecord(function(record) {
var data = JSON.parse(record.data);
// Define the dimensions of the chart
var margin = {top: 20, right: 20, bottom: 20, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
// Define the scales for the chart
var x = d3.scaleTime().range([0, width]);
var y = d3.scaleBand().rangeRound([0, height]).padding(0.1);
// Define the svg element to render the chart
var svg = d3.select("#gantt-chart").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// Define the y-axis
y.domain(data.map(function(d) { return d.task; }));
svg.append("g")
.attr("class", "y axis")
.call(d3.axisLeft(y));
// Define the x-axis
x.domain([d3.min(data, function(d) { return d.start; }), d3.max(data, function(d) { return d.end; })]);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x));
// Add the bars to the chart
svg.selectAll(".bar")
.data(data)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.start); })
.attr("width", function(d) { return x(d.end) - x(d.start); })
.attr("y", function(d) { return y(d.task); })
.attr("height", y.bandwidth());
});
</script>
</body>
</html>
To host the code on Github, you can follow these steps:
I haven´t tested the code. In fact, I never even used Github exactly. The code above and text was done by our friend ChatGPT. I expect some errors initially.
Hello @RogerioPenna ,
I’ll give it a trial when I have a moment and keep you informed.
I’m interesting in integrating D3js, having also possibility to build module for SPC, Cpk and so on (Minitab like). This would need to be able to integrate some math and statistic module. Yet this is not on the top of my priorities
Thanks.