logo
down
shadow

How to auto size nodes based on content in cytoscape.js


How to auto size nodes based on content in cytoscape.js

By : Conor Kaminer
Date : November 17 2020, 11:55 AM
around this issue This is planned for 2.4, but I don't know whether I'll be able to devote the time to it in the near future: https://github.com/cytoscape/cytoscape.js/issues/649
code :


Share : facebook icon twitter icon
Auto-size Ext JS Window based on content, up to maxHeight

Auto-size Ext JS Window based on content, up to maxHeight


By : user3269490
Date : March 29 2020, 07:55 AM
may help you . I have exactly the same problem and for now I'm doing a litle dirty hack :)
code :
this.on('afterrender', function() {
    if (this.getHeight() > this.maxHeight) {
        this.setHeight(this.maxHeight);
    }
    this.center();
}, this);
listeners: {afterlayout: function() {
    var height = Ext.getBody().getViewSize().height;
    if (this.getHeight() > height) {
        this.setHeight(height);
    }
    this.center();
}}
Cytoscape.js style node based on content

Cytoscape.js style node based on content


By : user2485761
Date : March 29 2020, 07:55 AM
will be helpful for those in need Unless, content is in the node's data, that won't work. If you have the ID of a node (e.g. foo), you can use #foo or [id = 'foo'] as the selector.
Vertically scrolling graph with fixed size nodes with Cytoscape.js?

Vertically scrolling graph with fixed size nodes with Cytoscape.js?


By : marie carline
Date : March 29 2020, 07:55 AM
With these it helps Based on the suggestions of maxkfranz and gcpdev, I came up with the following solution that seems to work pretty well.
Cytoscope Init:
code :
cy = cytoscape({
    container: document.getElementById('cy'),
    style: cytoscape.stylesheet()
      .selector('node')
      .css({
          'shape': 'roundrectangle',
          'height': 80,
          'width': 150,
          'background-fit': 'cover',
          'background-color': '#F5F5F5',
          'border-color': '#F5F5F5',
          'border-width': 3,
          'border-opacity': 0.5,
          'text-valign': 'center',
          'content': 'data(name)',
       })
       .selector('edge')
       .css({
           'width': 6,
           'target-arrow-shape': 'triangle',
           'line-color': '#0088cc',
           'target-arrow-color': '#0088cc'
       }),
   elements: data,
   zoomingEnabled: false,
   layout: {
       name: 'breadthfirst',
       directed: true,
       padding: 10
   }
}); // cy init
cy.on('ready', function () {
    updateBounds();
});
//if they resize the window, resize the diagram
$(window).resize(function () {
    updateBounds();
});

var updateBounds = function () {
    var bounds = cy.elements().boundingBox();
    $('#cyContainer').css('height', bounds.h + 300);
    cy.center();
    cy.resize();
    //fix the Edgehandles
    $('#cy').cytoscapeEdgehandles('resize');
};
Cytoscape.js - create circular nodes with size

Cytoscape.js - create circular nodes with size


By : Pradeep Kumar
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , If you can use a fixed-width font, then @BeerBaron's answer is best.
Alternatively, use the stylesheet you have in the OP:
code :
style: {
  'shape': 'ellipse',
  'width': 'label',
  'height': 'data(height)'
}
cy.nodes().forEach(function( n ){ n.data('height', n.width()); });
How to auto size chat bubble element based on text content?

How to auto size chat bubble element based on text content?


By : Marcelo Cordeiro Flo
Date : March 29 2020, 07:55 AM
I wish this help you I have made some changes to your code and achieved it. Please see this Fiddle and let me know if this is what desired output is.
code :
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>

<style>
  .bubble {
    clear: both;
    box-sizing: border-box;
    position: relative;
    width: auto;
    height: auto;
    padding: 4px;
    background: #C28584;
    border-radius: 10px;
    margin: 10px 30px;
    display: inline-block;
    z-index: -1;
    padding-left: 15px;
    /* min-width: 50px; */
    padding-right: 15px;
  }

  .bubble:after {
    content: '';
    position: absolute;
    border-style: solid;
    border-width: 11px 32px 11px 0;
    border-color: transparent #C28584;
    display: block;
    width: 0;
    overflow: auto;
    left: -30px;
    top: 50%;
    transform: translateY(-50%);
  }

  .bottom {
    position: absolute;
    bottom: 01px;
  }

  .widebox {
    width: 100%;
    float: left;
    margin-left: -10px;
  }

  button {
    float: right;
    margin-left: 250px;
    margin-right: -50px;
    margin-top: -28px;
  }

</style>

<body>
  <div class="container">

    <div class="row">
      <div class="panel panel-primary">
        <div class="panel-heading">
          <span class="glyphicon glyphicon-comment"></span> Chat
          <div class="btn-group">
          </div>
        </div>
      </div>
    </div>


    <div class="bottom">
      <div id="demo"></div>
      <input class="widebox" type="text" id="myText" value="">
      <button onclick="typo()" class="btn btn-warning btn-sm" id="btn-chat">Send</button>
    </div>
  </div>
  <script>
    function typo() {
      var currentText = document.getElementById("demo").innerHTML;
      var x = '<div><p class=bubble>' + document.getElementById("myText").value + '</div></p>';
      document.getElementById("myText").value = "";
      var y = document.getElementById("demo").innerHTML = currentText + x;
    }

    var input = document.getElementById("myText");
    input.addEventListener("keyup", function(event) {
      event.preventDefault();
      if (event.keyCode === 13) {
        document.getElementById("btn-chat").click();
      }
    });

  </script>

</body>
Related Posts Related Posts :
  • How to change add and remove active class in JavaScript
  • how to toggle a specific div in javascript
  • How to get all the values from multiple keys of an array of object?
  • jQuery bind() unbind() and on() and off()
  • regular expression to find DD Month YYYY from a string
  • How to upload files from web client (HTML/jQuery form) to your Dropbox folder
  • Backbone history and require.js issue
  • Confusion over Classical and Prototypal Inheritance Javascript
  • How to take screen shot of current webpage using Javascript/JQuery?
  • Store meridiem in a variable
  • class declared inside closure vs standard class without closure
  • javascript confirm box always return true
  • dynamically changing the size of font size based on text length using css and html
  • Node.js - Getting the host IP address while on Amazon EC2
  • Confusing CSS, can anyone explain please
  • How to install v8-profiler on Windows 8 (64 bit) using npm?
  • Resolve promise based on another promise
  • google maps adding overlay layer above UI and markers
  • Style specific letter?
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org