Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
56f76528
Commit
56f76528
authored
Nov 02, 2014
by
Mathieu Rodic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] graph plotting - add X-axis
parent
5f4fcb05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
53 deletions
+74
-53
script.js
tests/charts/script.js
+74
-53
No files found.
tests/charts/script.js
View file @
56f76528
...
@@ -198,9 +198,6 @@ var Graph = function(container, width, height) {
...
@@ -198,9 +198,6 @@ var Graph = function(container, width, height) {
};
};
var
__datasets__
=
{};
var
__datasets__
=
{};
var
plotMethods
=
{};
plotMethods
.
segments
=
function
(
point
,
previousPoint
,
options
)
{
}
this
.
feed
=
function
(
datasets
)
{
this
.
feed
=
function
(
datasets
)
{
// get the dimensions & types
// get the dimensions & types
__datasets__
.
dimensions
=
datasets
[
0
].
data
[
0
].
length
;
__datasets__
.
dimensions
=
datasets
[
0
].
data
[
0
].
length
;
...
@@ -231,6 +228,66 @@ var Graph = function(container, width, height) {
...
@@ -231,6 +228,66 @@ var Graph = function(container, width, height) {
__datasets__
.
list
=
datasets
;
__datasets__
.
list
=
datasets
;
return
__this__
;
return
__this__
;
};
};
this
.
axisX
=
function
(
label
,
grads
)
{
var
extrema
=
plottingData
.
extrema
;
var
valuesX
=
__datasets__
.
values
[
0
];
var
valuesY
=
__datasets__
.
values
[
1
];
// main components
__this__
.
line
(
scales
[
0
].
min
,
valuesY
[
0
],
scales
[
0
].
max
,
valuesY
[
0
],
{
size
:
1
,
color
:
'#000'
}
);
__this__
.
text
(
scales
[
0
].
max
-
.
0125
*
scales
[
0
].
span
,
valuesY
[
0
]
+
.
025
*
scales
[
1
].
span
,
label
,
{
align
:
'right'
,
size
:
1
,
color
:
'#000'
}
);
// graduations
for
(
var
i
=
0
;
i
<
grads
.
length
;
i
++
)
{
var
opacity
=
Math
.
pow
(.
5
,
i
+
1
);
var
grad
=
grads
[
i
];
// extrema
var
min
=
valuesX
[
0
];
min
-=
min
%
grad
;
if
(
min
<
valuesX
[
0
])
{
min
+=
grad
;
}
var
max
=
valuesX
[
valuesX
.
length
-
1
];
max
-=
max
%
grad
;
while
(
max
<
valuesX
[
valuesX
.
length
-
1
])
{
max
+=
grad
;
}
// draw
for
(
var
x
=
min
;
x
<
max
;
x
+=
grad
)
{
__this__
.
line
(
x
,
valuesY
[
0
]
-
.
0125
*
scales
[
1
].
span
,
x
,
valuesY
[
0
]
+
.
0125
*
scales
[
1
].
span
,
{
size
:
1
,
color
:
'rgba(0,0,0,'
+
(
2
*
opacity
)
+
')'
}
);
__this__
.
line
(
x
,
valuesY
[
valuesY
.
length
-
1
],
x
,
valuesY
[
0
],
{
size
:
1
,
color
:
'rgba(0,0,0,'
+
opacity
+
')'
}
);
if
(
i
==
0
)
{
__this__
.
text
(
x
,
valuesY
[
0
]
-
.
05
*
scales
[
1
].
span
,
x
,
{
align
:
'center'
,
size
:
1
,
color
:
'#000'
}
);
}
}
}
};
this
.
axisY
=
function
(
label
,
grads
)
{
this
.
axisY
=
function
(
label
,
grads
)
{
var
extrema
=
plottingData
.
extrema
;
var
extrema
=
plottingData
.
extrema
;
var
valuesX
=
__datasets__
.
values
[
0
];
var
valuesX
=
__datasets__
.
values
[
0
];
...
@@ -291,52 +348,8 @@ var Graph = function(container, width, height) {
...
@@ -291,52 +348,8 @@ var Graph = function(container, width, height) {
}
}
}
}
};
};
this
.
grid
=
function
(
xGrad
,
yGrad
,
options
)
{
var
extrema
=
plottingData
.
extrema
;
this
.
viewLine
=
function
(
labels
,
options
)
{
//
var
xMin
=
extrema
.
xMin
;
xMin
-=
xMin
%
xGrad
;
if
(
xMin
<
extrema
.
xMin
)
{
xMin
+=
xGrad
;
}
var
xMax
=
extrema
.
xMax
;
xMax
-=
xMax
%
xGrad
;
while
(
xMax
<=
extrema
.
xMax
)
{
xMax
+=
xGrad
;
}
var
yMin
=
extrema
.
yMin
;
yMin
-=
yMin
%
yGrad
;
if
(
yMin
<
extrema
.
yMin
)
{
yMin
+=
yGrad
;
}
var
yMax
=
extrema
.
yMax
;
yMax
-=
yMax
%
yGrad
;
while
(
yMax
<=
extrema
.
yMax
)
{
yMax
+=
yGrad
;
}
//
for
(
var
y
=
yMin
;
y
<
yMax
;
y
+=
yGrad
)
{
__this__
.
line
(
extrema
.
yMin
-
extrema
.
xStep
,
y
,
scale
.
right
,
y
,
options
);
}
for
(
var
x
=
xMin
;
x
<
xMax
;
x
+=
xGrad
)
{
__this__
.
line
(
x
,
scale
.
top
,
x
,
scale
.
bottom
,
options
);
}
return
__this__
;
};
this
.
viewLine
=
function
(
labels
)
{
__this__
.
clear
();
__this__
.
clear
();
// compute the scales
// compute the scales
scales
=
[];
scales
=
[];
...
@@ -381,15 +394,23 @@ var Graph = function(container, width, height) {
...
@@ -381,15 +394,23 @@ var Graph = function(container, width, height) {
previousPoint
=
point
;
previousPoint
=
point
;
}
}
}
}
//
base for X- and Y-
axis
//
Y
axis
var
values
Y
=
__datasets__
.
values
[
0
];
var
values
=
__datasets__
.
values
[
1
];
var
grad
=
Math
.
log
(
values
Y
[
valuesY
.
length
-
1
]
-
valuesY
[
0
]);
var
grad
=
Math
.
log
(
values
[
values
.
length
-
1
]
-
values
[
0
]);
grad
/=
Math
.
log
(
10
);
grad
/=
Math
.
log
(
10
);
grad
=
Math
.
floor
(
grad
);
grad
=
Math
.
floor
(
grad
);
grad
=
Math
.
pow
(
10
,
grad
);
__this__
.
axisY
(
labels
[
1
],
[
grad
,
.
1
*
grad
]);
__this__
.
axisY
(
labels
[
1
],
[
grad
,
.
1
*
grad
]);
// X axis
var
values
=
__datasets__
.
values
[
0
];
var
grad
=
values
[
values
.
length
-
1
]
-
values
[
0
];
grad
=
Math
.
log
(
grad
)
/
Math
.
log
(
10
);
grad
=
Math
.
floor
(
grad
);
grad
=
Math
.
pow
(
10
,
grad
);
__this__
.
axisX
(
labels
[
0
],
[
grad
,
.
1
*
grad
]);
};
};
this
.
view
=
function
(
name
,
labels
)
{
this
.
view
=
function
(
name
,
labels
,
options
)
{
name
=
name
name
=
name
.
toLowerCase
()
.
toLowerCase
()
.
replace
(
/s+$/
,
''
)
.
replace
(
/s+$/
,
''
)
...
...
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