Graph resizing error, invalid height

I am trying to add a graph to my page, and I am having problems adding resize to the graph. In order for the resize plugin to work with width and height, the div div must be set to 100%. But when I do this and want to load the graph in a new window, I try to call the plot method on doc ready, but the og my div height is 0 althoug containg div har height = 600px (so should the div separator have the same thing?).

 <div id ="ResizableContainer" class="ui-widget-content" style="width:900px;height:600px;">
    <div id="placeholderForGraph" class="graph-placeholder" ></div>
</div>

my.css:

.graph-placeholder {
    width: 100%;
    height: 100%;
    font-size: 14px;
    line-height: 1.2em;
    padding: 0; 
    position: relative;
}

my.js

$("#placeholderForGraph").text('');
$("#ResizableContainer").show();
$("#placeholderForGraph").plot([data], options);<- error

Error: invalid dimensions for the graph, width = 900, height = 0

If you set the value before calling the graph, the graph will not change in height. How can I add height to a div without destroying the ability to resize?

Thanks in advance!

+4
2

, . ,

 $("#ResizableContainer").show();
    if ($("#placeholderForGraph").height() === 0) {
        $("#placeholderForGraph").css('min-height', $("#ResizableContainer").height()); 
    }
    plot = $.plot($("#placeholderForGraph"), []); 

, :

 $("#placeholderForGraph").css('min-height', "100px");
 $("#placeholderForGraph").css('height', "100%");
 $("#placeholderForGraph").css('width', "100%"); 

@Raidri :)

+1

min-height .graph-placeholder , 100px.

(. ).

+4

Source: https://habr.com/ru/post/1529196/


All Articles