Convert attr to classed

This commit is contained in:
Caleb Usadi
2022-10-26 00:17:20 -04:00
parent 58d692e6f5
commit a59f49c04f

View File

@@ -77,7 +77,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
// Add a text node for the attribute type // Add a text node for the attribute type
const typeNode = groupNode const typeNode = groupNode
.append('text') .append('text')
.attr('class', 'er entityLabel') .classed('er entityLabel', true)
.attr('id', `${attrPrefix}-type`) .attr('id', `${attrPrefix}-type`)
.attr('x', 0) .attr('x', 0)
.attr('y', 0) .attr('y', 0)
@@ -90,7 +90,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
// Add a text node for the attribute name // Add a text node for the attribute name
const nameNode = groupNode const nameNode = groupNode
.append('text') .append('text')
.attr('class', 'er entityLabel') .classed('er entityLabel', true)
.attr('id', `${attrPrefix}-name`) .attr('id', `${attrPrefix}-name`)
.attr('x', 0) .attr('x', 0)
.attr('y', 0) .attr('y', 0)
@@ -114,7 +114,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
if (hasKeyType) { if (hasKeyType) {
const keyTypeNode = groupNode const keyTypeNode = groupNode
.append('text') .append('text')
.attr('class', 'er entityLabel') .classed('er entityLabel', true)
.attr('id', `${attrPrefix}-key`) .attr('id', `${attrPrefix}-key`)
.attr('x', 0) .attr('x', 0)
.attr('y', 0) .attr('y', 0)
@@ -133,7 +133,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
if (hasComment) { if (hasComment) {
const commentNode = groupNode const commentNode = groupNode
.append('text') .append('text')
.attr('class', 'er entityLabel') .classed('er entityLabel', true)
.attr('id', `${attrPrefix}-comment`) .attr('id', `${attrPrefix}-comment`)
.attr('x', 0) .attr('x', 0)
.attr('y', 0) .attr('y', 0)
@@ -209,7 +209,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
// Insert a rectangle for the type // Insert a rectangle for the type
const typeRect = groupNode const typeRect = groupNode
.insert('rect', '#' + attributeNode.tn.node().id) .insert('rect', '#' + attributeNode.tn.node().id)
.attr('class', `er ${attribStyle}`) .classed(`er ${attribStyle}`, true)
.style('fill', conf.fill) .style('fill', conf.fill)
.style('fill-opacity', '100%') .style('fill-opacity', '100%')
.style('stroke', conf.stroke) .style('stroke', conf.stroke)
@@ -229,7 +229,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
// Insert a rectangle for the name // Insert a rectangle for the name
const nameRect = groupNode const nameRect = groupNode
.insert('rect', '#' + attributeNode.nn.node().id) .insert('rect', '#' + attributeNode.nn.node().id)
.attr('class', `er ${attribStyle}`) .classed(`er ${attribStyle}`, true)
.style('fill', conf.fill) .style('fill', conf.fill)
.style('fill-opacity', '100%') .style('fill-opacity', '100%')
.style('stroke', conf.stroke) .style('stroke', conf.stroke)
@@ -251,7 +251,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
// Insert a rectangle for the key type // Insert a rectangle for the key type
const keyTypeRect = groupNode const keyTypeRect = groupNode
.insert('rect', '#' + attributeNode.kn.node().id) .insert('rect', '#' + attributeNode.kn.node().id)
.attr('class', `er ${attribStyle}`) .classed(`er ${attribStyle}`, true)
.style('fill', conf.fill) .style('fill', conf.fill)
.style('fill-opacity', '100%') .style('fill-opacity', '100%')
.style('stroke', conf.stroke) .style('stroke', conf.stroke)
@@ -274,7 +274,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => {
// Insert a rectangle for the comment // Insert a rectangle for the comment
groupNode groupNode
.insert('rect', '#' + attributeNode.cn.node().id) .insert('rect', '#' + attributeNode.cn.node().id)
.attr('class', `er ${attribStyle}`) .classed(`er ${attribStyle}`, 'true')
.style('fill', conf.fill) .style('fill', conf.fill)
.style('fill-opacity', '100%') .style('fill-opacity', '100%')
.style('stroke', conf.stroke) .style('stroke', conf.stroke)
@@ -327,7 +327,7 @@ const drawEntities = function (svgNode, entities, graph) {
const textId = 'text-' + entityId; const textId = 'text-' + entityId;
const textNode = groupNode const textNode = groupNode
.append('text') .append('text')
.attr('class', 'er entityLabel') .classed('er entityLabel', true)
.attr('id', textId) .attr('id', textId)
.attr('x', 0) .attr('x', 0)
.attr('y', 0) .attr('y', 0)
@@ -346,7 +346,7 @@ const drawEntities = function (svgNode, entities, graph) {
// Draw the rectangle - insert it before the text so that the text is not obscured // Draw the rectangle - insert it before the text so that the text is not obscured
const rectNode = groupNode const rectNode = groupNode
.insert('rect', '#' + textId) .insert('rect', '#' + textId)
.attr('class', 'er entityBox') .classed('er entityBox', true)
.style('fill', conf.fill) .style('fill', conf.fill)
.style('fill-opacity', '100%') .style('fill-opacity', '100%')
.style('stroke', conf.stroke) .style('stroke', conf.stroke)
@@ -450,7 +450,7 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) {
// Insert the line at the right place // Insert the line at the right place
const svgPath = svg const svgPath = svg
.insert('path', '#' + insert) .insert('path', '#' + insert)
.attr('class', 'er relationshipLine') .classed('er relationshipLine', true)
.attr('d', lineFunction(edge.points)) .attr('d', lineFunction(edge.points))
.style('stroke', conf.stroke) .style('stroke', conf.stroke)
.style('fill', 'none'); .style('fill', 'none');
@@ -527,7 +527,7 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) {
const labelNode = svg const labelNode = svg
.append('text') .append('text')
.attr('class', 'er relationshipLabel') .classed('er relationshipLabel', true)
.attr('id', labelId) .attr('id', labelId)
.attr('x', labelPoint.x) .attr('x', labelPoint.x)
.attr('y', labelPoint.y) .attr('y', labelPoint.y)
@@ -543,7 +543,7 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) {
// Insert the opaque rectangle before the text label // Insert the opaque rectangle before the text label
svg svg
.insert('rect', '#' + labelId) .insert('rect', '#' + labelId)
.attr('class', 'er relationshipLabelBox') .classed('er relationshipLabelBox', true)
.attr('x', labelPoint.x - labelBBox.width / 2) .attr('x', labelPoint.x - labelBBox.width / 2)
.attr('y', labelPoint.y - labelBBox.height / 2) .attr('y', labelPoint.y - labelBBox.height / 2)
.attr('width', labelBBox.width) .attr('width', labelBBox.width)