2
I need to create a code that after passing some parameters it generates a graph similar to the image below, I thought of creating a table for each activity. Does anyone have any tips, or do you know an article that could help me? I think about using Json to pass the data (I know how to work with Json), my problem would be creating this Function in Javascript
This table is defined by dependencies, as we see in the image the activity B is dependent on the activity To
My Json will have a structure similar to the one below:
<script>
$(document).ready(function () {
$.ajax({
type: "GET",
url: "/Venda/GetDadosItensVenda",
success: function (itensVenda) {
if (itensVenda != null) {
$('#tbody').children().remove();
$(itensVenda).each(function (i) {
var tbody = $('#tbody');
var tr = "<tr>";
tr +=
tr += "<td>" + itensVenda[i].CodigoProduto;
tr += "<td>" + itensVenda[i].Quantidade;
tr += "<td>" + itensVenda[i].PrecoUnitario;
tr += "<td>" + "<button class='btn btn-info' onclick=Editar(" + itensVenda[i].Id + ")>" + "Editar";
tr += "<td>" + "<button class='btn btn-danger' onclick=Deletar(" + itensVenda[i].Id + ")>" + "Deletar";
tbody.append(tr);
});
}
}
});
});
`
When you say "a graph" do you refer to the entire image? And is it important that it be all an image? In my opinion, the simplest would be to create several tables (since it is easier to create and style elements in the DOM than to draw arbitrary tables on a canvas), positioning them absolutely in an area of the page. Arrows could be a single image, rotated with CSS. P.S. Although it is important to generate an image, there is a library that can transform the visual result of the page into an image.
– mgibsonbr
By the way, do you already know or have you defined what this JSON would look like? Would it be just a declarative description of the data (and the program draws as you want) or would it also have specified the positioning? If not defined. I would suggest a list of lists, to be drawn from left to right, where each element is either "beginning" or is a structure with the table values (the tables always have the same format, right?). Just one question: are all the elements on the right "reachable" by all the elements on the left? Could for example have an E with arrow coming out of B but not C?
– mgibsonbr
@mgibsonbr It would not be an image no, it would be several tables even. I edited my question with a Json similar to what I want to use.
– user31040
Does it have to be in this layout? I wonder why we have several frameworks that can help to build a chart. But in this layout I find difficult. Especially because it doesn’t look like a graph rsrs
– Emir Marques
Not that it needs to be a graph, just be something visual to inform dependencies between activities. I’m open to suggestions.
– user31040