def compute_graph_curves(metrics, rrd_data): curves = [] for metric_definition in metrics: expression = metric_definition["expression"] time_series = evaluate_time_series_expression(expression, rrd_data) if not time_series: continue multi = len(time_series) > 1 mirror_prefix = "-" if metric_definition["line_type"].startswith("-") else "" for i, ts in enumerate(time_series): title = metric_definition["title"] if ts.metadata.get('title') and multi: title += " - " + ts.metadata['title'] color = metric_definition.get("color", ts.metadata.get('color', "#000000")) if i % 2 == 1 and not (expression[0] == "transformation" and expression[1][0] == "forecast"): color = render_color(fade_color(parse_color(color), 0.3)) curves.append({ "line_type": mirror_prefix + ts.metadata.get('line_type', "") if multi else metric_definition["line_type"], "color": color, 'title': title, 'rrddata': ts }) return curves
def compute_graph_curves(metrics: Sequence[GraphMetric], rrd_data: RRDData) -> list[Curve]: curves = [] for metric_definition in metrics: expression = metric_definition["expression"] time_series = evaluate_time_series_expression(expression, rrd_data) if not time_series: continue multi = len(time_series) > 1 mirror_prefix = "-" if metric_definition["line_type"].startswith( "-") else "" for i, ts in enumerate(time_series): title = metric_definition["title"] if ts.metadata.get("title") and multi: title += " - " + ts.metadata["title"] color = metric_definition.get("color", ts.metadata.get("color", "#000000")) if i % 2 == 1 and not (expression[0] == "transformation" and expression[1][0] == "forecast"): color = render_color(fade_color(parse_color(color), 0.3)) curves.append( Curve({ "line_type": mirror_prefix + ts.metadata.get("line_type", "") if multi else metric_definition["line_type"], "color": color, "title": title, "rrddata": ts, })) return curves