flotbar-chart

How to remove grid lines from Flot chart


I am using Flot in my application and it is working fine. I want to remove both vertical lines and horizontal lines from the the background of the chart. I tried this but I am not able to achieve the functionality.

grid: {
    verticalLines:false,
    horizontalLines:false
}

Can anyone help me in this regard?


Solution

  • You can remove the lines, use tickLength: 0

    $.plot("#flot", dataset,
    {
        yaxis: {tickLength:0}, 
        xaxis: {tickLength:0}
    });
    

    Fiddle here.

    Running demo:

    $(function () {
    
    someData = [[1, 3],
                [2, 16],
                [3, 3],
                [4, 3],
                [5, 8],
                [6, 12],
                [7, 3]];
        
    var dataset = [
        {color: "#edc240", data: someData, lines: {show: true}, points: {show: true}}    
    ]; 
        $.plot("#flot", dataset,
        {
            yaxis: {tickLength:0}, 
            xaxis: {tickLength:0}
        });
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
    <div id="flot" style="width:500px;height:300px;margin:20px"></div>