Flot - 柱形图,系列对齐在一起

发布于 2024-09-18 00:43:50 字数 294 浏览 6 评论 0原文

我可以绘制这样的图表 http://developer.yahoo.com/ yui/examples/charts/charts-rotation.html 使用 flot ?

我的意思是,我有两个在 x 轴上具有相同值的系列,我想将它们显示为对齐在一起,如上面的示例所示,Flot 将它们绘制在另一个之上。

有什么想法吗?

Can I plot charts like this http://developer.yahoo.com/yui/examples/charts/charts-rotation.html using flot ?

I mean, I have two series with the same values on the x axis, I want to show them aligned together like in the example above, Flot plots them one above the another.

Any ideas ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏闹i 2024-09-25 00:43:50

好吧,这有点晚了,但你可以这样做...Flot 不支持开箱即用,但有一个非常好的补丁和插件可以让它做你想做的事。

您可以从 Flot Issue #159 获取它们。您需要修补您的flot(根据您使用的版本,该问题中有一些副本)。由于使用了较新的版本,我的补丁被拒绝了一两次...然后在 flot 之后将 multi 插件添加到您的 javascript 源中。最后,在实际的 plot 调用选项中使用 multiplebars:true

一旦您准备好正确的脚本,它就会是什么样子:

$.plot($("#placeholder"), [ d1, d2, d3 ], {
  series: {
    bars: { show: true, barWidth: 0.3, align:'center' }
  },
  multiplebars:true
});

您可以在这里看到它的实际效果:http://jsfiddle.net/ryleyb/B3uGP/2/

编辑:请注意,自从我做出这个答案以来,flot 已转移到 github。在那里,有人提出了一个拉取请求,其中包含可以更好应用的多插件到代码的当前版本。

Well this is a bit late, but here's how you do it... Flot does not support this out of the box, but there's a perfectly good patch and plugin that will get it doing what you want.

You get them from Flot Issue #159. You'll need to patch your flot (depending on what revision you're using, there's a few copies in the issue). I had a reject or two from the patch due to using a newer revision... Then add the multi plugin to your javascript sources after flot. Finally, use multiplebars:true in your actual plot call's options.

Here's the general idea of what it will look like once you have the right scripts ready to go:

$.plot($("#placeholder"), [ d1, d2, d3 ], {
  series: {
    bars: { show: true, barWidth: 0.3, align:'center' }
  },
  multiplebars:true
});

You can see it in action here: http://jsfiddle.net/ryleyb/B3uGP/2/

EDIT: Note that since I made this answer, flot has moved over to github. Over there, someone has made a pull request that includes the multi plugin which will apply better to current versions of the code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文