Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-dashboard
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-analytics-dashboard
Commits
e7b99ff5
Commit
e7b99ff5
authored
Nov 07, 2014
by
Dennis Jen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #189 from edx/dsjen/demographic-tooltips
Updated charting tooltips to include header and updated labels.
parents
90cb48ad
8b25011f
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
85 additions
and
69 deletions
+85
-69
analytics_dashboard/static/js/engagement-content-main.js
+3
-4
analytics_dashboard/static/js/enrollment-demographics-age-main.js
+6
-4
analytics_dashboard/static/js/enrollment-demographics-education-main.js
+6
-5
analytics_dashboard/static/js/enrollment-demographics-gender-main.js
+6
-5
analytics_dashboard/static/js/views/bar-view.js
+46
-0
analytics_dashboard/static/js/views/chart-view.js
+0
-7
analytics_dashboard/static/js/views/discrete-bar-view.js
+6
-24
analytics_dashboard/static/js/views/histogram-view.js
+4
-20
analytics_dashboard/static/js/views/trends-view.js
+8
-0
No files found.
analytics_dashboard/static/js/engagement-content-main.js
View file @
e7b99ff5
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
'use strict'
;
'use strict'
;
require
([
'
views/data-table-view'
,
'views/trends-view'
],
function
(
DataTableView
,
TrendsView
)
{
require
([
'
underscore'
,
'views/data-table-view'
,
'views/trends-view'
],
function
(
_
,
DataTableView
,
TrendsView
)
{
// shared settings between the chart and table
// shared settings between the chart and table
// colors are chosen to be color-blind accessible
// colors are chosen to be color-blind accessible
var
settings
=
[
var
settings
=
[
...
@@ -72,9 +72,8 @@ require(['vendor/domReady!', 'load/init-page'], function (doc, page) {
...
@@ -72,9 +72,8 @@ require(['vendor/domReady!', 'load/init-page'], function (doc, page) {
title
:
'Students'
,
title
:
'Students'
,
key
:
'count'
key
:
'count'
},
},
tooltip
:
gettext
(
'The number of active students, and the number of students who engaged in specific activities, over time.'
),
// jshint ignore:line
// Translators: <%=value%> will be replaced with a date.
// Translators: %(value)s will be replaced with a date.
interactiveTooltipHeaderTemplate
:
_
.
template
(
gettext
(
'Week Ending <%=value%>'
))
interactiveTooltipHeader
:
gettext
(
'Week Ending %(value)s'
)
});
});
// weekly engagement activities table
// weekly engagement activities table
...
...
analytics_dashboard/static/js/enrollment-demographics-age-main.js
View file @
e7b99ff5
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
'use strict'
;
'use strict'
;
require
([
'views/data-table-view'
,
'views/histogram-view'
],
require
([
'
underscore'
,
'
views/data-table-view'
,
'views/histogram-view'
],
function
(
DataTableView
,
HistogramView
)
{
function
(
_
,
DataTableView
,
HistogramView
)
{
// used in the table to show ages above this are binned--displayed as "100+"
// used in the table to show ages above this are binned--displayed as "100+"
var
maxNumber
=
100
;
var
maxNumber
=
100
;
...
@@ -18,12 +18,14 @@ require(['vendor/domReady!', 'load/init-page'], function(doc, page) {
...
@@ -18,12 +18,14 @@ require(['vendor/domReady!', 'load/init-page'], function(doc, page) {
modelAttribute
:
'ages'
,
modelAttribute
:
'ages'
,
excludeData
:
[
'Unknown'
],
excludeData
:
[
'Unknown'
],
trends
:
[{
trends
:
[{
title
:
gettext
(
'Students'
),
title
:
gettext
(
'
Number of
Students'
),
color
:
'rgb(58, 162, 224)'
,
color
:
'rgb(58, 162, 224)'
,
maxNumber
:
maxNumber
maxNumber
:
maxNumber
}],
}],
x
:
{
key
:
'age'
},
x
:
{
key
:
'age'
},
y
:
{
key
:
'count'
}
y
:
{
key
:
'count'
},
// Translators: <%=value%> will be replaced with an age.
interactiveTooltipHeaderTemplate
:
_
.
template
(
gettext
(
'Age: <%=value%>'
))
});
});
new
DataTableView
({
new
DataTableView
({
...
...
analytics_dashboard/static/js/enrollment-demographics-education-main.js
View file @
e7b99ff5
...
@@ -6,9 +6,8 @@
...
@@ -6,9 +6,8 @@
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
'use strict'
;
'use strict'
;
require
([
'views/data-table-view'
,
require
([
'underscore'
,
'views/data-table-view'
,
'views/discrete-bar-view'
],
'views/discrete-bar-view'
],
function
(
_
,
DataTableView
,
DiscreteBarView
)
{
function
(
DataTableView
,
DiscreteBarView
)
{
new
DiscreteBarView
({
new
DiscreteBarView
({
el
:
'#enrollment-chart-view'
,
el
:
'#enrollment-chart-view'
,
...
@@ -17,11 +16,13 @@ require(['vendor/domReady!', 'load/init-page'], function(doc, page) {
...
@@ -17,11 +16,13 @@ require(['vendor/domReady!', 'load/init-page'], function(doc, page) {
excludeData
:
[
'Unknown'
],
excludeData
:
[
'Unknown'
],
dataType
:
'percent'
,
dataType
:
'percent'
,
trends
:
[{
trends
:
[{
title
:
gettext
(
'
Education
'
),
title
:
gettext
(
'
Percentage
'
),
color
:
'rgb(58, 162, 224)'
color
:
'rgb(58, 162, 224)'
}],
}],
x
:
{
key
:
'educationLevel'
},
x
:
{
key
:
'educationLevel'
},
y
:
{
key
:
'percent'
}
y
:
{
key
:
'percent'
},
// Translators: <%=value%> will be replaced with a level of education (e.g. Doctorate).
interactiveTooltipHeaderTemplate
:
_
.
template
(
gettext
(
'Education: <%=value%>'
))
});
});
new
DataTableView
({
new
DataTableView
({
...
...
analytics_dashboard/static/js/enrollment-demographics-gender-main.js
View file @
e7b99ff5
...
@@ -6,9 +6,8 @@
...
@@ -6,9 +6,8 @@
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
require
([
'vendor/domReady!'
,
'load/init-page'
],
function
(
doc
,
page
)
{
'use strict'
;
'use strict'
;
require
([
'views/data-table-view'
,
require
([
'underscore'
,
'views/data-table-view'
,
'views/discrete-bar-view'
],
'views/discrete-bar-view'
],
function
(
_
,
DataTableView
,
DiscreteBarView
)
{
function
(
DataTableView
,
DiscreteBarView
)
{
new
DiscreteBarView
({
new
DiscreteBarView
({
el
:
'#enrollment-chart-view'
,
el
:
'#enrollment-chart-view'
,
...
@@ -16,11 +15,13 @@ require(['vendor/domReady!', 'load/init-page'], function(doc, page) {
...
@@ -16,11 +15,13 @@ require(['vendor/domReady!', 'load/init-page'], function(doc, page) {
modelAttribute
:
'genders'
,
modelAttribute
:
'genders'
,
dataType
:
'percent'
,
dataType
:
'percent'
,
trends
:
[{
trends
:
[{
title
:
gettext
(
'
Gender
'
),
title
:
gettext
(
'
Percentage
'
),
color
:
'rgb(58, 162, 224)'
color
:
'rgb(58, 162, 224)'
}],
}],
x
:
{
key
:
'gender'
},
x
:
{
key
:
'gender'
},
y
:
{
key
:
'percent'
}
y
:
{
key
:
'percent'
},
// Translators: <%=value%> will be replaced with a level of gender (e.g. Female).
interactiveTooltipHeaderTemplate
:
_
.
template
(
gettext
(
'Gender: <%=value%>'
))
});
});
// Daily enrollment table
// Daily enrollment table
...
...
analytics_dashboard/static/js/views/bar-view.js
0 → 100644
View file @
e7b99ff5
/**
* Abstract class for NVD3 bar charts (includes discrete bar and histogram).
*/
define
([
'nvd3'
,
'underscore'
,
'views/chart-view'
],
function
(
nvd3
,
_
,
ChartView
)
{
'use strict'
;
var
BarView
=
ChartView
.
extend
({
defaults
:
_
.
extend
({},
ChartView
.
prototype
.
defaults
,
{
graphShiftSelector
:
'.nv-barsWrap'
}
),
initChart
:
function
(
chart
)
{
var
self
=
this
;
ChartView
.
prototype
.
initChart
.
call
(
self
,
chart
);
// NVD3's bar views display tooltips differently than for graphs
chart
.
tooltipContent
(
function
(
key
,
x
,
y
)
{
var
maxNumber
=
self
.
options
.
trends
[
0
].
maxNumber
,
xValue
=
x
;
if
(
!
_
(
maxNumber
).
isUndefined
)
{
// e.g. 100+
xValue
=
x
>=
maxNumber
?
maxNumber
+
'+'
:
x
;
}
if
(
_
(
self
.
options
).
has
(
'interactiveTooltipHeaderTemplate'
))
{
xValue
=
self
.
options
.
interactiveTooltipHeaderTemplate
({
value
:
xValue
});
}
return
self
.
hoverTooltipTemplate
({
xValue
:
xValue
,
label
:
key
,
yValue
:
y
,
swatchColor
:
self
.
options
.
trends
[
0
].
color
});
});
}
});
return
BarView
;
}
);
analytics_dashboard/static/js/views/chart-view.js
View file @
e7b99ff5
...
@@ -217,13 +217,6 @@ define(['d3', 'jquery', 'nvd3', 'underscore', 'utils/utils', 'views/attribute-li
...
@@ -217,13 +217,6 @@ define(['d3', 'jquery', 'nvd3', 'underscore', 'utils/utils', 'views/attribute-li
.
tickFormat
(
Utils
.
localizeNumber
);
.
tickFormat
(
Utils
.
localizeNumber
);
self
.
chart
.
yAxis
.
tickFormat
(
self
.
getYAxisFormat
());
self
.
chart
.
yAxis
.
tickFormat
(
self
.
getYAxisFormat
());
if
(
_
(
self
.
options
).
has
(
'interactiveTooltipHeader'
))
{
self
.
chart
.
interactiveLayer
.
tooltip
.
headerFormatter
(
function
(
d
)
{
// interpolate is a global django function
return
interpolate
(
self
.
options
.
interactiveTooltipHeader
,
{
value
:
d
},
true
);
// jshint ignore:line
});
}
// Append the svg to an inner container so that it adapts to
// Append the svg to an inner container so that it adapts to
// the height of the inner container instead of the outer
// the height of the inner container instead of the outer
// container which needs to create height for the title.
// container which needs to create height for the title.
...
...
analytics_dashboard/static/js/views/discrete-bar-view.js
View file @
e7b99ff5
define
([
'nvd3'
,
'underscore'
,
'views/
chart
-view'
],
define
([
'nvd3'
,
'underscore'
,
'views/
bar
-view'
],
function
(
nvd3
,
_
,
Chart
View
)
{
function
(
nvd3
,
_
,
Bar
View
)
{
'use strict'
;
'use strict'
;
var
DiscreteBarView
=
Chart
View
.
extend
({
var
DiscreteBarView
=
Bar
View
.
extend
({
defaults
:
_
.
extend
({},
Chart
View
.
prototype
.
defaults
,
{
defaults
:
_
.
extend
({},
Bar
View
.
prototype
.
defaults
,
{
// unsetting because this view will always display all x-ticks
// unsetting because this view will always display all x-ticks
displayExplicitTicksThreshold
:
undefined
,
displayExplicitTicksThreshold
:
undefined
graphShiftSelector
:
'.nv-barsWrap'
}
}
),
),
...
@@ -17,28 +16,11 @@ define(['nvd3', 'underscore', 'views/chart-view'],
...
@@ -17,28 +16,11 @@ define(['nvd3', 'underscore', 'views/chart-view'],
initChart
:
function
(
chart
)
{
initChart
:
function
(
chart
)
{
var
self
=
this
;
var
self
=
this
;
Chart
View
.
prototype
.
initChart
.
call
(
self
,
chart
);
Bar
View
.
prototype
.
initChart
.
call
(
self
,
chart
);
if
(
_
(
self
.
options
.
trends
[
0
]).
has
(
'color'
))
{
if
(
_
(
self
.
options
.
trends
[
0
]).
has
(
'color'
))
{
chart
.
color
([
self
.
options
.
trends
[
0
].
color
]);
chart
.
color
([
self
.
options
.
trends
[
0
].
color
]);
}
}
chart
.
tooltipContent
(
function
(
key
,
x
,
y
)
{
var
maxNumber
=
self
.
options
.
trends
[
0
].
maxNumber
,
xValue
=
x
;
if
(
!
_
(
maxNumber
).
isUndefined
)
{
// e.g. 100+
xValue
=
x
>=
maxNumber
?
maxNumber
+
'+'
:
x
;
}
return
self
.
hoverTooltipTemplate
({
xValue
:
xValue
,
label
:
key
,
yValue
:
y
,
swatchColor
:
self
.
options
.
trends
[
0
].
color
});
});
}
}
});
});
...
...
analytics_dashboard/static/js/views/histogram-view.js
View file @
e7b99ff5
define
([
'nvd3'
,
'underscore'
,
'views/
chart
-view'
],
define
([
'nvd3'
,
'underscore'
,
'views/
bar
-view'
],
function
(
nvd3
,
_
,
Chart
View
)
{
function
(
nvd3
,
_
,
Bar
View
)
{
'use strict'
;
'use strict'
;
var
HistogramView
=
ChartView
.
extend
({
var
HistogramView
=
BarView
.
extend
({
defaults
:
_
.
extend
({},
ChartView
.
prototype
.
defaults
,
{
graphShiftSelector
:
'.nv-barsWrap'
}
),
getChart
:
function
()
{
getChart
:
function
()
{
return
nvd3
.
models
.
multiBarChart
();
return
nvd3
.
models
.
multiBarChart
();
},
},
initChart
:
function
(
chart
)
{
initChart
:
function
(
chart
)
{
ChartView
.
prototype
.
initChart
.
call
(
this
,
chart
);
BarView
.
prototype
.
initChart
.
call
(
this
,
chart
);
var
self
=
this
;
chart
.
showLegend
(
false
);
chart
.
showLegend
(
false
);
chart
.
multibar
.
stacked
(
true
);
chart
.
multibar
.
stacked
(
true
);
chart
.
showControls
(
false
);
chart
.
showControls
(
false
);
chart
.
tooltip
(
function
(
key
,
x
,
y
)
{
var
maxNumber
=
self
.
options
.
trends
[
0
].
maxNumber
;
return
self
.
hoverTooltipTemplate
({
xValue
:
x
>=
maxNumber
?
maxNumber
+
'+'
:
x
,
// e.g. 100+
label
:
key
,
yValue
:
y
,
swatchColor
:
self
.
options
.
trends
[
0
].
color
});
});
}
}
});
});
...
...
analytics_dashboard/static/js/views/trends-view.js
View file @
e7b99ff5
...
@@ -10,8 +10,16 @@ define(['moment', 'nvd3', 'underscore', 'views/chart-view'],
...
@@ -10,8 +10,16 @@ define(['moment', 'nvd3', 'underscore', 'views/chart-view'],
initChart
:
function
(
chart
)
{
initChart
:
function
(
chart
)
{
ChartView
.
prototype
.
initChart
.
call
(
this
,
chart
);
ChartView
.
prototype
.
initChart
.
call
(
this
,
chart
);
var
self
=
this
;
chart
.
showLegend
(
false
)
chart
.
showLegend
(
false
)
.
useInteractiveGuideline
(
true
);
.
useInteractiveGuideline
(
true
);
if
(
_
(
self
.
options
).
has
(
'interactiveTooltipHeaderTemplate'
))
{
self
.
chart
.
interactiveLayer
.
tooltip
.
headerFormatter
(
function
(
d
)
{
return
self
.
options
.
interactiveTooltipHeaderTemplate
({
value
:
d
});
});
}
},
},
formatXTick
:
function
(
d
)
{
formatXTick
:
function
(
d
)
{
...
...
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