Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
8c129da8
Commit
8c129da8
authored
Apr 16, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Output_viewGraph: Add checkboxes to enable / disable series
parent
afca0d8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
3 deletions
+49
-3
dream/platform/src/dream/Output_viewGraph.html
dream/platform/src/dream/Output_viewGraph.html
+2
-1
dream/platform/src/dream/Output_viewGraph.js
dream/platform/src/dream/Output_viewGraph.js
+47
-2
No files found.
dream/platform/src/dream/Output_viewGraph.html
View file @
8c129da8
...
...
@@ -14,6 +14,7 @@
<script
src=
"Output_viewGraph.js"
type=
"text/javascript"
></script>
</head>
<body>
<div
class=
"graph_container"
style=
"width: 100%;height:300px"
></div>
<div
class=
"graph_container"
style=
"float:left; width: 100%; height:300px"
></div>
<div
class=
"choices"
style=
"float:right; width: 10%; height:300px"
></div>
</body>
</html>
dream/platform/src/dream/Output_viewGraph.js
View file @
8c129da8
...
...
@@ -37,11 +37,56 @@
})
.
declareMethod
(
"
startService
"
,
function
()
{
// XXX Manually calculate width and height when resizing
var
i
=
0
,
options
=
this
.
props
.
data
.
options
,
datasets
=
this
.
props
.
data
.
series
,
graph_container
=
this
.
props
.
element
.
querySelector
(
"
.graph_container
"
),
choice_container
=
$
(
this
.
props
.
element
.
querySelector
(
"
.choices
"
));
$
.
plot
(
this
.
props
.
element
.
querySelector
(
"
.graph_container
"
)
,
graph_container
,
this
.
props
.
data
.
series
,
this
.
props
.
data
.
options
);
// Add checkboxes to toggle series on & off, inspired from http//:www.flotcharts.org/flot/examples/series-toggle/index.html
function
plotAccordingToChoices
()
{
var
data
=
[];
choice_container
.
find
(
"
input:checked
"
).
each
(
function
()
{
var
key
=
$
(
this
).
attr
(
"
name
"
);
if
(
key
&&
datasets
[
key
])
{
data
.
push
(
datasets
[
key
]);
}
});
if
(
data
.
length
>
0
)
{
$
.
plot
(
graph_container
,
data
,
options
);
}
}
if
(
!
this
.
props
.
data
.
options
.
bars
)
{
if
(
this
.
props
.
data
.
series
.
length
>=
5
)
{
// display the boxes
$
(
graph_container
).
css
({
'
width
'
:
'
90%
'
});
// hard-code color indices to prevent them from shifting as
// series are turned on/off
$
.
each
(
datasets
,
function
(
key
,
val
)
{
val
.
color
=
i
;
i
+=
1
;
});
// insert checkboxes
$
.
each
(
datasets
,
function
(
key
,
val
)
{
choice_container
.
append
(
"
<br/><input type='checkbox' name='
"
+
key
+
"
' checked='checked' id='id
"
+
key
+
"
'></input>
"
+
"
<label style='display:inline' for='id
"
+
key
+
"
'>
"
+
val
.
label
+
"
</label>
"
);
});
choice_container
.
find
(
"
input
"
).
click
(
plotAccordingToChoices
);
plotAccordingToChoices
();
}
}
});
}(
window
,
rJS
,
jQuery
,
initGadgetMixin
));
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