简体   繁体   中英

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?

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.

Here's what I did.

1) added 'tickBar' to the x/yaxis options. (if true, tickBar is shown.. default: true) 2) change the drawGrid function to use this option

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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