17

Flot API 文档描述了该库用于自定义图形轴的大量钩子。您可以为每个轴分别设置刻度数、颜色等。但是,我不知道如何防止 Flot 在不删除 x 轴标签的情况下绘制垂直网格线。我尝试更改 tickColor、ticks 和 tickSize 选项,但没有成功。

我想创建漂亮的、与 Tufte 兼容的图表,例如:

http://www.robgoodlatte.com/wp-content/uploads/2007/05/tufte_mint.gif http://www.argmax.com/mt_blog/archive/RealGDP_graph.jpg

我发现我的图表上的垂直刻度是图表垃圾。我正在处理一个显示为垂直条的时间序列,因此垂直刻度通常以一种视觉上嘈杂的方式穿过这些条。

4

5 回答 5

58

As Laurimann noted, Flot continues to evolve. The ability to control this has been added to the API (as noted in the flot issue Nelson linked to).

If you download the latest version (which is still labeled 0.6), you can disable lines on an axis with "tickLength", like so:

xaxis: {
  tickLength: 0
}

Rather annoyingly, this addition hasn't been updated in the API documentation.

于 2011-01-14T20:11:10.370 回答
8

This post comes over two years later than OP and Flot (now version 0.6) might have evolved a lot during that time or maybe there's better options than it around but in either case here's my contribution.

I accidentally bumped into a workaround for this problem: set grid's tick color's alpha channel to fully transparent. For example:

var options =   {
      grid:   {show: true,
               color: "rgb(48, 48, 48)",
               tickColor: "rgba(255, 255, 255, 0)",
               backgroundColor: "rgb(255, 255, 255)"}
    };

Works for me.

于 2010-12-31T11:08:46.820 回答
6

经过一番挖掘,我很确定通过 Flot API 是不可能的。不过,如果你真的很脏,你可以这样做——我已经发布了一个例子的修改版本查看源代码显示了整个丑陋。

于 2008-10-06T11:57:35.507 回答
6

To Avoid ticks in the options just give ticks:[] in the corresponding axis

于 2014-02-19T06:14:18.797 回答
2

从 2009 年 6 月开始,flot 问题 167是对这个确切功能的请求。包括两个实现和一些来自 flot 作者的一致意见,认为这是一个好主意。

于 2009-08-18T18:47:26.420 回答