Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
openfpm_io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sbalzarini Lab
Software
Parallel Computing
OpenFPM
openfpm_io
Commits
b03ba0d2
Commit
b03ba0d2
authored
8 years ago
by
Pietro Incardona
Browse files
Options
Downloads
Patches
Plain Diff
view options start
parent
6467fc05
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plot/GoogleChart.hpp
+34
-0
34 additions, 0 deletions
src/Plot/GoogleChart.hpp
src/Plot/Plot_unit_tests.hpp
+54
-0
54 additions, 0 deletions
src/Plot/Plot_unit_tests.hpp
with
88 additions
and
0 deletions
src/Plot/GoogleChart.hpp
+
34
−
0
View file @
b03ba0d2
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
src/Plot/Plot_unit_tests.hpp
+
54
−
0
View file @
b03ba0d2
...
...
@@ -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]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment