Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_io
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openfpm
openfpm_io
Commits
b03ba0d2
Commit
b03ba0d2
authored
Mar 01, 2017
by
incardon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
view options start
parent
6467fc05
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
0 deletions
+88
-0
src/Plot/GoogleChart.hpp
src/Plot/GoogleChart.hpp
+34
-0
src/Plot/Plot_unit_tests.hpp
src/Plot/Plot_unit_tests.hpp
+54
-0
No files found.
src/Plot/GoogleChart.hpp
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
;
}
...
...
src/Plot/Plot_unit_tests.hpp
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]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment