@cryptotaxi247 / netdata-1 / commits / fc1544c4d

fixed wrong annotations given to google charts (#4535)

* fixed wrong annotations given to google charts * added default rrdr dimension flag

Costa Tsaousis committed Oct 31, 2018 at 22:45 UTC fc1544c4d76a614b210a2739cfbcfdef576099c2
4 files changed +16 -10
web/api/formatters/json/json.c
+2
@@ -155,6 +155,8 @@ void rrdr2json(RRDR *r, BUFFER *wb, RRDR_OPTIONS options, int datatable) {
155 // google supports one annotation per row
156 int annotation_found = 0;
157 for(c = 0, rd = r->st->dimensions; rd ;c++, rd = rd->next) {
158 + if(unlikely(!(r->od[c] & RRDR_DIMENSION_SELECTED))) continue;
159 +
160 if(co[c] & RRDR_VALUE_RESET) {
161 buffer_strcat(wb, overflow_annotation);
162 annotation_found = 1;
web/api/queries/query.c
+4 -1
@@ -871,8 +871,11 @@ RRDR *rrd2rrdr(
871 for(rd = st->dimensions, c = 0 ; rd && c < dimensions_count ; rd = rd->next, c++) {
872
873 // if we need a percentage, we need to calculate all dimensions
874 - if(unlikely(!(options & RRDR_OPTION_PERCENTAGE) && (r->od[c] & RRDR_DIMENSION_HIDDEN)))
874 + if(unlikely(!(options & RRDR_OPTION_PERCENTAGE) && (r->od[c] & RRDR_DIMENSION_HIDDEN))) {
875 + if(unlikely(r->od[c] & RRDR_DIMENSION_SELECTED)) r->od[c] &= ~RRDR_DIMENSION_SELECTED;
876 continue;
877 + }
878 + r->od[c] |= RRDR_DIMENSION_SELECTED;
879
880 // reset the grouping for the new dimension
881 r->internal.grouping_reset(r);
web/api/queries/rrdr.c
+1 -1
@@ -126,7 +126,7 @@ RRDR *rrdr_create(RRDSET *st, long n)
126 if(unlikely(rrddim_flag_check(rd, RRDDIM_FLAG_HIDDEN)))
127 r->od[c] = RRDR_DIMENSION_HIDDEN;
128 else
129 - r->od[c] = 0;
129 + r->od[c] = RRDR_DIMENSION_DEFAULT;
130 }
131
132 r->group = 1;
web/api/queries/rrdr.h
+9 -8
@@ -25,21 +25,22 @@ typedef enum rrdr_options {
25 } RRDR_OPTIONS;
26
27 typedef enum rrdr_value_flag {
28 - RRDR_VALUE_NOTHING = 0x00, // no flag set
29 - RRDR_VALUE_EMPTY = 0x01, // the value is empty
30 - RRDR_VALUE_RESET = 0x02, // the value has been reset
28 + RRDR_VALUE_NOTHING = 0x00, // no flag set (a good default)
29 + RRDR_VALUE_EMPTY = 0x01, // the database value is empty
30 + RRDR_VALUE_RESET = 0x02, // the database value is marked as reset (overflown)
31 } RRDR_VALUE_FLAGS;
32
33 typedef enum rrdr_dimension_flag {
34 - RRDR_DIMENSION_HIDDEN = 0x04, // the dimension is hidden
35 - RRDR_DIMENSION_NONZERO = 0x08, // the dimension non zero
36 - RRDR_DIMENSION_SELECTED = 0x10, // the dimension is selected
34 + RRDR_DIMENSION_DEFAULT = 0x00,
35 + RRDR_DIMENSION_HIDDEN = 0x04, // the dimension is hidden (not to be presented to callers)
36 + RRDR_DIMENSION_NONZERO = 0x08, // the dimension is non zero (contains non-zero values)
37 + RRDR_DIMENSION_SELECTED = 0x10, // the dimension is selected for evaluation in this RRDR
38 } RRDR_DIMENSION_FLAGS;
39
40 // RRDR result options
41 typedef enum rrdr_result_flags {
41 - RRDR_RESULT_OPTION_ABSOLUTE = 0x00000001,
42 - RRDR_RESULT_OPTION_RELATIVE = 0x00000002,
42 + RRDR_RESULT_OPTION_ABSOLUTE = 0x00000001, // the query uses absolute time-frames (can be cached by browsers and proxies)
43 + RRDR_RESULT_OPTION_RELATIVE = 0x00000002, // the query uses relative time-frames (should not to be cached by browsers and proxies)
44 } RRDR_RESULT_FLAGS;
45
46 typedef struct rrdresult {