1/* sparkline.h -- ASCII Sparklines header file
2 *
3 * ---------------------------------------------------------------------------
4 *
5 * Copyright(C) 2011-2014 Salvatore Sanfilippo <[email protected]>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * * Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef __SPARKLINE_H
31#define __SPARKLINE_H
32
33/* A sequence is represented of many "samples" */
34struct sample {
35 double value;
36 char *label;
37};
38
39struct sequence {
40 int length;
41 int labels;
42 struct sample *samples;
43 double min, max;
44};
45
46#define SPARKLINE_NO_FLAGS 0
47#define SPARKLINE_FILL 1 /* Fill the area under the curve. */
48#define SPARKLINE_LOG_SCALE 2 /* Use logarithmic scale. */
49
50struct sequence *createSparklineSequence(void);
51void sparklineSequenceAddSample(struct sequence *seq, double value, char *label);
52void freeSparklineSequence(struct sequence *seq);
53sds sparklineRenderRange(sds output, struct sequence *seq, int rows, int offset, int len, int flags);
54sds sparklineRender(sds output, struct sequence *seq, int columns, int rows, int flags);
55
56#endif /* __SPARKLINE_H */
57