]> git.ipfire.org Git - collecty.git/commitdiff
graph: Add macros to draw some elements
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Oct 2025 10:21:51 +0000 (10:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Oct 2025 10:21:51 +0000 (10:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.h

index 90e2be2f6d14c994ff0c1532c8d65abdbad0488d..16d6c162b3720de34dad057e05e6ee040910c784 100644 (file)
@@ -65,4 +65,26 @@ typedef struct collecty_graph_render_options {
 int collecty_graph_render(collecty_graph* self, const char* object,
        const collecty_graph_render_options* options, char** buffer, size_t* length);
 
+/*
+       Helpers to write things faster...
+*/
+
+#define HEADER                 "COMMENT:" COLUMN
+#define EMPTY_COLUMN   "COMMENT:                                "
+#define EMPTY_LINE             "COMMENT: \\n"
+
+#define LABEL                  "%-30s"
+
+// A column is exactly 16 characters wide
+#define COLUMN                 "%16s"
+#define FLOAT                  "%%14.2lf"
+#define EOL                            "\\j"
+
+// Draw a LINE, AREA, etc.
+#define DRAW(what, field, color) what ":" field color
+#define DRAW_WITH_LABEL(what, field, color) DRAW(what, field, color) ":" LABEL
+
+// Add something to the legend of the graph
+#define PRINT_FLOAT(field) "GPRINT:" field ":" FLOAT
+
 #endif /* COLLECTY_GRAPH_H */