admin管理员组文章数量:1325236
Just as the title states, I'm looking to display a blank "template" graph (by which, I mean that the webpage will display a graph without any lines on it) for a finance calculator that I'm building for work. The basic setup of the webpage will have a blank graph at the top with an HTML form below to accept data entry. Once the user inputs the data and clicks submit, the graph should populate with that data.
Two questions arise from this. First, is it even possible? Second, if it is possible, what would I pass into the $.plot() function? Here is what I'm working with so far:
<div id="main-content">
<div id="chart" style="width:600px;height:300px;"></div>
<script type="text/javascript">
$(document).ready(function() {
$.plot($("#chart"), [[null]]);
});
</script>
</div>
Any advice would be greatly appreciated! Thank you!
EDIT: I forgot to mention this. When I go to view this webpage, Firebug gives me this error message:
uncaught exception: Invalid dimensions for plot, width = 928, height = 0
EDIT FOR ANSWER: It seems that the error message was ing from me using the width and height attributes of the div, instead of styling them with width and height. After fixing that, it works! All code displayed here now works properly.
Just as the title states, I'm looking to display a blank "template" graph (by which, I mean that the webpage will display a graph without any lines on it) for a finance calculator that I'm building for work. The basic setup of the webpage will have a blank graph at the top with an HTML form below to accept data entry. Once the user inputs the data and clicks submit, the graph should populate with that data.
Two questions arise from this. First, is it even possible? Second, if it is possible, what would I pass into the $.plot() function? Here is what I'm working with so far:
<div id="main-content">
<div id="chart" style="width:600px;height:300px;"></div>
<script type="text/javascript">
$(document).ready(function() {
$.plot($("#chart"), [[null]]);
});
</script>
</div>
Any advice would be greatly appreciated! Thank you!
EDIT: I forgot to mention this. When I go to view this webpage, Firebug gives me this error message:
uncaught exception: Invalid dimensions for plot, width = 928, height = 0
EDIT FOR ANSWER: It seems that the error message was ing from me using the width and height attributes of the div, instead of styling them with width and height. After fixing that, it works! All code displayed here now works properly.
Share Improve this question edited Jan 3, 2012 at 17:50 Z. Charles Dziura asked Jan 3, 2012 at 17:16 Z. Charles DziuraZ. Charles Dziura 9334 gold badges18 silver badges41 bronze badges1 Answer
Reset to default 8Just ditch the null. If you want an empty "box" pass no data arrays:
$(document).ready(function() {
$.plot($("#chart"), []);
});
If you want a "plot" with no data, pass an empty data array:
$(document).ready(function() {
$.plot($("#chart"), [[]]);
});
Running code:
<!DOCTYPE html>
<html>
<head>
<script data-require="[email protected]" data-semver="3.0.0" src="https://cdnjs.cloudflare./ajax/libs/jquery/3.0.0/jquery.js"></script>
<script data-require="[email protected]" data-semver="0.8.2" src="//cdnjs.cloudflare./ajax/libs/flot/0.8.2/jquery.flot.min.js"></script>
</head>
<body>
<div id="chart" style="width:200px; height:200px"></div>
<script>
$(document).ready(function() {
$.plot($("#chart"), [
[]
]);
});
</script>
</body>
</html>
本文标签: javascriptHow to Display a Blank Graph with FlotStack Overflow
版权声明:本文标题:javascript - How to Display a Blank Graph with Flot - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742166764a2425968.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论