Axis label in Flot

后端 未结 9 1244
长情又很酷
长情又很酷 2021-01-31 14:15

Does anyone know how one can set the label or title of an axis in Flot?

I\'ve read the API but it doesn\'t seem to have that feature...

Thanks :)

相关标签:
9条回答
  • 2021-01-31 15:03

    A suggestion I saw that works pretty well is to put the graph in the middle of a 3x3 table. Then the labels can be put in the others cells.

    <table style="text-align:center">
      <tr>
        <td></td>
    
        <td>Plot Title Goes Here</td>
    
        <td> </td>
      </tr>
    
      <tr>
        <td>Y Axis Label</td>
    
        <td>
          <div id="graph here" style="width:600px;height:300px"></div>
        </td>
    
        <td></td>
      </tr>
    
      <tr>
        <td></td>
    
        <td>X Axis Label Goes Here</td>
    
        <td></td>
      </tr>
    
    </table>
    
    0 讨论(0)
  • 2021-01-31 15:05
    $("<div class='axisLabel yaxisLabel'></div>")
            .text("Pressure")
            .appendTo($("#yl_1"));
    

    This will works too.

    0 讨论(0)
  • 2021-01-31 15:08

    Example for 2dims graph (x and y axis) solved with pure css.

    Y axis:

    #placeholder:after {
        content: 'Speed';
        position: absolute;
        top: 50%;
        left: -50px;
        font-weight: 600;
        /* Safari */
        -webkit-transform: rotate(-90deg);
        /* Firefox */
        -moz-transform: rotate(-90deg);
        /* IE */
        -ms-transform: rotate(-90deg);
        /* Opera */
        -o-transform: rotate(-90deg);
        /* Internet Explorer */
        filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    }
    

    X axis:

    #placeholder:before {
        content: 'Time';
        position: absolute;
        bottom: -30px;
        left: 50%;
        font-weight: 600;
    }
    
    0 讨论(0)
提交回复
热议问题