summaryrefslogtreecommitdiff
path: root/examples/redis-unstable/src/sparkline.h
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2026-01-21 22:40:55 +0100
commit5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda (patch)
tree1acdfa5220cd13b7be43a2a01368e80d306473ca /examples/redis-unstable/src/sparkline.h
parentc7ab12bba64d9c20ccd79b132dac475f7bc3923e (diff)
downloadcrep-5d8dfe892a2ea89f706ee140c3bdcfd89fe03fda.tar.gz
Add Redis source code for testing
Diffstat (limited to 'examples/redis-unstable/src/sparkline.h')
-rw-r--r--examples/redis-unstable/src/sparkline.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/redis-unstable/src/sparkline.h b/examples/redis-unstable/src/sparkline.h
new file mode 100644
index 0000000..7769fdb
--- /dev/null
+++ b/examples/redis-unstable/src/sparkline.h
@@ -0,0 +1,39 @@
+/* sparkline.h -- ASCII Sparklines header file
+ *
+ * ---------------------------------------------------------------------------
+ *
+ * Copyright (c) 2011-Present, Redis Ltd.
+ * All rights reserved.
+ *
+ * Licensed under your choice of (a) the Redis Source Available License 2.0
+ * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the
+ * GNU Affero General Public License v3 (AGPLv3).
+ */
+
+#ifndef __SPARKLINE_H
+#define __SPARKLINE_H
+
+/* A sequence is represented of many "samples" */
+struct sample {
+ double value;
+ char *label;
+};
+
+struct sequence {
+ int length;
+ int labels;
+ struct sample *samples;
+ double min, max;
+};
+
+#define SPARKLINE_NO_FLAGS 0
+#define SPARKLINE_FILL 1 /* Fill the area under the curve. */
+#define SPARKLINE_LOG_SCALE 2 /* Use logarithmic scale. */
+
+struct sequence *createSparklineSequence(void);
+void sparklineSequenceAddSample(struct sequence *seq, double value, char *label);
+void freeSparklineSequence(struct sequence *seq);
+sds sparklineRenderRange(sds output, struct sequence *seq, int rows, int offset, int len, int flags);
+sds sparklineRender(sds output, struct sequence *seq, int columns, int rows, int flags);
+
+#endif /* __SPARKLINE_H */