[go: nahoru, domu]

Skip to content

Commit

Permalink
Add a default label parameter value to plot C API (apple#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
znation authored Jan 28, 2019
1 parent 1d89184 commit 40b918a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/capi/TuriCreate.h
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,9 @@ typedef enum {

} tc_plot_variation;

// Default plot title / axis title sentinel value
const char * const tc_plot_title_default_label = "__TURI_DEFAULT_LABEL";

// Single SArray view (`.show` on an SArray)
tc_plot* tc_plot_create_1d(const tc_sarray* sa,
const char* title,
Expand Down
7 changes: 4 additions & 3 deletions src/unity/lib/visualization/vega_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include "vega_spec.hpp"

#include <capi/TuriCreate.h>
#include <logger/assertions.hpp>
#include <flexible_type/string_escape.hpp>

Expand Down Expand Up @@ -96,7 +97,7 @@ static std::string label_or_default(const flexible_type& label,
// undefined should render as null in JSON
return "null";

} else if (label == "__TURI_DEFAULT_LABEL") {
} else if (label == tc_plot_title_default_label) {
// substitute the default label
return extra_label_escape(_default, false /* include_quotes */);

Expand All @@ -110,7 +111,7 @@ static std::string title_or_default(const flexible_type& title, const std::strin
if (title == FLEX_UNDEFINED) {
// undefined/not provided should render as null in JSON
return "null";
} else if (title == "__TURI_DEFAULT_LABEL") {
} else if (title == tc_plot_title_default_label) {
return extra_label_escape(default_title, true /* include_quotes */);
} else {
// user-provided label should render with quotes/escaping
Expand All @@ -123,7 +124,7 @@ static std::string title_or_default(const flexible_type& title, const std::strin
if (title == FLEX_UNDEFINED) {
// undefined/not provided should render as null in JSON
return "null";
} else if (title == "__TURI_DEFAULT_LABEL") {
} else if (title == tc_plot_title_default_label) {
return extra_label_escape(xlabel + " vs. " + ylabel, true /* include_quotes */);
} else {
// user-provided label should render with quotes/escaping
Expand Down

0 comments on commit 40b918a

Please sign in to comment.