display x-axis and y-axis lines with out the grid lines using flot

前端 未结 5 1673
你的背包
你的背包 2020-12-01 16:58

I am using flot to display bar charts. When I set the tickLength to 0, it hides the vertical and horizontal lines but it also hides the x-axis and y-axis lines. I need the x

5条回答
  •  一生所求
    2020-12-01 17:44

    Mark answer works but it's a little too hardcoded for his data. This one is a little better:

    $(function() {
        var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
        $.plot($("#placeholder"),
          [{data: d2,
            bars: {
                show: true
            }}
          ],
          {
            xaxis: {
                tickLength: 0
            },
             yaxis: {
                tickLength: 0
            },
            grid: {
               borderWidth: 0,
               aboveData: true,
               markings: [ { yaxis: { from: 0, to: 0 }, color: "#000" },
                           { xaxis: { from: 0, to: 0 }, color: "#000" }]
            }
          }
        );
    });
    

    Still if your chart starts at a value different than 0 you have to manually change the markings.

提交回复
热议问题