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
570dfabf
Commit
570dfabf
authored
Feb 25, 2015
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed Context Finding for Axis Formatters
parent
e571e7f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
25 deletions
+22
-25
analytics_dashboard/static/js/views/bar-view.js
+19
-23
analytics_dashboard/static/js/views/chart-view.js
+2
-1
bower.json
+1
-1
No files found.
analytics_dashboard/static/js/views/bar-view.js
View file @
570dfabf
...
@@ -20,7 +20,7 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
...
@@ -20,7 +20,7 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
*
*
* This is called for both display labels beneath the bars and in tooltips.
* This is called for both display labels beneath the bars and in tooltips.
*/
*/
formatXValue
:
function
(
xValue
)
{
formatXValue
:
function
(
xValue
)
{
var
self
=
this
,
var
self
=
this
,
trend
=
self
.
options
.
trends
[
0
],
trend
=
self
.
options
.
trends
[
0
],
maxNumber
=
trend
.
maxNumber
;
maxNumber
=
trend
.
maxNumber
;
...
@@ -38,37 +38,33 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
...
@@ -38,37 +38,33 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
/**
/**
* Returns function for displaying a truncated label.
* Returns function for displaying a truncated label.
*/
*/
truncateXTick
Func
:
function
(
)
{
truncateXTick
:
function
(
d
)
{
var
self
=
this
;
var
self
=
this
;
d
=
self
.
formatXValue
(
d
);
return
function
(
d
)
{
var
barWidth
=
d3
.
select
(
self
.
options
.
barSelector
).
attr
(
'width'
),
// jshint ignore:line
// this is a rough estimate of how wide a character is
chartWidth
=
5
,
characterLimit
=
Math
.
floor
(
barWidth
/
chartWidth
),
formattedLabel
=
d
;
d
=
self
.
formatXValue
(
d
);
if
(
_
(
formattedLabel
).
size
()
>
characterLimit
)
{
formattedLabel
=
Utils
.
truncateText
(
d
,
characterLimit
);
var
barWidth
=
d3
.
select
(
self
.
options
.
barSelector
).
attr
(
'width'
),
// jshint ignore:line
}
// this is a rough estimate of how wide a character is
chartWidth
=
5
,
characterLimit
=
Math
.
floor
(
barWidth
/
chartWidth
),
formattedLabel
=
d
;
if
(
_
(
formattedLabel
).
size
()
>
characterLimit
)
{
formattedLabel
=
Utils
.
truncateText
(
d
,
characterLimit
);
}
return
formattedLabel
;
return
formattedLabel
;
};
},
},
addChartClick
:
function
()
{
addChartClick
:
function
()
{
var
self
=
this
;
var
self
=
this
;
d3
.
selectAll
(
'rect.nv-bar'
)
d3
.
selectAll
(
'rect.nv-bar'
)
.
style
(
'cursor'
,
'pointer'
)
.
style
(
'cursor'
,
'pointer'
)
.
on
(
'click'
,
function
(
d
)
{
.
on
(
'click'
,
function
(
d
)
{
self
.
options
.
click
(
d
);
self
.
options
.
click
(
d
);
});
});
},
},
buildTrendTip
:
function
(
trend
,
x
,
y
,
e
)
{
buildTrendTip
:
function
(
trend
,
x
,
y
,
e
)
{
var
self
=
this
,
var
self
=
this
,
swatchColor
=
trend
.
color
,
// e.g #ff9988 or a function
swatchColor
=
trend
.
color
,
// e.g #ff9988 or a function
label
=
trend
.
title
;
// e.g. 'my title' or a function
label
=
trend
.
title
;
// e.g. 'my title' or a function
...
@@ -101,7 +97,7 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
...
@@ -101,7 +97,7 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
/**
/**
* Builds the header for the interactive tooltip.
* Builds the header for the interactive tooltip.
*/
*/
buildTipHeading
:
function
(
point
)
{
buildTipHeading
:
function
(
point
)
{
var
self
=
this
,
var
self
=
this
,
heading
=
self
.
formatXValue
(
point
[
self
.
options
.
x
.
key
]),
heading
=
self
.
formatXValue
(
point
[
self
.
options
.
x
.
key
]),
charLimit
=
self
.
options
.
tipCharLimit
;
charLimit
=
self
.
options
.
tipCharLimit
;
...
@@ -120,14 +116,14 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
...
@@ -120,14 +116,14 @@ define(['d3', 'nvd3', 'underscore', 'utils/utils', 'views/chart-view'],
return
heading
;
return
heading
;
},
},
initChart
:
function
(
chart
)
{
initChart
:
function
(
chart
)
{
var
self
=
this
;
var
self
=
this
;
ChartView
.
prototype
.
initChart
.
call
(
self
,
chart
);
ChartView
.
prototype
.
initChart
.
call
(
self
,
chart
);
// NVD3's bar views display tooltips differently than for graphs
// NVD3's bar views display tooltips differently than for graphs
chart
.
tooltipContent
(
function
(
key
,
x
,
y
,
e
)
{
chart
.
tooltipContent
(
function
(
key
,
x
,
y
,
e
)
{
var
trend
=
self
.
options
.
trends
[
e
.
seriesIndex
],
var
trend
=
self
.
options
.
trends
[
e
.
seriesIndex
],
// 'e' contains the raw x-value and 'x' could be formatted (e.g. truncated, ellipse, etc.)
// 'e' contains the raw x-value and 'x' could be formatted (e.g. truncated, ellipse, etc.)
tips
=
[
self
.
buildTrendTip
(
trend
,
x
,
y
,
e
)];
tips
=
[
self
.
buildTrendTip
(
trend
,
x
,
y
,
e
)];
return
self
.
hoverTooltipTemplate
({
return
self
.
hoverTooltipTemplate
({
...
...
analytics_dashboard/static/js/views/chart-view.js
View file @
570dfabf
...
@@ -22,6 +22,7 @@ define(['d3', 'jquery', 'nvd3', 'underscore', 'utils/utils', 'views/attribute-li
...
@@ -22,6 +22,7 @@ define(['d3', 'jquery', 'nvd3', 'underscore', 'utils/utils', 'views/attribute-li
var
self
=
this
;
var
self
=
this
;
self
.
chart
=
null
;
self
.
chart
=
null
;
self
.
options
=
_
.
extend
({},
self
.
defaults
,
options
);
self
.
options
=
_
.
extend
({},
self
.
defaults
,
options
);
_
.
bindAll
(
this
,
'truncateXTick'
,
'formatXTick'
);
self
.
renderIfDataAvailable
();
self
.
renderIfDataAvailable
();
},
},
...
@@ -254,7 +255,7 @@ define(['d3', 'jquery', 'nvd3', 'underscore', 'utils/utils', 'views/attribute-li
...
@@ -254,7 +255,7 @@ define(['d3', 'jquery', 'nvd3', 'underscore', 'utils/utils', 'views/attribute-li
}
}
}
}
self
.
chart
.
xAxis
.
tickFormat
(
self
.
options
.
truncateXTicks
?
self
.
truncateXTick
Func
()
:
self
.
formatXTick
);
self
.
chart
.
xAxis
.
tickFormat
(
self
.
options
.
truncateXTicks
?
self
.
truncateXTick
:
self
.
formatXTick
);
self
.
chart
.
yAxis
self
.
chart
.
yAxis
.
showMaxMin
(
false
)
.
showMaxMin
(
false
)
...
...
bower.json
View file @
570dfabf
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
"bootstrap-sass-official"
:
"v3.2.0+2"
,
"bootstrap-sass-official"
:
"v3.2.0+2"
,
"jquery"
:
"~1.11.1"
,
"jquery"
:
"~1.11.1"
,
"bootstrapaccessibilityplugin"
:
"~1.0.3"
,
"bootstrapaccessibilityplugin"
:
"~1.0.3"
,
"underscore"
:
"~1.
7.0
"
,
"underscore"
:
"~1.
8.2
"
,
"backbone"
:
"~1.1.2"
,
"backbone"
:
"~1.1.2"
,
"d3"
:
"~3.3.13"
,
"d3"
:
"~3.3.13"
,
"requirejs"
:
"~2.1.15"
,
"requirejs"
:
"~2.1.15"
,
...
...
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