Beispiel #1
0
def _time_range_historic_dict_elements(with_elements) -> DictionaryElements:
    yield 'window', Timerange(
        title=_("Time range to consider"),
        default_value="d0",
        allow_empty=True,
    )
    yield "rrd_consolidation", DropdownChoice(
        choices=[
            ("average", _("Average")),
            ("min", _("Minimum")),
            ("max", _("Maximum")),
        ],
        default_value="max",
        title="RRD consolidation",
        help=_(
            "Consolidation function for the [cms_graphing#rrds|RRD] data column"
        ),
    )

    if "with_graph_styling" in with_elements:
        yield "style", DropdownChoice(
            choices=[
                ("line", _("Line")),
                ("area", _("Area")),
            ],
            default_value="area",
            title=_("Style"),
        )
        yield "color", GraphColor(
            title=_("Color"),
            default_value="default",
        )
 def _vs_elements() -> DictionaryElements:
     return [
         ("metric", MetricName()),
         ("time_range",
          Timerange(
              title=_("Time range"),
              default_value='d0',
          )),
         ("metric_color",
          GraphColor(title=_("Color for the main metric scattered dots"),
                     default_value="default")),
         ("avg_color",
          GraphColor(title=_("Color for the average line"),
                     default_value="default")),
         ("median_color",
          GraphColor(title=_("Color for the median line"),
                     default_value="default")),
     ]
 def vs_parameters(cls):
     return Dictionary(
         title=_("Properties"),
         render="form",
         optional_keys=[],
         elements=[
             ("metric", MetricName()),
             ("time_range",
              Timerange(
                  title=_("Time range"),
                  default_value='d0',
              )),
             ("metric_color",
              GraphColor(
                  title=_("Color for the main metric scattered dots"),
                  default_value="default")),
             ("avg_color",
              GraphColor(title=_("Color for the average line"),
                         default_value="default")),
             ("median_color",
              GraphColor(title=_("Color for the median line"),
                         default_value="default")),
         ])
Beispiel #4
0
    def _vs_elements(cls):
        vs_el = super()._vs_elements()
        vs_el.extend([
            ("fill",
             DropdownChoice(
                 choices=[
                     (False, _("Don't fill area plot")),
                     (True, _("Fill area plot")),
                 ],
                 default_value=True,
                 title=_("Fill area plot when displaying historic values"))),
            ("color",
             GraphColor(title=_("Color metric plot"), default_value="default"))
        ])

        return vs_el
Beispiel #5
0
def vs_graph_render_option_elements(default_values=None, exclude=None):
    # Allow custom default values to be specified by the caller. This is, for example,
    # needed by the dashlets which should add the host/service by default.
    if default_values is None:
        default_values = artwork.get_default_graph_render_options()
    else:
        default_values = default_values.copy()
        for k, v in artwork.get_default_graph_render_options().items():
            default_values.setdefault(k, v)

    elements = [
        ("font_size", Fontsize(default_value=default_values["font_size"], )),
        ("show_title",
         DropdownChoice(
             title=_("Title"),
             choices=[
                 (False, _("Don't show graph title")),
                 (True, _("Show graph title")),
                 ("inline", _("Show graph title on graph area")),
             ],
             default_value=default_values["show_title"],
         )),
        ("title_format",
         Transform(
             vs_title_infos(),
             forth=transform_graph_render_options_title_format,
         )),
        ("show_graph_time",
         Checkbox(
             title=_("Show graph time range"),
             label=_("Show the graph time range on top of the graph"),
             default_value=default_values["show_graph_time"],
         )),
        ("show_margin",
         Checkbox(
             title=_("Show margin round the graph"),
             label=_("Show a margin round the graph"),
             default_value=default_values["show_margin"],
         )),
        ("show_legend",
         Checkbox(
             title=_("Show legend"),
             label=_("Show the graph legend"),
             default_value=default_values["show_legend"],
         )),
        ("show_vertical_axis",
         Checkbox(
             title=_("Show vertical axis"),
             label=_("Show the graph vertical axis"),
             default_value=default_values["show_vertical_axis"],
         )),
        ("vertical_axis_width",
         CascadingDropdown(
             title=_("Vertical axis width"),
             orientation="horizontal",
             choices=[
                 ("fixed", _("Use fixed width (relative to font size)")),
                 ("explicit", _("Use absolute width:"),
                  Float(title="", default_value=40.0, unit=_("pt"))),
             ],
         )),
        ("show_time_axis",
         Checkbox(
             title=_("Show time axis"),
             label=_("Show the graph time axis"),
             default_value=default_values["show_time_axis"],
         )),
        ("show_controls",
         Checkbox(
             title=_("Show controls"),
             label=_("Show the graph controls"),
             default_value=default_values["show_controls"],
         )),
        ("show_pin",
         Checkbox(
             title=_("Show pin"),
             label=_("Show the pin"),
             default_value=default_values["show_pin"],
         )),
        ("show_time_range_previews",
         Checkbox(
             title=_("Show time range previews"),
             label="Show previews",
             default_value=default_values["show_time_range_previews"],
         )),
        ("foreground_color",
         GraphColor(
             title=_("Foreground color"),
             default_value=default_values["foreground_color"],
         )),
        ("background_color",
         GraphColor(
             title=_("Background color"),
             default_value=default_values["background_color"],
         )),
        ("canvas_color",
         GraphColor(
             title=_("Canvas color"),
             default_value=default_values["canvas_color"],
         )),
    ]

    if exclude:
        elements = [x for x in elements if x[0] not in exclude]

    return elements