#include "string.h"
#include "time.h"
+// Include graph macros
+#include "graphs/graph.h"
+
// Maximum length of the title/vlabel
#define TITLE_MAX 128
#define VLABEL_MAX 64
ERROR(ctx, "Failed to reset the locale to '%s': %m\n", locale);
}
+static int td_graph_empty(td_graph* self, td_args* args) {
+ int r;
+
+ // Draw a line so that something will get rendered
+ r = td_args_push(args, "HRULE:0" COLOR_AXIS);
+ if (r < 0)
+ return r;
+
+ // Add an empty line
+ PRINT_EMPTY_LINE(args);
+
+ // Add a message that explains that no data is available
+ r = td_args_push(args, "COMMENT:%s\\c", _("No Data Available"));
+ if (r < 0)
+ return r;
+
+ // Add another empty line
+ PRINT_EMPTY_LINE(args);
+
+ return 0;
+}
+
int td_graph_render(td_graph* self, const char* object,
const td_graph_render_options* options, char** buffer, size_t* length) {
td_args* args = NULL;
if (r < 0)
goto ERROR;
+ // We cannot render the graph if there are no sources
+ if (!td_args_has_sources(args)) {
+ DEBUG(self->ctx, "Graph has no sources\n");
+
+ // Show nothing
+ r = td_graph_empty(self, args);
+ if (r < 0)
+ goto ERROR;
+ }
+
// Dump the command
r = td_args_dump(args);
if (r < 0)