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
16b527f0
Commit
16b527f0
authored
Jun 05, 2015
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPDATE] ngrams.html with sorting OK
parent
85aeadfb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
26 deletions
+70
-26
dc.js
static/js/charts/dc.js
+1
-1
jquery.dynatable.js
static/js/jquery/jquery.dynatable.js
+2
-0
test_dyna_chart_and_table.js
static/js/test_dyna_chart_and_table.js
+55
-16
ngrams.html
templates/tests/ngrams.html
+6
-6
views.py
tests/ngramstable/views.py
+6
-3
No files found.
static/js/charts/dc.js
View file @
16b527f0
...
@@ -3447,4 +3447,4 @@ dc.bubbleOverlay = function(root, chartGroup) {
...
@@ -3447,4 +3447,4 @@ dc.bubbleOverlay = function(root, chartGroup) {
};
};
return
_chart
.
anchor
(
parent
,
chartGroup
);
return
_chart
.
anchor
(
parent
,
chartGroup
);
};
};
\ No newline at end of file
static/js/jquery/jquery.dynatable.js
View file @
16b527f0
...
@@ -951,8 +951,10 @@
...
@@ -951,8 +951,10 @@
};
};
this
.
clear
=
function
()
{
this
.
clear
=
function
()
{
settings
.
dataset
.
sorts
=
{};
settings
.
dataset
.
sorts
=
{};
settings
.
dataset
.
sortsKeys
.
length
=
0
;
settings
.
dataset
.
sortsKeys
.
length
=
0
;
settings
.
dataset
.
queries
=
{};
obj
.
$element
.
trigger
(
'dynatable:sorts:cleared'
);
obj
.
$element
.
trigger
(
'dynatable:sorts:cleared'
);
};
};
...
...
static/js/test_dyna_chart_and_table.js
View file @
16b527f0
...
@@ -235,19 +235,40 @@ function SelectAll( the_checkbox ) {
...
@@ -235,19 +235,40 @@ function SelectAll( the_checkbox ) {
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
}
function
Main
(
data
,
initial
)
{
function
Main
_test
(
data
,
initial
)
{
var
DistributionDict
=
{}
var
DistributionDict
=
{}
for
(
var
i
in
DistributionDict
)
for
(
var
i
in
DistributionDict
)
delete
DistributionDict
[
i
];
delete
DistributionDict
[
i
];
delete
DistributionDict
;
delete
DistributionDict
;
DistributionDict
=
{}
DistributionDict
=
{}
AjaxRecords
=
[]
AjaxRecords
=
[]
var
FirstScore
=
initial
;
var
FirstScore
=
initial
;
var
arrayd3
=
[]
var
arrayd3
=
[]
$
(
"#div-table"
).
html
(
""
)
$
(
"#div-table"
).
empty
();
var
div_table
=
'<p align="right">'
+
"
\n
"
div_table
+=
'<table id="my-ajax-table" class="table table-bordered">'
+
"
\n
"
div_table
+=
"
\
t"
+
'<thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="name">Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="del" data-dynatable-no-sort="true">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
"
\
t"
+
'<input type="checkbox" id="multiple_selection" onclick="SelectAll(this);" /> Select'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
'</thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
'<tbody>'
+
"
\n
"
div_table
+=
"
\
t"
+
'</tbody>'
+
"
\n
"
div_table
+=
'</table>'
+
"
\n
"
div_table
+=
'</p>'
;
$
(
"#div-table"
).
html
(
div_table
)
for
(
var
i
in
data
.
ngrams
)
{
for
(
var
i
in
data
.
ngrams
)
{
var
le_ngram
=
data
.
ngrams
[
i
]
var
le_ngram
=
data
.
ngrams
[
i
]
...
@@ -287,7 +308,13 @@ function Main( data , initial) {
...
@@ -287,7 +308,13 @@ function Main( data , initial) {
oldest
=
Number
(
min_occ
);
oldest
=
Number
(
min_occ
);
latest
=
Number
(
max_occ
);
latest
=
Number
(
max_occ
);
var
ndx
=
crossfilter
();
var
ndx
=
false
;
ndx
=
crossfilter
();
ndx
.
add
(
DistributionList
);
ndx
.
add
(
DistributionList
);
// x_occs = ndx.dimension(dc.pluck('x_occ'));
// x_occs = ndx.dimension(dc.pluck('x_occ'));
...
@@ -320,7 +347,8 @@ function Main( data , initial) {
...
@@ -320,7 +347,8 @@ function Main( data , initial) {
// .stack(y_frecs, function (d) {
// .stack(y_frecs, function (d) {
// return d.value;
// return d.value;
// })
// })
// .elasticY(true)
// .ordinalColors(d3.scale.category10())
.
elasticY
(
true
)
// .round(dc.round.floor)
// .round(dc.round.floor)
.
renderHorizontalGridLines
(
true
)
.
renderHorizontalGridLines
(
true
)
.
renderVerticalGridLines
(
true
)
.
renderVerticalGridLines
(
true
)
...
@@ -331,14 +359,13 @@ function Main( data , initial) {
...
@@ -331,14 +359,13 @@ function Main( data , initial) {
.
title
(
function
(
d
)
{
.
title
(
function
(
d
)
{
var
value
=
d
.
value
.
avg
?
d
.
value
.
avg
:
d
.
value
;
var
value
=
d
.
value
.
avg
?
d
.
value
.
avg
:
d
.
value
;
if
(
isNaN
(
value
))
value
=
0
;
if
(
isNaN
(
value
))
value
=
0
;
return
value
+
" ngrams with
occ
="
+
Number
(
d
.
key
);
return
value
+
" ngrams with
"
+
FirstScore
+
"
="
+
Number
(
d
.
key
);
})
})
.
xAxis
();
.
xAxis
();
LineChart
.
yAxis
().
ticks
(
5
)
LineChart
.
yAxis
().
ticks
(
5
)
LineChart
.
render
()
LineChart
.
render
()
volumeChart
.
width
(
800
)
volumeChart
.
width
(
800
)
.
height
(
100
)
.
height
(
100
)
.
margins
({
top
:
30
,
right
:
50
,
bottom
:
20
,
left
:
40
})
.
margins
({
top
:
30
,
right
:
50
,
bottom
:
20
,
left
:
40
})
...
@@ -346,8 +373,8 @@ function Main( data , initial) {
...
@@ -346,8 +373,8 @@ function Main( data , initial) {
.
group
(
y_frecs
)
.
group
(
y_frecs
)
.
centerBar
(
true
)
.
centerBar
(
true
)
.
gap
(
5
)
.
gap
(
5
)
.
x
(
d3
.
scale
.
linear
().
domain
([
min_occ
/
2
,
max_occ
]))
.
x
(
d3
.
scale
.
linear
().
domain
([
min_occ
/
2
,
max_occ
+
min_occ
]))
.
y
(
d3
.
scale
.
sqrt
().
domain
([
min_frec
/
2
,
max_frec
]))
.
y
(
d3
.
scale
.
sqrt
().
domain
([
min_frec
/
2
,
max_frec
+
min_frec
]))
// .elasticY(true)
// .elasticY(true)
// // .round(d3.time.month.round)
// // .round(d3.time.month.round)
// // .xUnits(d3.time.months)
// // .xUnits(d3.time.months)
...
@@ -374,6 +401,11 @@ function Main( data , initial) {
...
@@ -374,6 +401,11 @@ function Main( data , initial) {
volumeChart
.
yAxis
().
ticks
(
5
)
volumeChart
.
yAxis
().
ticks
(
5
)
volumeChart
.
render
()
volumeChart
.
render
()
LineChart
.
filterAll
();
volumeChart
.
filterAll
();
dc
.
redrawAll
();
MyTable
=
[]
MyTable
=
$
(
'#my-ajax-table'
).
dynatable
({
MyTable
=
$
(
'#my-ajax-table'
).
dynatable
({
dataset
:
{
dataset
:
{
records
:
AjaxRecords
records
:
AjaxRecords
...
@@ -388,14 +420,18 @@ function Main( data , initial) {
...
@@ -388,14 +420,18 @@ function Main( data , initial) {
}
}
});
});
// MyTable.data('dynatable').settings.dataset.records = []
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
=
[]
//
MyTable.data('dynatable').settings.dataset.originalRecords = []
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
originalRecords
=
AjaxRecords
;
//
MyTable.data('dynatable').settings.dataset.originalRecords = AjaxRecords;
MyTable
.
data
(
'dynatable'
).
paginationPage
.
set
(
1
);
MyTable
.
data
(
'dynatable'
).
paginationPage
.
set
(
1
);
// MyTable.data('dynatable').process();
// MyTable.data('dynatable').sorts.clear();
MyTable
.
data
(
'dynatable'
).
process
();
MyTable
.
data
(
'dynatable'
).
process
();
$
(
"#score_column_id"
).
children
()[
0
].
text
=
FirstScore
// // // $("#score_column_id").children()[0].text = FirstScore
// // // // MyTable.data('dynatable').process();
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
$
(
".dynatable-record-count"
).
insertAfter
(
".imadiv"
)
$
(
".dynatable-record-count"
).
insertAfter
(
".imadiv"
)
...
@@ -408,25 +444,28 @@ console.log(window.location.href+"/ngrams.json")
...
@@ -408,25 +444,28 @@ console.log(window.location.href+"/ngrams.json")
$
.
ajax
({
$
.
ajax
({
url
:
window
.
location
.
href
+
"/ngrams.json"
,
url
:
window
.
location
.
href
+
"/ngrams.json"
,
success
:
function
(
data
){
success
:
function
(
data
){
// Building the Score-Selector
var
FirstScore
=
data
.
scores
.
initial
var
FirstScore
=
data
.
scores
.
initial
var
possible_scores
=
Object
.
keys
(
data
.
ngrams
[
0
].
scores
);
var
possible_scores
=
Object
.
keys
(
data
.
ngrams
[
0
].
scores
);
var
scores_div
=
'<select id="scores_selector">'
+
"
\n
"
;
var
scores_div
=
'<select
class="span1"
id="scores_selector">'
+
"
\n
"
;
scores_div
+=
"
\
t"
+
'<option value="'
+
FirstScore
+
'">'
+
FirstScore
+
'</option>'
+
"
\n
"
scores_div
+=
"
\
t"
+
'<option value="'
+
FirstScore
+
'">'
+
FirstScore
+
'</option>'
+
"
\n
"
for
(
var
i
in
possible_scores
)
{
for
(
var
i
in
possible_scores
)
{
if
(
possible_scores
[
i
]
!=
FirstScore
)
{
if
(
possible_scores
[
i
]
!=
FirstScore
)
{
scores_div
+=
"
\
t"
+
'<option value="'
+
possible_scores
[
i
]
+
'">'
+
possible_scores
[
i
]
+
'</option>'
+
"
\n
"
scores_div
+=
"
\
t"
+
'<option value="'
+
possible_scores
[
i
]
+
'">'
+
possible_scores
[
i
]
+
'</option>'
+
"
\n
"
}
}
}
}
var
result
=
Main
(
data
,
FirstScore
)
// Initializing the Charts and Table
var
result
=
Main_test
(
data
,
FirstScore
)
console
.
log
(
result
)
console
.
log
(
result
)
// Listener for onchange Score-Selector
scores_div
+=
"<select>"
+
"
\n
"
;
scores_div
+=
"<select>"
+
"
\n
"
;
$
(
"#ScoresBox"
).
html
(
scores_div
)
$
(
"#ScoresBox"
).
html
(
scores_div
)
$
(
"#scores_selector"
).
on
(
'change'
,
function
()
{
$
(
"#scores_selector"
).
on
(
'change'
,
function
()
{
console
.
log
(
this
.
value
)
console
.
log
(
this
.
value
)
var
result
=
Main
(
data
,
this
.
value
)
var
result
=
Main
_test
(
data
,
this
.
value
)
console
.
log
(
result
)
console
.
log
(
result
)
});
});
...
...
templates/tests/ngrams.html
View file @
16b527f0
...
@@ -78,14 +78,14 @@ th a {
...
@@ -78,14 +78,14 @@ th a {
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
<div
id=
"monthly-move-chart"
>
<center>
<center>
<div
id=
"ScoresBox"
></div>
(Blue bars: all, Green line: zoom)
<div
id=
"ScoresBox"
></div>
<br>
(Blue bars: all, Green line: zoom)
<a
class=
"reset"
href=
"javascript:volumeChart.filterAll();dc.redrawAll();"
<a
class=
"reset"
href=
"javascript:volumeChart.filterAll();dc.redrawAll();"
style=
"display: none;"
>
reset
</a>
style=
"display: none;"
>
reset
</a>
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
</center>
</center>
</div>
<
div
id=
"monthly-move-chart"
><
/div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
...
@@ -111,10 +111,10 @@ th a {
...
@@ -111,10 +111,10 @@ th a {
</div>
</div>
<div
id=
"collapseOne"
class=
"panel-collapse collapse no-transition"
role=
"tabpanel"
>
<div
id=
"collapseOne"
class=
"panel-collapse collapse no-transition"
role=
"tabpanel"
>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<p
align=
"right"
>
<div
id=
"div-table"
></div>
<!-- <p align="right">
<table id="my-ajax-table" class="table table-bordered">
<table id="my-ajax-table" class="table table-bordered">
<thead>
<thead>
<!-- <th data-dynatable-column="id">ID</th> -->
<th data-dynatable-column="name">Title</th>
<th data-dynatable-column="name">Title</th>
<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>
<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>
<th data-dynatable-column="del" data-dynatable-no-sort="true">
<th data-dynatable-column="del" data-dynatable-no-sort="true">
...
@@ -124,7 +124,7 @@ th a {
...
@@ -124,7 +124,7 @@ th a {
<tbody>
<tbody>
</tbody>
</tbody>
</table>
</table>
</p>
</p>
-->
<p
align=
"right"
>
<p
align=
"right"
>
<button
id=
"move2trash"
class=
"btn btn-primary btn-lg"
>
Trash It!
</button>
<button
id=
"move2trash"
class=
"btn btn-primary btn-lg"
>
Trash It!
</button>
</p>
</p>
...
...
tests/ngramstable/views.py
View file @
16b527f0
...
@@ -199,7 +199,7 @@ def test_ngrams(request , project_id, corpus_id ):
...
@@ -199,7 +199,7 @@ def test_ngrams(request , project_id, corpus_id ):
ngrams_ids
=
Ngrams_Scores
.
keys
()
ngrams_ids
=
Ngrams_Scores
.
keys
()
import
math
import
math
occs_threshold
=
m
ath
.
sqrt
(
Sum
/
len
(
ngrams_ids
)
)
occs_threshold
=
m
in
(
10
,
math
.
sqrt
(
Sum
/
len
(
ngrams_ids
))
)
Metrics
=
{
Metrics
=
{
"ngrams"
:[],
"ngrams"
:[],
...
@@ -210,15 +210,18 @@ def test_ngrams(request , project_id, corpus_id ):
...
@@ -210,15 +210,18 @@ def test_ngrams(request , project_id, corpus_id ):
query
=
session
.
query
(
Ngram
)
.
filter
(
Ngram
.
id
.
in_
(
ngrams_ids
))
query
=
session
.
query
(
Ngram
)
.
filter
(
Ngram
.
id
.
in_
(
ngrams_ids
))
ngrams_data
=
query
.
all
()
ngrams_data
=
query
.
all
()
for
ngram
in
ngrams_data
:
for
ngram
in
ngrams_data
:
if
Ngrams_Scores
[
ngram
.
id
][
"scores"
][
"occ_uniq"
]
>
occs_threshold
:
occ_uniq
=
Ngrams_Scores
[
ngram
.
id
][
"scores"
][
"occ_uniq"
]
if
occ_uniq
>
occs_threshold
:
Ngrams_Scores
[
ngram
.
id
][
"name"
]
=
ngram
.
terms
Ngrams_Scores
[
ngram
.
id
][
"name"
]
=
ngram
.
terms
Ngrams_Scores
[
ngram
.
id
][
"id"
]
=
ngram
.
id
Ngrams_Scores
[
ngram
.
id
][
"id"
]
=
ngram
.
id
Ngrams_Scores
[
ngram
.
id
][
"scores"
][
"tfidf"
]
=
Ngrams_Scores
[
ngram
.
id
][
"scores"
][
"tfidf_sum"
]
/
occ_uniq
del
Ngrams_Scores
[
ngram
.
id
][
"scores"
][
"tfidf_sum"
]
Metrics
[
"ngrams"
]
.
append
(
Ngrams_Scores
[
ngram
.
id
]
)
Metrics
[
"ngrams"
]
.
append
(
Ngrams_Scores
[
ngram
.
id
]
)
Metrics
[
"scores"
]
=
{
Metrics
[
"scores"
]
=
{
"initial"
:
"occ_
sum
"
,
"initial"
:
"occ_
uniq
"
,
"nb_docs"
:
len
(
documents
),
"nb_docs"
:
len
(
documents
),
"orig_nb_ngrams"
:
len
(
ngrams_ids
),
"orig_nb_ngrams"
:
len
(
ngrams_ids
),
"nb_ngrams"
:
len
(
Metrics
[
"ngrams"
]),
"nb_ngrams"
:
len
(
Metrics
[
"ngrams"
]),
...
...
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