Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Field Science
datavis
Commits
c24b4c13
Commit
c24b4c13
authored
Jan 07, 2022
by
Porter Libby
Browse files
fix graph loops caused by unsorted data
parent
ec2eb84b
Changes
2
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
c24b4c13
{
"name"
:
"datavis"
,
"version"
:
"0.1.1
2
"
,
"version"
:
"0.1.1
3
"
,
"description"
:
"A tool for visualizing the data collected from the IFS Earlham trip"
,
"main"
:
"datavis.js"
,
"scripts"
:
{
...
...
public/js/graph.js
View file @
c24b4c13
...
...
@@ -243,14 +243,19 @@ function addData(chart,times,data,types,color,title) {
chart
.
data
.
labels
=
times
;
for
(
x
=
0
;
x
<
data
.
length
;
x
++
){
// create plot for each set of data [elevation,pressure,etc...]
var
newdata
=
data
[
x
].
sort
((
a
,
b
)
=>
{
return
moment
(
a
.
x
).
diff
(
b
.
x
);
});
var
dataset
=
{
label
:
types
[
x
],
borderColor
:
getRandomColor
(),
// choose random color for now
borderWidth
:
3
,
fill
:
false
,
data
:
data
[
x
]
,
data
:
new
data
,
}
chart
.
data
.
datasets
.
push
(
dataset
);
console
.
log
(
data
[
x
][
0
][
"
x
"
])
}
chart
.
update
();
}
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