digraph {
graph[bgcolor="gold1:dodgerblue"]
node[shape=box;style="filled";];
edge[color="#000080";arrowhead="open";];
A [peripheries=2;color="blue:green:blue";fillcolor="#ddffff";];
B [fillcolor="#ddffff";];
A->B
}
Outputs the first picture. How to fill the gap and get the second picture?
The exact solution is still not found but HTML-Like Labels give a visually equivalent workaround. Though the code is pretty verbose it suites for my case.
digraph {
graph[imagepath=".";];
graph[layout=dot;rankdir=LR;];
node[shape=box;style="filled";];
node[shape=box;style="filled";penwidth="1";width=0;height=0;margin="0.05,0.05"];
edge[color="#000080";arrowhead="open";];
A [fillcolor="yellow";label=< <table cellpadding="0" cellspacing="0" border="1" bgcolor="#ffddff">
<tr><td cellpadding="5" border="0">Marked node</td></tr>
</table> >;];
B [fillcolor="#ddffff";label="Ordinary node";];
A->B
}
No solution yet. Found an alternative way to highlight the node:
digraph {
graph[imagepath=".";];
graph[layout=dot;rankdir=LR;];
node[shape=box;style="filled";];
node[shape=box;style="filled";penwidth="0.5";width=0;height=0;margin="0.05,0.05"];
edge[color="#000080";arrowhead="open";];
A [fillcolor="#ffddff";label="Marked node";image="rect2681.png";imagepos="tl";margin="0.2,0.05"];
B [fillcolor="#ddffff";label="Ordinary node";];
A->B
}
Works in graphviz-2.44.1. In graphviz-2.38 (and in graphviz-2.40.1 as I could check in Ubuntu) the image is always positioned in the center, i.e. imagepos doesn't work.
Also see the documentation.
UPDATE
Some problems found with graphviz-2.44.1 so need to get back to graphviz-2.38 and using HTML-Like Labels:
digraph {
graph[imagepath=".";];
graph[layout=dot;rankdir=LR;];
node[shape=box;style="filled";];
node[shape=box;style="filled";penwidth="0.5";width=0;height=0;margin="0.05,0.05"];
edge[color="#000080";arrowhead="open";];
A [fillcolor="#ffddff";label=< <table cellpadding="0" cellspacing="0" border="0">
<tr><td><img src="circle_mark.png"/></td>
<td cellpadding="5">Marked node</td></tr>
</table> >; margin="0.04,0"];
B [fillcolor="#ddffff";label="Ordinary node";];
A->B
}
Related
In Netsuite, the #list loop for the item table will only render as many line items as there are number of of items. For example, if there's two items in a Sales Order, there will be only two line items in the PDF template as rendered by this example code:
<#if record.item?has_content>
<table class="itemtable" style="width: 100%;"><!-- start items -->
<#list record.item as item>
<#if item_index==0>
<thead>
<tr>
<th align="center" colspan="1">${item.quantity#label}</th>
<th align="center" colspan="2">${item.item#label}</th>
<th align="center" colspan="3">${item.description#label}</th>
<th align="center" colspan="1">Unit Price</th>
<th align="center" colspan="1">U/M</th>
<th align="center" colspan="1">${item.amount#label}</th>
</tr>
</thead>
</#if>
<tr> <!--Move itemtable row up slightly to remove white space-->
<td align="right" colspan="1">${item.quantity}</td>
<td colspan="2"><span class="itemname">${item.item}</span></td>
<td colspan="3">${item.description}</td>
<td align="right" colspan="1">${item.rate?string.currency}</td>
<td align="center" colspan="1">${item.units}</td>
<td align="right" colspan="1">${item.amount?string.currency}</td>
</tr>
</#list><!-- end items -->
</table>
</#if>
I have been following this official documentation for adding striping to line items in PDF templates https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N2866065.html
Whereupon you add this to of the items:
<tr style="background-color: ${((item_index % 2)==0)?string('#ffffff', '#ccffcc')};">
I need to extend the #list loop so a few "empty" rows with alternate striping are added to the bottom of the line item table:
Striping of line items with alternate background colors + extended
My use case has different number of line items for each order, otherwise I would just hard code three alternate colored rows myself. Thank you!
You could just add some extra items to the list like <#list record.item + [{}, {}, {}] as item>. Then you need an #if that checks if item?has_content, and if not, then render a <tr> with one big spanning td, (unless in reality you need to handle null item.quantity, etc., in which case you don't need this extra #if).
As of using % for coloring, I don't know how many years the Netsuite FreeMarker is behind (except that a lot), but for a long time there's a feature like ${item?item_cycle('#ffffff', '#ccffcc', '#ffccff') in FreeMarker. If they don't yet have ?item_cycle, then I suggest writing a #function that returns the color code based on item_index (and that function will use index % 3 and #if-#elseif-#else, and #return inside).
Another possibility is just maintaining a counter yourself, so it can be independent of #list. Like <#assign rowCount = 0>, and then before each item you do <#assign rowCount++>. But I guess extending the list with empty items is nicer.
I use FreeMarker to build various templates from email to invoice templates. Issue that i am seeking right now is related to FreeMarker code being extracted outside table tag since HTML doesn't allow other characters inside it beside tbody, thead, tr.
Would be glad if anyone has an idea how to bypass this.
Example:
<table>
<tbody>
[#assign eventDetails = []]
[#if items?? && items?has_content]
[#list items as item]
<tr>
<td style="padding: 5px;vertical-align: top;border-bottom: 1px solid #eee; text-align: center;">
${item.name}
</td>
</tr>
[/#list]
[/#if]
</tbody>
</table>
become like this after being applied to editor using element.innerHTML:
[#assign eventDetails = []]
[#if items?? && items?has_content]
[#list items as item]
[/#list]
[/#if]
<table>
<tbody>
<tr>
<td style="padding: 5px;vertical-align: top;border-bottom: 1px solid #eee; text-align: center;">
${item.name}
</td>
</tr>
</tbody>
</table>
It of course only depends on the HTML editor you are using, but you should try if same happens if, either:
You are using the <#...> syntax instead. That looks like some unknown tag for the editor, not CDATA, so maybe it doesn't react the same way.
Replace <tbody>...</tbody> with [#html.tbody]...[/#html.tbody]. Then the editor might won't be confident enough to remove stuff. Or, the same with [#html.table], etc. Quite awkward, but might be better than what you have now. (For that to actually work when running the template, you will have to define the tbody macro in the html namespace of course. It's not built in.)
Example of the last:
<#ftl output_format='HTML'>
<#macro table attrs...><#elementWithNested 'table' attrs><#nested></#></#macro>
<#macro tbody attrs...><#elementWithNested 'tbody' attrs><#nested></#></#macro>
<#macro elementWithNested elementName attrs>
<${elementName}<#if attrs?size != 0><#list attrs as k, v> ${k}="${v}"</#list></#if>>
<#nested>
</${elementName}>
</#macro>
If above template is #import-ed as html, then <#html.table foo="bar">...</#html.table> etc. will work.
I have tried finding a solution to my problem for few days already - somehow I just don't manage to find a working solution.
Unfortunately I cannot give the URL for the webpage that I have as it would require a login and password - which I cannot share.
I have the VBA code already doing me everything, login into the webpage - proving the proper information inside the page and clicking validate button. But the problem is that I should then see if the below text appears:
ENQUADRAMENTO EM VIGOR - if yes, I will continue slightly differently the process and if not then differently.
Now below is the code from the webpage:
<tr>
<td>
<table cellpadding="4" border="0" width="100%">
<tbody><tr>
<td class="fieldTitleBold" style="width=30%">Enquadramento em IVA</td>
<td class="fieldValue" colspan="3">NORMAL TRIMESTRAL</td>
</tr>
<tr>
<td style="width=10%" class="fieldTitleBold">Situação</td>
<td class="fieldValue" colspan="3">ENQUADRAMENTO EM VIGOR</td>
</tr>
</tbody></table>
</td>
</tr>
I have tried many different ways and the latest I tried is with byclassname (this worked for me in a different website for similar purpose) but doesn't work here for some reason:
Set doc = ie.document
Set htmTable = doc.getElementsByClassName("ENQUADRAMENTO EM VIGOR")(0)
If Not htmTable Is Nothing Then
'continue depending if the text was found or not in different ways
ENQUADRAMENTO EM VIGOR is the .innerText value not the class name. The class value is fieldValue and is associated with a td (table cell) element.
This is pretty easy if it only occurs once. Use Instr to see if present in page html
If Instr(ie.document.body.innerHTML,"ENQUADRAMENTO EM VIGOR") > 0 Then
Otherwise, you can gather a nodeList of td elements with that class name and loop testing the .innerText
Dim classes As Object, i As Long
Set classes = ie.document.querySelectorAll("td.fieldValue")
For i = 0 To classes.Length - 1
If classes.item(i).innerText = "ENQUADRAMENTO EM VIGOR" Then
'do something
'Exit For ....
End If
End Sub
$(document).ready(function() {
var lenfV = document.querySelectorAll(".fieldValue");
for(let i=0;i<lenfV.length;i++) {
if(lenfV[i].innerHTML == "ENQUADRAMENTO EM VIGOR") {
console.log("is there");
}
//else {console.log(213423);}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p> I think, The below option will help you</p>
<table>
<tr>
<td>
<table cellpadding="4" border="0" width="100%">
<tbody><tr>
<td class="fieldTitleBold" style="width=30%">Enquadramento em IVA</td>
<td class="fieldValue" colspan="3">NORMAL TRIMESTRAL</td>
</tr>
<tr>
<td style="width=10%" class="fieldTitleBold">Situação</td>
<td class="fieldValue" colspan="3">ENQUADRAMENTO EM VIGOR</td>
</tr>
</table>
</td>
</tr>
</table>
I have table without any class or id (there are more tables on the page) with this structure:
<table cellpadding="2" cellspacing="2" width="100%">
...
<tr>
<td class="cell_c">...</td>
<td class="cell_c">...</td>
<td class="cell_c">...</td>
<td class="cell">SOME_ID</td>
<td class="cell_c">...</td>
</tr>
...
</table>
I want to get only one row, which contains <td class="cell">SOME_ID</td> and SOME_ID is an argument.
UPD.
Currently i am doing iy in this way:
doc = Jsoup.connect("http://www.bank.gov.ua/control/uk/curmetal/detail/currency?period=daily").get();
Elements rows = doc.select("table tr");
Pattern p = Pattern.compile("^.*(USD|EUR|RUB).*$");
for (Element trow : rows) {
Matcher m = p.matcher(trow.text());
if(m.find()){
System.out.println(m.group());
}
}
But why i need Jsoup if most of work is done by regexp ? To download HTML ?
If you have a generic HTML structure that always is the same, and you want a specific element which has no unique ID or identifier attribute that you can use, you can use the css selector syntax in Jsoup to specify where in the DOM-tree the element you are after is located.
Consider this HTML source:
<html>
<head></head>
<body>
<table cellpadding="2" cellspacing="2" width="100%">
<tbody>
<tr>
<td class="cell">I don't want this one...</td>
<td class="cell">Neither do I want this one...</td>
<td class="cell">Still not the right one..</td>
<td class="cell">BINGO!</td>
<td class="cell">Nothing further...</td>
</tr> ...
</tbody>
</table>
</body>
</html>
We want to select and parse the text from the fourth <td> element.
We specify that we want to select the <td> element that has the index 3 in the DOM-tree, by using td:eq(3). In the same way, we can select all <td> elements before index 3 by using td:lt(3). As you've probably figured out, this is equal and less than.
Without using first() you will get an Elements object, but we only want the first one so we specify that. We could use get(0) instead too.
So, the following code
Element e = doc.select("td:eq(3)").first();
System.out.println("Did I find it? " + e.text());
will output
Did I find it? BINGO!
Some good reading in the Jsoup cookbook!
My table has several columns.
Each column should have dynamic width that depends on the browser window size. On the other hand, each column must not be too tiny. So I tried to set min-width for those columns but it's not a valid property. Tried min-width for <td> as well but that too is an invalid property.
Is there any way to set min-width for col/td in HTML table?
try this one:
<table style="border:1px solid">
<tr>
<td style="min-width:50px;border:1px solid red">one</td>
<td style="min-width:100px;border:1px solid red">two</td>
</tr>
</table>
min-width and max-width properties do not work the way you expect for table cells. From spec:
In CSS 2.1, the effect of 'min-width' and 'max-width' on tables, inline tables, table cells, table columns, and column groups is undefined.
This hasn't changed in CSS3.
Try using an invisible element (or psuedoelement) to force the table-cell to expand.
td:before {
content: '';
display: block;
width: 5em;
}
JSFiddle: https://jsfiddle.net/cibulka/gf45uxr6/1/
If you need your cells to be large enough to fit the largest word in that column, you can try surrounding that or those specific words with <span style="white-space: nowrap">; that will cause that specific word to not wrap, forcing the column-width to be a minimum of that dynamic width.
Idea from #Jon.
<table style="min-width:50px; max-width:150px;">
<tr>
<td style="min-width:50px">one</td>
<td style="min-width:100px">two</td>
</tr>
</table>
This works for me using an email script.
None of these solutions worked for me. The only workaround I could find was, adding all the min-width sizes together and applying that to the entire table. This obviously only works if you know all the column sizes in advanced, which I do. My tables look something like this:
var columns = [
{label: 'Column 1', width: 80 /* plus other column config */},
{label: 'Column 2', minWidth: 110 /* plus other column config */},
{label: 'Column 3' /* plus other column config */},
];
const minimumTableWidth = columns.reduce((sum, column) => {
return sum + (column.width || column.minWidth || 0);
}, 0);
tableElement.style.minWidth = minimumTableWidth + 'px';
This is an example and not recommended code. Fit the idea to your requirements. For example, the above is javascript and won't work if the user has JS disabled, etc.
One way should be to add a <div style="min-width:XXXpx"> within the td, and let the <td style="width:100%">
If you have set the percentages width of your columns and for you could be enough to FIX the entire table width or set a minimum width, this is valid
<table style="min-width:1000px;">
or
<table style="width:1000px;">
please note that this is said to work ONLY as inline style
I had this need with a bootstrap 5 table and my code ended to be
<table style="min-width:1000px;" class="table table-striped
table-hover table-bordered text-center table-responsive" id="tabella">
you better appreciate this when in mobile with small or empty TDs content
<table style="border:2px solid #ddedde">
<tr>
<td style="border:2px solid #ddedde;width:50%">a</td>
<td style="border:2px solid #ddedde;width:20%">b</td>
<td style="border:2px solid #ddedde;width:30%">c</td>
</tr>
<tr>
<td style="border:2px solid #ddedde;width:50%">a</td>
<td style="border:2px solid #ddedde;width:20%">b</td>
<td style="border:2px solid #ddedde;width:30%">c</td>
</tr>
</table>