add possibility to change badge text font color (#7809)
- add possibility to change badge font color - unify color param syntax and fix where not working before in conflict with documentation custom html colors were not possible as label color. This fixes that and makes all `color` parameter values behave in the same way
Timo committed
Jan 30, 2020 at 15:03 UTC
15caabfcf8435a2b1957b79dcf260bce91d8fa1f
5 files changed
+296
-58
web/api/badges/README.md
+50
-7
@@ -178,19 +178,62 @@ These are options dedicated to badges:
178
179
Divide the value with this number. The default is `1`.
180
181
-- `label_color=COLOR`
181
+- Color customization parameters
182
183
- The color of the label (the left part). You can use any HTML color, include `#NNN` and `#NNNNNN`. The following colors are defined in Netdata (and you can use them by name): `green`, `brightgreen`, `yellow`, `yellowgreen`, `orange`, `red`, `blue`, `grey`, `gray`, `lightgrey`, `lightgray`. These are taken from <https://github.com/badges/shields> so they are compatible with standard badges.
183
+ The following parameters specify colors of each individual part of the badge. Each parameter is documented in detail
184
+ below.
185
185
-- `value_color=COLOR:null|COLOR<VALUE|COLOR>VALUE|COLOR>=VALUE|COLOR<=VALUE|...`
186
+ | Area of badge | Backgroud color parameter | Text color parameter |
187
+ | ---: | :-----------------------: | :------------------: |
188
+ | Label (left) part | `label_color` | `text_color_lbl` |
189
+ | Value (right) part | `value_color` | `text_color_val` |
190
187
- You can add a pipe delimited list of conditions to pick the color. The first matching (left to right) will be used.
191
+ - `label_color=COLOR`
192
189
- Example: `value_color=grey:null|green<10|yellow<100|orange<1000|blue<10000|red`
193
+ The color of the label (the left part). You can use any HTML color in `RGB` or `RRGGBB` hex notation (without
194
+ the `#` character at the beginning). Additionally, you can use one of the following predefined colors (and you
195
+ can use them by their name):
196
+
197
+ - `green`
198
+ - `brightgreen`
199
+ - `yellow`
200
+ - `yellowgreen`
201
+ - `orange`
202
+ - `red`
203
+ - `blue`
204
+ - `grey`
205
+ - `gray`
206
+ - `lightgrey`
207
+ - `lightgray`
208
+
209
+ These colors are taken from <https://github.com/badges/shields>, which makes them compatible with standard
210
+ badges.
211
+
212
+ - `value_color=COLOR:null|COLOR<VALUE|COLOR>VALUE|COLOR>=VALUE|COLOR<=VALUE|...`
213
+
214
+ You can add a pipe delimited list of conditions to pick the value color. The first matching (left to right) will
215
+ be used.
216
+
217
+ Example: `value_color=grey:null|green<10|yellow<100|orange<1000|blue<10000|red`
218
+
219
+ The above will set `grey` if no value exists (not collected within the `gap when lost iterations above` in
220
+ `netdata.conf` for the chart), `green` if the value is less than 10, `yellow` if the value is less than 100, and
221
+ so on. Netdata will use `red` if no other conditions match. Only integers are suported as values.
222
+
223
+ The supported operators are `<`, `>`, `<=`, `>=`, `=` (or `:`), and `!=` (or `<>`).
224
+
225
+ You can also use the same syntax as the `label_color` parameter to define each of these colors. You can
226
+ reference a predefined color by name or `RGB`/`RRGGBB` hex notation.
227
+
228
+ - `text_color_lbl=RGB` or `text_color_lbl=RRGGBB` or `text_color_lbl=color_by_name`
229
+
230
+ This value specifies the font color for the font of left/label side of the badge. The syntax is the same as the
231
+ `label_color` parameter. If not given, or given with an empty value, Netdata will use the default color.
232
191
- The above will set `grey` if no value exists (not collected within the `gap when lost iterations above` in `netdata.conf` for the chart), `green` if the value is less than 10, `yellow` if the value is less than 100, etc up to `red` which will be used if no other conditions match.
233
+ - `text_color_val=RGB` or `text_color_val=RRGGBB` or `text_color_lbl=color_by_name`
234
193
- The supported operators are `<`, `>`, `<=`, `>=`, `=` (or `:`) and `!=` (or `<>`).
235
+ This value specifies the font color for the font of right/value side of the badge. The syntax is the same as the
236
+ `label_color` parameter. If not given, or given with an empty value, Netdata will use the default color.
237
238
- `precision=NUMBER`
239
web/api/badges/web_buffer_svg.c
+92
-38
@@ -507,23 +507,23 @@ static struct badge_color {
507
// colors from:
508
// https://github.com/badges/shields/blob/master/colorscheme.json
509
510
- { "brightgreen", 0, "#4c1" },
511
- { "green", 0, "#97CA00" },
512
- { "yellow", 0, "#dfb317" },
513
- { "yellowgreen", 0, "#a4a61d" },
514
- { "orange", 0, "#fe7d37" },
515
- { "red", 0, "#e05d44" },
516
- { "blue", 0, "#007ec6" },
517
- { "grey", 0, "#555" },
518
- { "gray", 0, "#555" },
519
- { "lightgrey", 0, "#9f9f9f" },
520
- { "lightgray", 0, "#9f9f9f" },
510
+ { "brightgreen", 0, "4c1" },
511
+ { "green", 0, "97CA00" },
512
+ { "yellow", 0, "dfb317" },
513
+ { "yellowgreen", 0, "a4a61d" },
514
+ { "orange", 0, "fe7d37" },
515
+ { "red", 0, "e05d44" },
516
+ { "blue", 0, "007ec6" },
517
+ { "grey", 0, "555" },
518
+ { "gray", 0, "555" },
519
+ { "lightgrey", 0, "9f9f9f" },
520
+ { "lightgray", 0, "9f9f9f" },
521
522
// terminator
523
{ NULL, 0, NULL }
524
};
525
526
-static inline const char *color_map(const char *color) {
526
+static inline const char *color_map(const char *color, const char *def) {
527
static int max = -1;
528
int i;
529
@@ -543,7 +543,7 @@ static inline const char *color_map(const char *color) {
543
return ptr->color;
544
}
545
546
- return color;
546
+ return def;
547
}
548
549
typedef enum color_comparison {
@@ -688,24 +688,66 @@ static inline void calc_colorz(const char *color, char *final, size_t len, calcu
688
// colors
689
#define COLOR_STRING_SIZE 100
690
691
-void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const char *units, const char *label_color, const char *value_color, int precision, int scale, uint32_t options, int fixed_width_lbl, int fixed_width_val) {
691
+static inline int allowed_hexa_char(char x) {
692
+ return ( (x >= '0' && x <= '9') ||
693
+ (x >= 'a' && x <= 'f') ||
694
+ (x >= 'A' && x <= 'F')
695
+ );
696
+}
697
+
698
+static int html_color_check(const char *str) {
699
+ int i = 0;
700
+ while(str[i]) {
701
+ if(!allowed_hexa_char(str[i]))
702
+ return 0;
703
+ if(unlikely(i >= 6))
704
+ return 0;
705
+ i++;
706
+ }
707
+ // want to allow either RGB or RRGGBB
708
+ return ( i == 6 || i == 3 );
709
+}
710
+
711
+// Will parse color arg as #RRGGBB or #RGB or one of the colors
712
+// from color_map hash table
713
+// if parsing fails (argument error) it will return default color
714
+// given as default parameter (def)
715
+// in any case it will return either color in "RRGGBB" or "RGB" format as string
716
+// or whatever is given as def (without checking - caller responsible to give sensible
717
+// safely escaped default) as default if it fails
718
+// in any case this function must always return something we can put directly in XML
719
+// so no escaping is necessary anymore (with excpetion of default where caller is responsible)
720
+// to give sensible default
721
+#define BADGE_SVG_COLOR_ARG_MAXLEN 20
722
+
723
+static const char *parse_color_argument(const char *arg, const char *def)
724
+{
725
+ if( !arg )
726
+ return def;
727
+ size_t len = strnlen(arg, BADGE_SVG_COLOR_ARG_MAXLEN);
728
+ if( len < 2 || len >= BADGE_SVG_COLOR_ARG_MAXLEN )
729
+ return def;
730
+ if( html_color_check(arg) )
731
+ return arg;
732
+ return color_map(arg, def);
733
+}
734
+
735
+void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const char *units, const char *label_color, const char *value_color, int precision, int scale, uint32_t options, int fixed_width_lbl, int fixed_width_val, const char* text_color_lbl, const char* text_color_val) {
736
char value_color_buffer[COLOR_STRING_SIZE + 1]
737
, value_string[VALUE_STRING_SIZE + 1]
738
, label_escaped[LABEL_STRING_SIZE + 1]
695
- , value_escaped[VALUE_STRING_SIZE + 1]
696
- , label_color_escaped[COLOR_STRING_SIZE + 1]
697
- , value_color_escaped[COLOR_STRING_SIZE + 1];
739
+ , value_escaped[VALUE_STRING_SIZE + 1];
740
+
741
+ const char *label_color_parsed;
742
+ const char *value_color_parsed;
743
744
double label_width = (double)fixed_width_lbl, value_width = (double)fixed_width_val, total_width;
745
double height = 20.0, font_size = 11.0, text_offset = 5.8, round_corner = 3.0;
746
747
if(scale < 100) scale = 100;
748
704
- if(unlikely(!label_color || !*label_color))
705
- label_color = "#555";
706
-
749
if(unlikely(!value_color || !*value_color))
708
- value_color = (isnan(value) || isinf(value))?"#999":"#4c1";
750
+ value_color = (isnan(value) || isinf(value))?"999":"4c1";
751
752
calc_colorz(value_color, value_color_buffer, COLOR_STRING_SIZE, value);
753
format_value_and_unit(value_string, VALUE_STRING_SIZE, (options & RRDR_OPTION_DISPLAY_ABS)?calculated_number_fabs(value):value, units, precision);
@@ -718,8 +760,9 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
760
761
escape_xmlz(label_escaped, label, LABEL_STRING_SIZE);
762
escape_xmlz(value_escaped, value_string, VALUE_STRING_SIZE);
721
- escape_xmlz(label_color_escaped, color_map(label_color), COLOR_STRING_SIZE);
722
- escape_xmlz(value_color_escaped, color_map(value_color_buffer), COLOR_STRING_SIZE);
763
+
764
+ label_color_parsed = parse_color_argument(label_color, "555");
765
+ value_color_parsed = parse_color_argument(value_color_buffer, "555");
766
767
wb->contenttype = CT_IMAGE_SVG_XML;
768
@@ -743,10 +786,10 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
786
"<rect class=\"bdge-ttl-width\" width=\"%0.2f\" height=\"%0.2f\" rx=\"%0.2f\" fill=\"#fff\"/>"
787
"</mask>"
788
"<g mask=\"url(#round)\">"
746
- "<rect class=\"bdge-rect-lbl\" width=\"%0.2f\" height=\"%0.2f\" fill=\"%s\"/>",
789
+ "<rect class=\"bdge-rect-lbl\" width=\"%0.2f\" height=\"%0.2f\" fill=\"#%s\"/>",
790
total_width, height,
791
total_width, height, round_corner,
749
- label_width, height, label_color_escaped); //<rect class="bdge-rect-lbl"
792
+ label_width, height, label_color_parsed); //<rect class="bdge-rect-lbl"
793
794
if(fixed_width_lbl > 0 && fixed_width_val > 0) {
795
buffer_sprintf(wb,
@@ -757,8 +800,8 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
800
}
801
802
buffer_sprintf(wb,
760
- "<rect class=\"bdge-rect-val\" x=\"%0.2f\" width=\"%0.2f\" height=\"%0.2f\" fill=\"%s\"/>",
761
- label_width, value_width, height, value_color_escaped);
803
+ "<rect class=\"bdge-rect-val\" x=\"%0.2f\" width=\"%0.2f\" height=\"%0.2f\" fill=\"#%s\"/>",
804
+ label_width, value_width, height, value_color_parsed);
805
806
if(fixed_width_lbl > 0 && fixed_width_val > 0) {
807
buffer_sprintf(wb,
@@ -771,18 +814,18 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
814
buffer_sprintf(wb,
815
"<rect class=\"bdge-ttl-width\" width=\"%0.2f\" height=\"%0.2f\" fill=\"url(#smooth)\"/>"
816
"</g>"
774
- "<g fill=\"#fff\" text-anchor=\"middle\" font-family=\"DejaVu Sans,Verdana,Geneva,sans-serif\" font-size=\"%0.2f\">"
817
+ "<g text-anchor=\"middle\" font-family=\"DejaVu Sans,Verdana,Geneva,sans-serif\" font-size=\"%0.2f\">"
818
"<text class=\"bdge-lbl-lbl\" x=\"%0.2f\" y=\"%0.0f\" fill=\"#010101\" fill-opacity=\".3\" clip-path=\"url(#lbl-rect)\">%s</text>"
776
- "<text class=\"bdge-lbl-lbl\" x=\"%0.2f\" y=\"%0.0f\" clip-path=\"url(#lbl-rect)\">%s</text>"
819
+ "<text class=\"bdge-lbl-lbl\" x=\"%0.2f\" y=\"%0.0f\" fill=\"#%s\" clip-path=\"url(#lbl-rect)\">%s</text>"
820
"<text class=\"bdge-lbl-val\" x=\"%0.2f\" y=\"%0.0f\" fill=\"#010101\" fill-opacity=\".3\" clip-path=\"url(#val-rect)\">%s</text>"
778
- "<text class=\"bdge-lbl-val\" x=\"%0.2f\" y=\"%0.0f\" clip-path=\"url(#val-rect)\">%s</text>"
821
+ "<text class=\"bdge-lbl-val\" x=\"%0.2f\" y=\"%0.0f\" fill=\"#%s\" clip-path=\"url(#val-rect)\">%s</text>"
822
"</g>",
823
total_width, height,
824
font_size,
825
label_width / 2, ceil(height - text_offset), label_escaped,
783
- label_width / 2, ceil(height - text_offset - 1.0), label_escaped,
826
+ label_width / 2, ceil(height - text_offset - 1.0), parse_color_argument(text_color_lbl, "fff"), label_escaped,
827
label_width + value_width / 2 -1, ceil(height - text_offset), value_escaped,
785
- label_width + value_width / 2 -1, ceil(height - text_offset - 1.0), value_escaped);
828
+ label_width + value_width / 2 -1, ceil(height - text_offset - 1.0), parse_color_argument(text_color_val, "fff"), value_escaped);
829
830
if(fixed_width_lbl <= 0 || fixed_width_val <= 0){
831
buffer_sprintf(wb,
@@ -815,6 +858,9 @@ void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const ch
858
buffer_sprintf(wb, "</svg>");
859
}
860
861
+#define BADGE_URL_ARG_LBL_COLOR "text_color_lbl"
862
+#define BADGE_URL_ARG_VAL_COLOR "text_color_val"
863
+
864
int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *url) {
865
int ret = HTTP_RESP_BAD_REQUEST;
866
buffer_flush(w->response.data);
@@ -836,7 +882,9 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
882
, *scale_str = NULL
883
, *alarm = NULL
884
, *fixed_width_lbl_str = NULL
839
- , *fixed_width_val_str = NULL;
885
+ , *fixed_width_val_str = NULL
886
+ , *text_color_lbl_str = NULL
887
+ , *text_color_val_str = NULL;
888
889
int group = RRDR_GROUPING_AVERAGE;
890
uint32_t options = 0x00000000;
@@ -883,6 +931,8 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
931
else if(!strcmp(name, "fixed_width_lbl")) fixed_width_lbl_str = value;
932
else if(!strcmp(name, "fixed_width_val")) fixed_width_val_str = value;
933
else if(!strcmp(name, "alarm")) alarm = value;
934
+ else if(!strcmp(name, BADGE_URL_ARG_LBL_COLOR)) text_color_lbl_str = value;
935
+ else if(!strcmp(name, BADGE_URL_ARG_VAL_COLOR)) text_color_val_str = value;
936
}
937
938
int fixed_width_lbl = -1;
@@ -893,7 +943,7 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
943
fixed_width_lbl = str2i(fixed_width_lbl_str);
944
fixed_width_val = str2i(fixed_width_val_str);
945
}
896
-
946
+
947
if(!chart || !*chart) {
948
buffer_no_cacheable(w->response.data);
949
buffer_sprintf(w->response.data, "No chart id is given at the request.");
@@ -906,7 +956,7 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
956
if(!st) st = rrdset_find_byname(host, chart);
957
if(!st) {
958
buffer_no_cacheable(w->response.data);
909
- buffer_svg(w->response.data, "chart not found", NAN, "", NULL, NULL, -1, scale, 0, -1, -1);
959
+ buffer_svg(w->response.data, "chart not found", NAN, "", NULL, NULL, -1, scale, 0, -1, -1, NULL, NULL);
960
ret = HTTP_RESP_OK;
961
goto cleanup;
962
}
@@ -917,7 +967,7 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
967
rc = rrdcalc_find(st, alarm);
968
if (!rc) {
969
buffer_no_cacheable(w->response.data);
920
- buffer_svg(w->response.data, "alarm not found", NAN, "", NULL, NULL, -1, scale, 0, -1, -1);
970
+ buffer_svg(w->response.data, "alarm not found", NAN, "", NULL, NULL, -1, scale, 0, -1, -1, NULL, NULL);
971
ret = HTTP_RESP_OK;
972
goto cleanup;
973
}
@@ -1037,7 +1087,9 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
1087
scale,
1088
options,
1089
fixed_width_lbl,
1040
- fixed_width_val
1090
+ fixed_width_val,
1091
+ text_color_lbl_str,
1092
+ text_color_val_str
1093
);
1094
ret = HTTP_RESP_OK;
1095
}
@@ -1076,7 +1128,9 @@ int web_client_api_request_v1_badge(RRDHOST *host, struct web_client *w, char *u
1128
scale,
1129
options,
1130
fixed_width_lbl,
1079
- fixed_width_val
1131
+ fixed_width_val,
1132
+ text_color_lbl_str,
1133
+ text_color_val_str
1134
);
1135
}
1136
web/api/badges/web_buffer_svg.h
+1
-1
@@ -6,7 +6,7 @@
6
#include "libnetdata/libnetdata.h"
7
#include "web/server/web_client.h"
8
9
-extern void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const char *units, const char *label_color, const char *value_color, int precision, int scale, uint32_t options, int fixed_width_lbl, int fixed_width_val);
9
+extern void buffer_svg(BUFFER *wb, const char *label, calculated_number value, const char *units, const char *label_color, const char *value_color, int precision, int scale, uint32_t options, int fixed_width_lbl, int fixed_width_val, const char* text_color_lbl, const char* text_color_val);
10
extern char *format_value_and_unit(char *value_string, size_t value_string_len, calculated_number value, const char *units, int precision);
11
12
extern int web_client_api_request_v1_badge(struct rrdhost *host, struct web_client *w, char *url);
web/api/netdata-swagger.json
+87
-5
@@ -338,7 +338,7 @@
338
},
339
"/badge.svg": {
340
"get": {
341
- "summary": "Generate a SVG image for a chart (or dimension)",
341
+ "summary": "Generate a badge in form of SVG image for a chart (or dimension)",
342
"description": "Successful responses are SVG images.",
343
"parameters": [
344
{
@@ -471,18 +471,38 @@
471
{
472
"name": "label_color",
473
"in": "query",
474
- "description": "A color to be used for the background of the label.",
474
+ "description": "A color to be used for the background of the label side(left side) of the badge. One of predefined colors or specific color in hex `RGB` or `RRGGBB` format (without preceding `#` character). If value wrong or not given default color will be used.",
475
"required": false,
476
"allowEmptyValue": true,
477
"schema": {
478
- "type": "string",
479
- "format": "any text"
478
+ "oneOf": [
479
+ {
480
+ "type": "string",
481
+ "enum" : [
482
+ "green",
483
+ "brightgreen",
484
+ "yellow",
485
+ "yellowgreen",
486
+ "orange",
487
+ "red",
488
+ "blue",
489
+ "grey",
490
+ "gray",
491
+ "lightgrey",
492
+ "lightgray"
493
+ ]
494
+ },
495
+ {
496
+ "type": "string",
497
+ "format": "^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
498
+ }
499
+ ]
500
}
501
},
502
{
503
"name": "value_color",
504
"in": "query",
485
- "description": "A color to be used for the background of the label. You can set multiple using a pipe with a condition each, like this: colorvalue|color:null The following operators are supported: >, <, >=, <=, =, :null (to check if no value exists).",
505
+ "description": "A color to be used for the background of the value *(right)* part of badge. You can set multiple using a pipe with a condition each, like this: `color<value|color:null` The following operators are supported: >, <, >=, <=, =, :null (to check if no value exists). Each color can be specified in same manner as for `label_color` parameter. Currently only integers are suported as values.",
506
"required": false,
507
"allowEmptyValue": true,
508
"schema": {
@@ -490,6 +510,68 @@
510
"format": "any text"
511
}
512
},
513
+ {
514
+ "name": "text_color_lbl",
515
+ "in": "query",
516
+ "description": "Font color for label *(left)* part of the badge. One of predefined colors or as HTML hexadecimal color without preceeding `#` character. Formats allowed `RGB` or `RRGGBB`. If no or wrong value given default color will be used.",
517
+ "required": false,
518
+ "allowEmptyValue": true,
519
+ "schema": {
520
+ "oneOf": [
521
+ {
522
+ "type": "string",
523
+ "enum" : [
524
+ "green",
525
+ "brightgreen",
526
+ "yellow",
527
+ "yellowgreen",
528
+ "orange",
529
+ "red",
530
+ "blue",
531
+ "grey",
532
+ "gray",
533
+ "lightgrey",
534
+ "lightgray"
535
+ ]
536
+ },
537
+ {
538
+ "type": "string",
539
+ "format": "^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
540
+ }
541
+ ]
542
+ }
543
+ },
544
+ {
545
+ "name": "text_color_val",
546
+ "in": "query",
547
+ "description": "Font color for value *(right)* part of the badge. One of predefined colors or as HTML hexadecimal color without preceeding `#` character. Formats allowed `RGB` or `RRGGBB`. If no or wrong value given default color will be used.",
548
+ "required": false,
549
+ "allowEmptyValue": true,
550
+ "schema": {
551
+ "oneOf": [
552
+ {
553
+ "type": "string",
554
+ "enum" : [
555
+ "green",
556
+ "brightgreen",
557
+ "yellow",
558
+ "yellowgreen",
559
+ "orange",
560
+ "red",
561
+ "blue",
562
+ "grey",
563
+ "gray",
564
+ "lightgrey",
565
+ "lightgray"
566
+ ]
567
+ },
568
+ {
569
+ "type": "string",
570
+ "format": "^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
571
+ }
572
+ ]
573
+ }
574
+ },
575
{
576
"name": "multiply",
577
"in": "query",
web/api/netdata-swagger.yaml
+66
-7
@@ -291,7 +291,7 @@ paths:
291
memory.
292
/badge.svg:
293
get:
294
- summary: Generate a SVG image for a chart (or dimension)
294
+ summary: Generate a badge in form of SVG image for a chart (or dimension)
295
description: Successful responses are SVG images.
296
parameters:
297
- name: chart
@@ -410,23 +410,82 @@ paths:
410
format: any text
411
- name: label_color
412
in: query
413
- description: A color to be used for the background of the label.
413
+ description: A color to be used for the background of the label side(left side) of the badge. One of predefined colors or specific color in hex `RGB` or `RRGGBB` format (without preceding `#` character). If value wrong or not given default color will be used.
414
required: false
415
allowEmptyValue: true
416
schema:
417
- type: string
418
- format: any text
417
+ oneOf:
418
+ - type: string
419
+ enum:
420
+ - green
421
+ - brightgreen
422
+ - yellow
423
+ - yellowgreen
424
+ - orange
425
+ - red
426
+ - blue
427
+ - grey
428
+ - gray
429
+ - lightgrey
430
+ - lightgray
431
+ - type: string
432
+ format: ^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
433
- name: value_color
434
in: query
421
- description: "A color to be used for the background of the label. You can set
435
+ description: "A color to be used for the background of the value *(right)* part of badge. You can set
436
multiple using a pipe with a condition each, like this:
423
- colorvalue|color:null The following operators are
424
- supported: >, <, >=, <=, =, :null (to check if no value exists)."
437
+ `color<value|color:null` The following operators are
438
+ supported: >, <, >=, <=, =, :null (to check if no value exists). Each color can be specified in same manner as for `label_color` parameter.
439
+ Currently only integers are suported as values."
440
required: false
441
allowEmptyValue: true
442
schema:
443
type: string
444
format: any text
445
+ - name: text_color_lbl
446
+ in: query
447
+ description: Font color for label *(left)* part of the badge. One of predefined colors or as HTML hexadecimal color without preceeding `#` character. Formats allowed `RGB` or `RRGGBB`. If no or wrong value given default color will be used.
448
+ required: false
449
+ allowEmptyValue: true
450
+ schema:
451
+ oneOf:
452
+ - type: string
453
+ enum:
454
+ - green
455
+ - brightgreen
456
+ - yellow
457
+ - yellowgreen
458
+ - orange
459
+ - red
460
+ - blue
461
+ - grey
462
+ - gray
463
+ - lightgrey
464
+ - lightgray
465
+ - type: string
466
+ format: ^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
467
+ - name: text_color_val
468
+ in: query
469
+ description: Font color for value *(right)* part of the badge. One of predefined colors or as HTML hexadecimal color without preceeding `#` character. Formats allowed `RGB` or `RRGGBB`. If no or wrong value given default color will be used.
470
+ required: false
471
+ allowEmptyValue: true
472
+ schema:
473
+ oneOf:
474
+ - type: string
475
+ enum:
476
+ - green
477
+ - brightgreen
478
+ - yellow
479
+ - yellowgreen
480
+ - orange
481
+ - red
482
+ - blue
483
+ - grey
484
+ - gray
485
+ - lightgrey
486
+ - lightgray
487
+ - type: string
488
+ format: ^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
489
- name: multiply
490
in: query
491
description: Multiply the value with this number for rendering it at the image