浮雕条形图月份对齐问题 [英] Flot bar chart month alignment issue

查看:67
本文介绍了浮雕条形图月份对齐问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Flot库绘制每月条形图. x轴与月份中心的对齐完全错误.我创建了 jsfiddle 来显示问题.

I'm trying to draw a monthly bar chart using Flot library. The alignment with the month center is completely wrong with the x axis. I've created a jsfiddle to show the problem.

直观地给出

bars: {
    show: true,
    fillColor: '#4682b4',
    barWidth: 15 * 24 * 60 * 60 * 1000,
    align: 'center'
},

我想该条应该与中心的刻度线对齐,但不是!我期望的结果如下:

I suppose the bar should align with the tick on the center, but is not! The result I'm expecting is the following:

非常感谢!

推荐答案

在时间格式中包括%d而不是仅显示月份,您将看到发生了什么. Flot通过从最小轴上减去钢筋宽度的一半来为居中的钢筋腾出空间.因此,条形图居中,但x轴刻度不是您期望的.

Instead of showing just the month, include %d in the time format and you'll see what's happening. Flot makes room for centered bars by subtracting half the bar's width from the axis min. So the bar is centered, but the x-axis ticks aren't what you expect.

我正在调查我们可以做些什么;同时,您可以设置一个显式的最小值(该值将切断第一个小节或在其左侧添加不希望的空白),或显式提供一个刻度线数组.

I'm investigating what we can do about this; in the meantime you can either set an explicit minimum (which will either cut off the first bar or add undesirable white space to the left of it), or provide an array of ticks explicitly.

您可能还想尝试使用0.7而不是master,因为它可能不会出现此问题.

You may also want to try 0.7 instead of master, since it likely doesn't exhibit this problem.

检查完代码后,我将更新此答案.

I'll update this answer when I've finished examining the code.

这篇关于浮雕条形图月份对齐问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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