Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
82f87a91
Commit
82f87a91
authored
Apr 09, 2013
by
Valera Rozuvan
Committed by
Vasyl Nakvasiuk
May 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rough version of d3 word cloud.
parent
acfbe14e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
3 deletions
+74
-3
common/lib/xmodule/xmodule/js/src/word_cloud/d3.layout.cloud.js
+0
-0
common/lib/xmodule/xmodule/js/src/word_cloud/d3.min.js
+0
-0
common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js
+72
-3
common/lib/xmodule/xmodule/word_cloud_module.py
+2
-0
No files found.
common/lib/xmodule/xmodule/js/src/word_cloud/d3.layout.cloud.js
0 → 100644
View file @
82f87a91
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/js/src/word_cloud/d3.min.js
0 → 100644
View file @
82f87a91
This source diff could not be displayed because it is too large. You can
view the blob
instead.
common/lib/xmodule/xmodule/js/src/word_cloud/word_cloud_main.js
View file @
82f87a91
(
function
(
requirejs
,
require
,
define
)
{
(
function
(
requirejs
,
require
,
define
)
{
define
(
'WordCloudMain'
,
[
'logme'
],
function
(
logme
)
{
define
(
'WordCloudMain'
,
[
'logme'
],
function
(
logme
)
{
var
hash
=
0
;
WordCloudMain
.
prototype
=
{
WordCloudMain
.
prototype
=
{
'submitAnswer'
:
function
()
{
'submitAnswer'
:
function
()
{
...
@@ -36,16 +38,62 @@ WordCloudMain.prototype = {
...
@@ -36,16 +38,62 @@ WordCloudMain.prototype = {
},
// End-of: 'submitAnswer': function (answer, answerEl) {
},
// End-of: 'submitAnswer': function (answer, answerEl) {
'showWordCloud'
:
function
(
response
){
'showWordCloud'
:
function
(
response
){
var
words
,
_this
=
this
,
fill
=
d3
.
scale
.
category20
();
console
.
log
(
'Show word cloud with next:'
);
console
.
log
(
'Show word cloud with next:'
);
console
.
log
(
response
);
console
.
log
(
response
);
inputSection
=
this
.
wordCloudEl
.
find
(
'#input-cloud-section'
);
inputSection
=
this
.
wordCloudEl
.
find
(
'#input-cloud-section'
);
resultSection
=
this
.
wordCloudEl
.
find
(
'#result-cloud-section'
);
resultSection
=
this
.
wordCloudEl
.
find
(
'#result-cloud-section'
);
resultSection
.
text
(
'TODO: Word cloud canvas'
);
resultSection
.
text
(
'TODO: Word cloud canvas'
);
inputSection
.
hide
();
inputSection
.
hide
();
resultSection
.
show
();
resultSection
.
show
();
},
words
=
response
.
top_words
;
d3
.
layout
.
cloud
().
size
([
5
,
5
])
.
words
(
words
)
.
rotate
(
function
()
{
return
~~
(
Math
.
random
()
*
2
)
*
90
;
})
.
font
(
'Impact'
)
.
fontSize
(
function
(
d
)
{
return
d
.
size
;
})
.
on
(
'end'
,
draw
)
.
start
();
// End of executable code.
return
;
function
draw
(
words
)
{
d3
.
select
(
'.word_cloud_d3_'
+
_this
.
hash
).
append
(
'svg'
)
.
attr
(
'width'
,
500
)
.
attr
(
'height'
,
500
)
.
append
(
'g'
)
// .attr('transform', 'translate(125,125)')
.
selectAll
(
'text'
)
.
data
(
words
)
.
enter
().
append
(
'text'
)
.
style
(
'font-size'
,
function
(
d
)
{
return
d
.
size
+
'px'
;
})
.
style
(
'font-family'
,
'Impact'
)
.
style
(
'fill'
,
function
(
d
,
i
)
{
return
fill
(
i
);
})
.
attr
(
'text-anchor'
,
'middle'
)
.
attr
(
'transform'
,
function
(
d
)
{
return
'translate('
+
[
d
.
x
,
d
.
y
]
+
')rotate('
+
d
.
rotate
+
')'
;
})
.
text
(
function
(
d
)
{
return
d
.
text
;
});
}
}
};
// End-of: WordCloudMain.prototype = {
};
// End-of: WordCloudMain.prototype = {
...
@@ -53,6 +101,7 @@ return WordCloudMain;
...
@@ -53,6 +101,7 @@ return WordCloudMain;
function
WordCloudMain
(
el
)
{
function
WordCloudMain
(
el
)
{
var
_this
;
var
_this
;
this
.
wordCloudEl
=
$
(
el
).
find
(
'.word_cloud'
);
this
.
wordCloudEl
=
$
(
el
).
find
(
'.word_cloud'
);
if
(
this
.
wordCloudEl
.
length
!==
1
)
{
if
(
this
.
wordCloudEl
.
length
!==
1
)
{
// We require one question DOM element.
// We require one question DOM element.
...
@@ -61,6 +110,26 @@ function WordCloudMain(el) {
...
@@ -61,6 +110,26 @@ function WordCloudMain(el) {
return
;
return
;
}
}
hash
+=
1
;
this
.
hash
=
hash
;
this
.
wordCloudEl
.
addClass
(
'word_cloud_d3_'
+
this
.
hash
);
this
.
configJson
=
null
;
try
{
this
.
configJson
=
JSON
.
parse
(
this
.
wordCloudEl
.
find
(
'.word_cloud_div'
).
html
());
}
catch
(
err
)
{
logme
(
'ERROR: Incorrect JSON config was given.'
);
logme
(
err
.
message
);
return
;
}
if
(
this
.
configJson
.
hasOwnProperty
(
'status'
)
&&
this
.
configJson
.
status
===
'success'
)
{
this
.
showWordCloud
(
this
.
configJson
);
return
;
}
this
.
inputSaveEl
=
$
(
el
).
find
(
'input.save'
);
this
.
inputSaveEl
=
$
(
el
).
find
(
'input.save'
);
// Get the URL to which we will post the users words.
// Get the URL to which we will post the users words.
...
...
common/lib/xmodule/xmodule/word_cloud_module.py
View file @
82f87a91
...
@@ -44,6 +44,8 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -44,6 +44,8 @@ class WordCloudModule(WordCloudFields, XModule):
js
=
{
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/src/javascript_loader.coffee'
)],
'coffee'
:
[
resource_string
(
__name__
,
'js/src/javascript_loader.coffee'
)],
'js'
:
[
resource_string
(
__name__
,
'js/src/word_cloud/logme.js'
),
'js'
:
[
resource_string
(
__name__
,
'js/src/word_cloud/logme.js'
),
resource_string
(
__name__
,
'js/src/word_cloud/d3.min.js'
),
resource_string
(
__name__
,
'js/src/word_cloud/d3.layout.cloud.js'
),
resource_string
(
__name__
,
'js/src/word_cloud/word_cloud.js'
),
resource_string
(
__name__
,
'js/src/word_cloud/word_cloud.js'
),
resource_string
(
__name__
,
'js/src/word_cloud/word_cloud_main.js'
)]
resource_string
(
__name__
,
'js/src/word_cloud/word_cloud_main.js'
)]
}
}
...
...
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