Modifying Container Height After Initialization With Resize()
See original GitHub issueI have a HTML DOM that looks like:
<div id="my-element"></div>
with the corresponding code to initialize Cytoscape:
var cy = cytoscape({
container: $('#my-element'),
height: 500px
});
I would like to change the height of the container element to something other than the original 500px
value when an user commits an action.
After going through the docs, it seems like I should be able to do this with cy.resize()
.
I have the following bound to a button click action in my code:
$('#my-element').css('height', 'calc(100% - 410px)');
cy.resize();
But the above doesn’t redraw my Cytoscape container with the new height.
What am I missing here?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Cytoscape JS - Modifying Container Height After Initialization
There is a documented method cy.resize() that you can call to redraw the graph to fit within the context of the current container's...
Read more >vector : : resize() in C++ STL - GeeksforGeeks
The function alters the container's content in actual by inserting or deleting the elements from it.
Read more >Chart Container - Concepts - Handbook - Apache ECharts
In general, you need to define a <div> node and use the CSS to change the width and height. While initializing, import the...
Read more >std::vector::resize - CPlusPlus.com
Change size. Resizes the container so that it contains n elements. If n is smaller than the current container size, the content is...
Read more >std::vector::resize - cppreference.com
[edit] Parameters ; count, -, new size of the container ; value, -, the value to initialize the new elements with ; Type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also found this slightly confusing. In particular I took this line from the documentation for
resize
(ref)to mean that I should expect the pan and zoom to be modified to fit the graph inside the new dimensions when I called this function. This probably stems from my being newish to javascript and not fully understanding the distinction of viewport and pan and zoom you helpfully described.
@maxkfranz would you be open to adding something like the following to the documentation: This function will only change the viewport extent, it will not modify the pan and zoom to fit the graph inside the new dimensions. To accomplish that you will need to call
cy.fit()
after this function.It had nothing to do with styling.
cy.resize()
needs to be followed by a call tocy.fit()