Commit f02a479f authored by incardon's avatar incardon

New colums with numbers

parent b03ba0d2
......@@ -38,7 +38,8 @@ vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: 'bars'};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: 'Y Axis'},
hAxis: {title: 'X Axis'},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: ''},
hAxis: {title: ''},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: ''},
hAxis: {title: ''},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -38,7 +38,8 @@ vAxis: {title: ''},
hAxis: {title: ''},
seriesType: ''};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -79,11 +79,14 @@ hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
$("#export_svg1").on("click", function (event) {exportToSVG.apply(this,[1]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div1'));chart.draw(data1, options1);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div1'));
chart.draw(data1, options1);
$("#export_svg2").on("click", function (event) {exportToSVG.apply(this,[2]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));chart.draw(data2, options2);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div2'));
chart.draw(data2, options2);
}</script>
</head>
<body>
......
......@@ -39,7 +39,8 @@ hAxis: {title: 'X Axis'},
seriesType: 'bars',
series: {3: {type: 'line'}}};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -45,7 +45,8 @@ curveType: 'function',
lineWidth: 1,
intervals: { 'style':'area' }};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -47,7 +47,8 @@ intervals: { 'style':'area' },
interval: {'i2': { 'color': '#4374E0', 'style':'bars', 'lineWidth':4, 'fillOpacity':1 } }
};
$("#export_svg0").on("click", function (event) {exportToSVG.apply(this,[0]);});
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));chart.draw(data0, options0);
var chart = new google.visualization.ComboChart(document.getElementById('chart_div0'));
chart.draw(data0, options0);
}</script>
</head>
<body>
......
......@@ -258,20 +258,22 @@ class GoogleChart
*/
std::string get_view_bar_option(const GCoptions & opt, size_t n_col)
{
if (opt.barWD == false)
return std::string();
std::stringstream str;
str << "view.setColumns([0," << std::endl;
str << "[0" << std::endl;
for (size_t i = 0 ; i < n_col ; i++)
for (size_t i = 1 ; i < n_col ; i++)
{
str << i << ",{ calc: \"stringify\"," << std::endl;
str << "," << i << ",{ calc: \"stringify\"," << std::endl;
str << "sourceColumn: " << i << "," << std::endl;
str << "type: \"string\"," << std::endl;
str << "role: \"annotation\" }"<< std::endl;
}
str << "]);" << std::endl;
str << "]" << std::endl;
return str.str();
}
......@@ -344,19 +346,46 @@ class GoogleChart
of << "};\n";
}
/*! \brief Add a view data variable
*
* \param of file out
* \param i id
* \param view string
*
*/
void addView(std::ofstream & of, size_t i, std::string view)
{
if (view.size() == 0)
return;
of << "var view" << i << " = new google.visualization.DataView(data" << i << ");" << std::endl;
of << "view"<< i << ".setColumns(";
of << view << ");" << std::endl;
}
/*! \brief Add a draw div section
*
* \param of file out
* \param i id
* \param draw_view draw a chart(true) or view(false)
*
*/
void addDrawDiv(std::ofstream & of, size_t i)
void addDrawDiv(std::ofstream & of, size_t i, bool draw_view)
{
of << "$(\"#export_svg" << i << "\").on(\"click\", function (event) {exportToSVG.apply(this,[" << i << "]);});\n";
of << "var chart = new google.visualization.ComboChart(document.getElementById('chart_div";
of << i;
of << "'));chart.draw(data";
of << i;
of << "'));" << std::endl;
if (draw_view == true)
{
of << "chart.draw(data";
of << i;
}
else
{
of << "chart.draw(view";
of << i;
}
of << ", options";
of << i;
of << ");\n";
......@@ -471,7 +500,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().view = get_view_bar_option(opt,y.get(0).size());
set_of_graphs.last().opt = opt;
}
......@@ -633,7 +662,10 @@ public:
addOption(of,i,set_of_graphs.get(i).option);
for (size_t i = 0 ; i < set_of_graphs.size() ; i++)
addDrawDiv(of,i);
addView(of,i,set_of_graphs.get(i).view);
for (size_t i = 0 ; i < set_of_graphs.size() ; i++)
addDrawDiv(of,i,set_of_graphs.get(i).view.size() == 0);
of << begin_div;
......
......@@ -14,7 +14,7 @@
BOOST_AUTO_TEST_SUITE( plot_unit_test )
BOOST_AUTO_TEST_CASE( google_chart )
BOOST_AUTO_TEST_CASE( google_chart_bar_string )
{
//! [Producing an Histogram graph]
......@@ -58,11 +58,11 @@ BOOST_AUTO_TEST_CASE( google_chart )
GoogleChart cg;
cg.AddHistGraph(x,y,yn,options);
cg.write("gc_out_wd.html");
cg.write("gc_out_sc.html");
//! [Producing an Histogram graph]
bool test = compare("gc_out_wd.html","gc_out_wd_test.html");
bool test = compare("gc_out_sc.html","gc_out_sc_test.html");
BOOST_REQUIRE_EQUAL(true,test);
}
......
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