简体   繁体   English

删除浮动图表上的刻度线

[英]Remove the tick bar on flot charts

Is it possible to remove the tick bars on the x and y axis on a flot chart? 是否可以删除浮动图表上x和y轴上的刻度线?

picture of what I currently have 我目前所拥有的图片

I want to remove the gray bar between the two series labels 我想删除两个系列标签之间的灰色条

Have you tried to configure your axes like: 您是否尝试过配置轴,例如:

xaxis: {
  tickLength: 0
}

yaxis: {
  tickLength: 0
}

Reference here . 参考这里

Update in response to your last comment 更新以回应您的最后评论

Since there is no such option one possible workaround could be to color the tickbar the same as your chart background and the ticks like you have it right now. 由于没有此类选项,因此一种可能的解决方法是将刻度栏的颜色设置为与图表背景相同的颜色,以及将刻度线设置为与现在一样的颜色。

xaxis: {   
  color: /* same as your background color */
  tickColor: /* different color, like the grayish one you have for the ticks */
}

yaxis: {   
  color: /* same as your background color */
  tickColor: /* different color, like the grayish one you have for the ticks */
}

Hope it helps 希望能帮助到你

I ended up changing the flot source code to allow this to occur. 我最终更改了flot源代码以允许发生这种情况。

Here's what I did. 这就是我所做的。

1) added 'tickBar' to the x/yaxis options. 1)在x / yaxis选项中添加了“ tickBar”。 (if true, tickBar is shown.. default: true) 2) change the drawGrid function to use this option (如果为true,则显示tickBar。默认值:true)2)更改drawGrid函数以使用此选项

drawGrid()
...

//draw the ticks
axes = allAxes();
bw = options.grid.borderWidth;
xBar = (options.xaxis.tickBar !== undefined)? options.xaxis.tickBar:true; //new
yBar = (options.yaxis.tickBar !== undefined)? options.yaxis.tickBar:true; //new

...

if(!axis.innermost){
ctx.strokeStyle = axis.options.color;
ctx.beginPath();
xoff = yoff = 0;
if(axis.direction == "x"){
    if(xBar) //new
        xoff = plotWidth + 1; // new
} else {
    if(yBar) //new
        yoff = plotHeight + 1; //new
}

When tickBar is set to false, the offset remains 0 so the line is drawn with a 0 value for width/height so it is not seen. 当tickBar设置为false时,偏移量保持为0,因此该线的宽度/高度值被绘制为0,因此看不到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM