5432 WIP, rendering items

This commit is contained in:
Knut Sveidqvist 2024-10-06 19:22:07 +02:00
parent fb44e769f2
commit 93f2c241b8
6 changed files with 25 additions and 14 deletions

View File

@ -89,12 +89,13 @@ kanban
id2[Create JISON] id2[Create JISON]
id3[Update DB function] id3[Update DB function]
id4[Create parsing tests] id4[Create parsing tests]
id5[define getData] id6[Create renderer so that it works in all cases. We also add som extra text here for testing purposes.]
id6[Create renderer so that it works in all cases] id66[last item]
id7[In progress] id7[In progress]
id8[Design grammar] id8[Design grammar]
id9[Ready for deploy] id9[Ready for deploy]
id10[Ready for test] id10[Ready for test]
id5[define getData]
id11[Done] id11[Done]
id12[Can't reproduce] id12[Can't reproduce]
</pre> </pre>
@ -116,7 +117,7 @@ kanban
// layout: 'dagre', // layout: 'dagre',
// layout: 'elk', // layout: 'elk',
// layout: 'fixed', // layout: 'fixed',
// htmlLabels: false, htmlLabels: false,
flowchart: { titleTopMargin: 10 }, flowchart: { titleTopMargin: 10 },
// fontFamily: 'Caveat', // fontFamily: 'Caveat',
// fontFamily: 'Kalam', // fontFamily: 'Kalam',
@ -126,6 +127,9 @@ kanban
noteFontFamily: 'courier', noteFontFamily: 'courier',
messageFontFamily: 'courier', messageFontFamily: 'courier',
}, },
kanban: {
htmlLabels: false,
},
fontSize: 12, fontSize: 12,
logLevel: 0, logLevel: 0,
securityLevel: 'loose', securityLevel: 'loose',

View File

@ -76,6 +76,8 @@ const getData = function () {
label: sanitizeText(item.descr, conf), label: sanitizeText(item.descr, conf),
isGroup: false, isGroup: false,
shape: 'kanbanItem', shape: 'kanbanItem',
rx: 5,
cssStyles: ['text-align: left'],
} satisfies Node; } satisfies Node;
nodes.push(childNode); nodes.push(childNode);
} }

View File

@ -106,13 +106,13 @@ export const draw: DrawDefinition = async (text, id, _version, diagObj) => {
const padding = 10; const padding = 10;
for (const section of sections) { for (const section of sections) {
let y = 0; const WIDTH = 200;
let y = (-WIDTH * 3) / 2 + 40;
cnt = cnt + 1; cnt = cnt + 1;
const WIDTH = 300;
section.x = WIDTH * cnt + ((cnt - 1) * padding) / 2; section.x = WIDTH * cnt + ((cnt - 1) * padding) / 2;
section.width = WIDTH; section.width = WIDTH;
section.y = 0; section.y = 0;
section.height = WIDTH; section.height = WIDTH * 3;
section.rx = 5; section.rx = 5;
section.ry = 5; section.ry = 5;
@ -123,14 +123,15 @@ export const draw: DrawDefinition = async (text, id, _version, diagObj) => {
// positionCluster(section); // positionCluster(section);
for (const item of sectionItems) { for (const item of sectionItems) {
item.x = section.x; item.x = section.x;
item.width = WIDTH - padding * 2; item.width = WIDTH - 2 * padding;
// item.height = 100; // item.height = 100;
const nodeEl = await insertNode(nodesElem, item); const nodeEl = await insertNode(nodesElem, item);
console.log('ITEM', item, 'bbox=', nodeEl.node().getBBox()); console.log('ITEM', item, 'bbox=', nodeEl.node().getBBox());
item.y = y; const bbox = nodeEl.node().getBBox();
item.height = 150; item.y = y + bbox.height / 2;
// item.height = 150;
await positionNode(item); await positionNode(item);
y = y + 1.5 * nodeEl.node().getBBox().height + padding / 2; y = item.y + bbox.height / 2 + padding;
} }
} }

View File

@ -52,7 +52,7 @@ const genSections: DiagramStylesProvider = (options) => {
.node ellipse, .node ellipse,
.node polygon, .node polygon,
.node path { .node path {
fill: ${options.mainBkg}; fill: ${options.background};
stroke: ${options.nodeBorder}; stroke: ${options.nodeBorder};
stroke-width: 1px; stroke-width: 1px;
} }

View File

@ -326,7 +326,7 @@ const kanbanSection = async (parent, node) => {
const height = node.height; const height = node.height;
const x = node.x - width / 2; const x = node.x - width / 2;
const y = node.y; const y = node.y - height / 2;
log.trace('Data ', node, JSON.stringify(node)); log.trace('Data ', node, JSON.stringify(node));
let rect; let rect;

View File

@ -9,10 +9,14 @@ export const kanbanItem = async (parent: SVGAElement, node: Node) => {
const { labelStyles, nodeStyles } = styles2String(node); const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles; node.labelStyle = labelStyles;
// console.log('IPI labelStyles:', labelStyles); // console.log('IPI labelStyles:', labelStyles);
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const labelPaddingX = 10; const labelPaddingX = 10;
const orgWidth = node.width;
node.width = (node.width ?? 200) - 2 * labelPaddingX;
console.log('APA123 kanbanItem', node.labelStyle);
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
node.width = orgWidth;
const labelPaddingY = 10; const labelPaddingY = 10;
const totalWidth = Math.max(bbox.width + labelPaddingX * 2, node?.width || 0); const totalWidth = node?.width || 0;
const totalHeight = Math.max(bbox.height + labelPaddingY * 2, node?.height || 0); const totalHeight = Math.max(bbox.height + labelPaddingY * 2, node?.height || 0);
const x = -totalWidth / 2; const x = -totalWidth / 2;
const y = -totalHeight / 2; const y = -totalHeight / 2;