Turi Create  4.0
vega_spec.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef __TC_VEGA_SPEC
7 #define __TC_VEGA_SPEC
8 
9 #include <core/data/flexible_type/flexible_type.hpp>
10 
11 #include <string>
12 #include <sstream>
13 
14 namespace turi {
15 
16  namespace visualization {
17  // 1d plots (distribution plots)
18  std::string histogram_spec(const flexible_type& title, const flexible_type& xlabel, const flexible_type& ylabel, flex_type_enum dtype);
19  std::string categorical_spec(const flexible_type& title, const flexible_type& xlabel, const flexible_type& ylabel, flex_type_enum dtype);
20  // collection of 1d plots for SFrame
21  std::string summary_view_spec(size_t length_elements);
22 
23  // 2d plots
24  std::string scatter_spec(const flexible_type& xlabel, const flexible_type& ylabel, const flexible_type& title);
25  std::string heatmap_spec(const flexible_type& xlabel, const flexible_type& ylabel, const flexible_type& title);
26  std::string categorical_heatmap_spec(const flexible_type& xlabel, const flexible_type& ylabel, const flexible_type& title);
27  std::string boxes_and_whiskers_spec(const flexible_type& xlabel, const flexible_type& ylabel, const flexible_type& title);
28 
29  // Utility for escaping JSON string literals. Not concerned with Vega implications of the contents of those strings.
30  std::string make_format_string(const std::string& raw_str);
31  std::string make_format_string(unsigned char *raw_format_str_ptr,
32  size_t raw_format_str_len);
33  std::string format(const std::string& format_str, const std::unordered_map<std::string, std::string>& format_params);
34  }
35 }
36 
37 #endif // __TC_VEGA_SPEC