From 95fd04e74d35ff36fd4c02d1b832ec1f67330d43 Mon Sep 17 00:00:00 2001 From: ialokim Date: Mon, 6 Apr 2020 18:40:04 +0200 Subject: [PATCH] always add bits label to ports markup (#14) --- src/cells/base.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cells/base.js b/src/cells/base.js index c593e42..e97b742 100644 --- a/src/cells/base.js +++ b/src/cells/base.js @@ -58,27 +58,27 @@ export const Gate = joint.shapes.basic.Generic.define('Gate', { _.set(args, ['attrs', 'path.wire.port_' + port.id], wire_args); _.set(args, ['attrs', 'circle.port_' + port.id], circle_args); let markup = ''; - if (port.bits > 1) { - markup += ''; - const bits_args = { - text: port.bits, - ref: 'circle.port_' + port.id - }; - if (vert) { - // TODO - } else { - bits_args['ref-y'] = -3; - bits_args['text-anchor'] = 'middle'; - } - if (side == 'left') { - bits_args['ref-dx'] = 6; - } else if (side == 'right') { - bits_args['ref-x'] = -6; - } else if (side == 'top') { - bits_args['ref-y'] = 6; - } else console.assert(false); - _.set(args, ['attrs', 'text.bits.port_' + port.id], bits_args); + + markup += ''; + const bits_args = { + text: port.bits > 1 ? port.bits : "", + ref: 'circle.port_' + port.id + }; + if (vert) { + // TODO + } else { + bits_args['ref-y'] = -3; + bits_args['text-anchor'] = 'middle'; } + if (side == 'left') { + bits_args['ref-dx'] = 6; + } else if (side == 'right') { + bits_args['ref-x'] = -6; + } else if (side == 'top') { + bits_args['ref-y'] = 6; + } else console.assert(false); + _.set(args, ['attrs', 'text.bits.port_' + port.id], bits_args); + const signame = port.dir == 'in' ? 'inputSignals' : 'outputSignals'; if (_.get(args, [signame, port.id]) === undefined) { _.set(args, [signame, port.id], Vector3vl.xes(port.bits));