Commit b03ba0d2 authored by incardon's avatar incardon

view options start

parent 6467fc05
......@@ -68,6 +68,9 @@ struct GCoptions
//! curve type
std::string curveType = "function";
//! barWD
bool barWD = false;
//! copy operator
GCoptions & operator=(const GCoptions & opt)
{
......@@ -98,6 +101,9 @@ struct GGraph
//! option
std::string option;
//! view in case we need a view
std::string view;
//! Google chart option
GCoptions opt;
};
......@@ -243,6 +249,33 @@ class GoogleChart
return data.str();
}
/*! \brief Construct a view option
*
* \param opt GoogleChart option
*
* \return the string
*
*/
std::string get_view_bar_option(const GCoptions & opt, size_t n_col)
{
std::stringstream str;
str << "view.setColumns([0," << std::endl;
for (size_t i = 0 ; i < n_col ; i++)
{
str << i << ",{ calc: \"stringify\"," << std::endl;
str << "sourceColumn: " << i << "," << std::endl;
str << "type: \"string\"," << std::endl;
str << "role: \"annotation\" }"<< std::endl;
}
str << "]);" << std::endl;
return str.str();
}
std::string get_colums_bar_option(const GCoptions & opt)
{
std::stringstream str;
......@@ -438,6 +471,7 @@ public:
set_of_graphs.last().type = GGRAPH_COLUMS;
set_of_graphs.last().data = get_points_plot_data(x,y,yn,opt,set_of_graphs.size()-1);
set_of_graphs.last().option = get_colums_bar_option(opt);
set_of_graphs.last().view = get_view_bar_option(opt);
set_of_graphs.last().opt = opt;
}
......
......@@ -13,6 +13,60 @@
BOOST_AUTO_TEST_SUITE( plot_unit_test )
BOOST_AUTO_TEST_CASE( google_chart )
{
//! [Producing an Histogram graph]
openfpm::vector<std::string> x;
openfpm::vector<openfpm::vector<size_t>> y;
openfpm::vector<std::string> yn;
x.add("colum1");
x.add("colum2");
x.add("colum3");
x.add("colum4");
x.add("colum5");
x.add("colum6");
// Each colum can have multiple data set (in this case 4 dataset)
// Each dataset can have a name
yn.add("dataset1");
yn.add("dataset2");
yn.add("dataset3");
yn.add("dataset4");
// Each colums can have multiple data-set
y.add({2,3,5,6});
y.add({5,6,1,6});
y.add({2,1,6,9});
y.add({1,6,3,2});
y.add({3,3,0,6});
y.add({2,1,4,6});
// Google charts options
GCoptions options;
options.title = std::string("Example");
options.yAxis = std::string("Y Axis");
options.xAxis = std::string("X Axis");
options.stype = std::string("bars");
options.barWD = true;
// it say that the colum4 must me represented with a line
options.stypeext = std::string("{3: {type: 'line'}}");
GoogleChart cg;
cg.AddHistGraph(x,y,yn,options);
cg.write("gc_out_wd.html");
//! [Producing an Histogram graph]
bool test = compare("gc_out_wd.html","gc_out_wd_test.html");
BOOST_REQUIRE_EQUAL(true,test);
}
BOOST_AUTO_TEST_CASE( google_chart )
{
//! [Producing an Histogram graph]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment