# Path: aqmt/plot/common.py
# def add_plot(gpi):
#     """
#     Remove trailing comma from plot command because gnuplot complains about it
#     (We use the trailing comma to easier build plot commands)
#     """
#     return re.sub(r',(\s*\\?\s*\\?\s*)$', '\g<1>', gpi)
# 
# def add_scale(y_logarithmic, range_from=None, range_from_log=None,
#         range_to=None, range_to_log=None):
#     if y_logarithmic:
#         if range_from_log is None:
#             range_from_log = '1'
#         if range_to_log is None:
#             range_to_log = '*'
#         return """
#             set logscale y
#             set yrange [""" + range_from_log + """:""" + range_to_log + """]
#             """
#     else:
#         if range_from is None:
#             range_from = '0'
#         if range_to is None:
#             range_to = '1<*'
#         return """
#             set yrange [""" + range_from + """:""" + range_to + """]
#             """


from collections import OrderedDict
from .common import add_plot, add_scale


def utilization_queues(y_logarithmic=False, total=True, ecn=True, flows=True):
    """
    Plot utilization per queue
    """

    def plot(testfolder, plotdef):
        label_y_pos = -0.06 * (1/plotdef.y_scale)
        gpi = """
            set format y "%g"
            set ylabel 'Utilization [%]'

            set style line 100 lt 1 lc rgb 'black' lw 1.5 dt 3
            set arrow 100 from graph 0, first 100 to graph 1, first 100 nohead ls 100 back


# Path: aqmt/plot/common.py
# def add_plot(gpi):
#     """
#     Remove trailing comma from plot command because gnuplot complains about it
#     (We use the trailing comma to easier build plot commands)
#     """
#     return re.sub(r',(\s*\\?\s*\\?\s*)$', '\g<1>', gpi)
# 
# def add_scale(y_logarithmic, range_from=None, range_from_log=None,
#         range_to=None, range_to_log=None):
#     if y_logarithmic:
#         if range_from_log is None:
#             range_from_log = '1'
#         if range_to_log is None:
#             range_to_log = '*'
#         return """
#             set logscale y
#             set yrange [""" + range_from_log + """:""" + range_to_log + """]
#             """
#     else:
#         if range_from is None:
#             range_from = '0'
#         if range_to is None:
#             range_to = '1<*'
#         return """
#             set yrange [""" + range_from + """:""" + range_to + """]
#             """


# Path: aqmt/plot/flow_components.py
from collections import OrderedDict
from .common import add_plot, add_scale



def utilization_queues(y_logarithmic=False, total=True, ecn=True, flows=True):
    """
    Plot utilization per queue
    """

    def plot(testfolder, plotdef):
        label_y_pos = -0.06 * (1/plotdef.y_scale)
        gpi = """
            set format y "%g"
            set ylabel 'Utilization [%]'

            set style line 100 lt 1 lc rgb 'black' lw 1.5 dt 3
            set arrow 100 from graph 0, first 100 to graph 1, first 100 nohead ls 100 back


            set label "Sample #:" at graph -0.01, graph """ + str(label_y_pos) + """ font 'Times-Roman,11pt' tc rgb 'black' right