summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5b3d96f)
raw | patch | inline | side by side (parent: 5b3d96f)
author | Florian Forster <octo@verplant.org> | |
Thu, 9 Sep 2010 15:15:55 +0000 (17:15 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Thu, 9 Sep 2010 15:15:55 +0000 (17:15 +0200) |
src/graph_def.c | patch | blob | history |
diff --git a/src/graph_def.c b/src/graph_def.c
index c7ecb988069299e233421659882fa6a3028b2219..d01db8ea8b4e06e581705a74668273e89491887f 100644 (file)
--- a/src/graph_def.c
+++ b/src/graph_def.c
if (def == NULL)
return (0);
- snprintf (color, sizeof (color), "#%06"PRIx32, def->color);
+ if (def->color < 0x00ffffff)
+ snprintf (color, sizeof (color), "#%06"PRIx32, def->color);
+ else
+ strncpy (color, "random", sizeof (color));
color[sizeof (color) - 1] = 0;
yajl_gen_map_open (handler);
yajl_gen_string_cast (handler, "select", strlen ("select"));
ident_to_json (def->select, handler);
- yajl_gen_string_cast (handler, "ds_name", strlen ("ds_name"));
- yajl_gen_string_cast (handler, def->ds_name, strlen (def->ds_name));
- yajl_gen_string_cast (handler, "legend", strlen ("legend"));
- yajl_gen_string_cast (handler, def->legend, strlen (def->legend));
+ if (def->ds_name != NULL)
+ {
+ yajl_gen_string_cast (handler, "ds_name", strlen ("ds_name"));
+ yajl_gen_string_cast (handler, def->ds_name, strlen (def->ds_name));
+ }
+ if (def->legend != NULL)
+ {
+ yajl_gen_string_cast (handler, "legend", strlen ("legend"));
+ yajl_gen_string_cast (handler, def->legend, strlen (def->legend));
+ }
yajl_gen_string_cast (handler, "color", strlen ("color"));
yajl_gen_string_cast (handler, color, strlen (color));
yajl_gen_string_cast (handler, "stack", strlen ("stack"));
yajl_gen_bool (handler, def->stack);
yajl_gen_string_cast (handler, "area", strlen ("area"));
yajl_gen_bool (handler, def->area);
- yajl_gen_string_cast (handler, "format", strlen ("format"));
- yajl_gen_string_cast (handler, def->format, strlen (def->format));
+ if (def->format != NULL)
+ {
+ yajl_gen_string_cast (handler, "format", strlen ("format"));
+ yajl_gen_string_cast (handler, def->format, strlen (def->format));
+ }
yajl_gen_map_close (handler);