简体   繁体   中英

php rrd_graphs comments position change almost every time

I have a problem with rrd graps - they look different every time.

For example: these are 2 graphs generated one by one using the same function.

第一

第二名

My rrd_graph options looks like this:

"--slope-mode",
        "--start", $start,

        "--font=DEFAULT:9:Cantarell",
        "--font=TITLE:12:Roboto Condensed",
        "--font=AXIS:8:Roboto Condensed",
        "--font=LEGEND:9:Cantarell",
        "--font=WATERMARK:6:Cantarell",

        "--title=$title",
        "-W General",
        "--vertical-label=Tx[dBm] / Rx[dBm] / SNR[dB]",
        "--lower=0",
        "-w 550",
        "-h 300",
        "-P",
        "--border=0",
        "--color=BACK#ffffff",
        "DEF:Tx=$RRD_CM_PATH$cm_mac_mod.rrd:US_Tx:AVERAGE",
        "DEF:SNR=$RRD_CM_PATH$cm_mac_mod.rrd:US_SNR:AVERAGE",
        "DEF:Rx=$RRD_CM_PATH$cm_mac_mod.rrd:US_Rx:AVERAGE",
        "COMMENT:\\n",
        "COMMENT:\\t\\t\\t\\t\\t\\t\\t\\t    Current\\t\\t  Average\\t\\tMinimum\\t      Maximum",
        "COMMENT:\\n",
        "COMMENT:\\t\\t\\t",
        "LINE3:Tx#055499:US Tx\\t\\t\\t",
        "GPRINT:Tx:LAST:%2.1lfdBm \\t",
        "GPRINT:Tx:AVERAGE:%2.1lfdBm \\t",
        "GPRINT:Tx:MAX:%2.1lfdBm \\t",
        "GPRINT:Tx:MIN:%2.1lfdBm \\t",
        "COMMENT:\\n",
        "COMMENT:\\t\\t\\t",
        "LINE3:SNR#ff5a00:US SNR\\t\\t",
        "GPRINT:SNR:LAST:%2.1lfdBm\\t",
        "GPRINT:SNR:AVERAGE:%2.1lfdBm\\t",
        "GPRINT:SNR:MAX:%2.1lfdBm\\t",
        "GPRINT:SNR:MIN:%2.1lfdBm\\t",
        "COMMENT:\\n",
        "COMMENT:\\t\\t\\t",
        "LINE3:Rx#4be117:US_Rx\\t",
        "GPRINT:Rx:LAST:%2.1lfdBm\\t",
        "GPRINT:Rx:AVERAGE:%2.1lfdBm\\t",
        "GPRINT:Rx:MAX:%2.1lfdBm\\t",
        "GPRINT:Rx:MIN:%2.1lfdBm\\t",
        "COMMENT:\\n",

I forgot to share the solution... I fixed a problem using 2 things:

  1. Monospaced font.
  2. sprintf with fixed width strings:

      sprintf('COMMENT:%25s%13s%13s%14s%13s', "", "Current", " Average", "Maximum", "Minimum"), "COMMENT:\\\\n", "COMMENT: \\\\n", "COMMENT:\\\\t", sprintf("LINE3:Rx#055499:%-9s%-10s", "DS Rx", "[dBm]"), sprintf("GPRINT:Rx:LAST:%-13s", "%4.1lf"), sprintf("GPRINT:Rx:AVERAGE:%-13s", "%4.1lf"), sprintf("GPRINT:Rx:MAX:%-13s", "%4.1lf"), sprintf("GPRINT:Rx:MIN:%-13s", "%4.1lf"), "COMMENT:\\\\n", "COMMENT:\\\\t", sprintf("LINE3:SNR#ff5a00:%-9s%-10s", "DS SNR", "[dB]"), sprintf("GPRINT:SNR:LAST:%-13s", "%4.1lf"), sprintf("GPRINT:SNR:AVERAGE:%-13s", "%4.1lf"), sprintf("GPRINT:SNR:MAX:%-13s", "%4.1lf"), sprintf("GPRINT:SNR:MIN:%-13s", "%4.1lf"), "COMMENT:\\\\n", "COMMENT:\\\\t", sprintf("LINE3:MR#4be117:%-9s%-10s", "MicroRef", "[-dBc]"), sprintf("GPRINT:MR:LAST:%-13s", "%4.1lf"), sprintf("GPRINT:MR:AVERAGE:%-13s", "%4.1lf"), sprintf("GPRINT:MR:MAX:%-13s", "%4.1lf"), sprintf("GPRINT:MR:MIN:%-13s", "%4.1lf"), "COMMENT:\\\\n", 

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