流量图为空?
我正在运行下面的代码并使用 Flot/jQuery 获取一个空图表。 理想情况下,我想要的是数据的条形图。 我看着这个,心里没有任何喜悦——有人有什么想法吗?
<div id="user_breakdown_placeholder" style="width:300px;height:300px"></div>
<script>
$(function () {
var d = [["Unassigned", 310],["Maynard Schumm", 274]];
var options = {};
$.plot($("#user_breakdown_placeholder"), d, options);
});
</script>
I'm running the code below and getting an empty chart using Flot/jQuery. Ideally what I am after is a bar chart of the data. I'm looked and looked at this with no joy - does anyone have any ideas?
<div id="user_breakdown_placeholder" style="width:300px;height:300px"></div>
<script>
$(function () {
var d = [["Unassigned", 310],["Maynard Schumm", 274]];
var options = {};
$.plot($("#user_breakdown_placeholder"), d, options);
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当前版本的 flot (v. 0.6) 支持条形图。 这是一个示例。 在你的plot()函数中,你只需输入:
The current version of flot (v. 0.6) supports bar charts. Here is an example. In your plot() function, you just have to put:
这是一个老问题,但我认为没有得到解答。 根据 Flot API 文档:
如果在上述情况下,您在数据中使用字符串(例如[“未分配”,310]),那么根据文档,这将不起作用。
An old question but I don't think it was answered. According to the Flot API documentation:
If the above case you are using strings in your data (e.g. ["Unassigned", 310]) which isn't going to work according to the docs.
你可以做到这一点,但你只需要稍微伪造一下你的数据。
------>
大概您可以在将数据传递给 Flot 之前对其进行适当修改。
FlotUsage 上有很多实际使用的精彩示例。 例如 Fedora 有一些不错的条形图。 最棒的是,因为它是 JavaScript,所以你可以查看任何人的源代码和创意:)
You can do this but you just need to fake up your data a little bit.
------>
Presumably you can modify your data appropriately before passing it to Flot.
There are lots of great examples of real uses at FlotUsage. e.g. Fedora have some nice bar charts. The great thing is because it's JavaScript you can view source and crib ideas from anyone :)
正如 Neil Middleton 在评论中所说,Flot 不支持条形图。
也许这个或这个插件可以帮助你吗?
As Neil Middleton says in his comment, Flot does not support Bar Charts.
Perhaps this or this plugin can help you?