如何用flot渲染此条形图 [英] How to render this bar chart with flot

查看:80
本文介绍了如何用flot渲染此条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以使用flot绘制这样的条形图吗?

Can you render a bar chart like this using flot?

我是否需要手动创建数据集才能获得此结果,而不是使用时间"模式?

Do I need to create the dataset manually to get this result, instead of using mode: 'time' ?

推荐答案

实际上非常容易使用flot.

var options = {
     series: {
         bars: {
             show: true,
             barWidth: 15778463000, // 1/2 year in milliseconds
             align: 'center'
         },
     },
     yaxes: {
         min: 0
     },
     xaxis: {
         mode: 'time',
         timeformat: "%y",
         tickSize: [1, "year"],
         autoscaleMargin: .10 // allow space left and right
     }
 };

 $(function() {
     $.plot($('#placeholder'), [[[1230768000*1000, 100], //[seconds * 1000 = milli, y value]
                                [1262304000*1000, 200],
                                [1293840000*1000, 300]]], options);
 });

产生:

这篇关于如何用flot渲染此条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆