]> git.ipfire.org Git - collecty.git/commitdiff
graph: Import the default arguments from the Python implementation
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 10:11:02 +0000 (10:11 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 2 Oct 2025 10:11:02 +0000 (10:11 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/graph.c

index d79893798bf776a5ced7a5d9e8e8fff08b23ec83..e7b494d9dd69910567215e6f4ce3ce47debbb606 100644 (file)
@@ -24,6 +24,7 @@
 #include <rrd.h>
 
 #include "args.h"
+#include "colors.h"
 #include "ctx.h"
 #include "daemon.h"
 #include "graph.h"
@@ -39,6 +40,29 @@ struct collecty_graph {
        const collecty_graph_impl* impl;
 };
 
+const char* DEFAULT_RENDER_ARGS[] = {
+       // Change the background color
+       "--color=BACK" COLOR_BLACK,
+
+       // Disable the border around the image
+       "--border=0",
+
+       // Let's width and heigh define the size of the entire image
+       "--full-size-mode",
+
+       // Give the curves a more organic look
+       "--slope-mode",
+
+       // Show nicer labels
+       "--dynamic-labels",
+
+       // Add a watermark
+       "--watermark=PACKAGE_NAME",
+
+       // Sentinel
+       NULL,
+};
+
 static void collecty_graph_free(collecty_graph* self) {
        if (self->daemon)
                collecty_daemon_unref(self->daemon);
@@ -174,6 +198,11 @@ int collecty_graph_render(collecty_graph* self,
        if (r < 0)
                goto ERROR;
 
+       // Push the default arguments
+       r = collecty_args_pushv(args, DEFAULT_RENDER_ARGS);
+       if (r < 0)
+               goto ERROR;
+
        // Call the implementation to add some arguments
        r = self->impl->render(self->ctx, self, args, object);
        if (r < 0)