php rrd_graphs评论几乎每次都会改变位置

时间:2016-09-02 12:12:15

标签: php graph rrd

我的rrd graps有问题 - 每次都看起来不一样。

例如:这些是使用相同函数逐个生成的2个图。

1st

2nd

我的rrd_graph选项如下所示:

"--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",

1 个答案:

答案 0 :(得分:0)

我忘了分享解决方案...... 我使用两件事来解决问题:

  1. Monospaced font。
  2. 带有固定宽度字符串的sprintf:

            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",