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
46de7b2c
Commit
46de7b2c
authored
Dec 11, 2012
by
Valera Rozuvan
Committed by
Alexander Kryklia
Jan 15, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added config options for number of points and xrange - start, end, step.
parent
4265bf17
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
22 deletions
+49
-22
common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js
+49
-22
No files found.
common/lib/xmodule/xmodule/js/src/graphical_slider_tool/graph.js
View file @
46de7b2c
...
...
@@ -2,14 +2,12 @@
// define() functions from Require JS available inside the anonymous function.
(
function
(
requirejs
,
require
,
define
)
{
define
(
'Graph'
,
[
'logme'
],
function
(
logme
)
{
define
(
'Graph'
,
[
],
function
(
)
{
return
Graph
;
function
Graph
(
gstId
,
config
,
state
)
{
var
plotDiv
,
dataSeries
,
functions
,
xaxis
,
yaxis
;
logme
(
'config:'
,
config
);
var
plotDiv
,
dataSeries
,
functions
,
xaxis
,
yaxis
,
xrange
;
plotDiv
=
$
(
'#'
+
gstId
+
'_plot'
);
...
...
@@ -19,6 +17,7 @@ define('Graph', ['logme'], function (logme) {
setGraphDimensions
();
setGraphAxes
();
setGraphXRange
();
state
.
bindUpdatePlotEvent
(
plotDiv
,
onUpdatePlot
);
...
...
@@ -30,27 +29,25 @@ define('Graph', ['logme'], function (logme) {
return
;
function
setGraphDimensions
()
{
var
dimObj
,
width
,
height
;
var
dimObj
,
width
,
height
,
tempInt
;
// If no dimensions are specified by the user, the graph have
// predefined dimensions.
width
=
3
00
;
height
=
3
00
;
width
=
1
00
;
height
=
1
00
;
// Get the user specified dimensions, if any.
if
(
$
.
isPlainObject
(
config
.
plot
[
'dimensions'
])
===
true
)
{
dimObj
=
config
.
plot
[
'dimensions'
];
if
(
dimObj
.
hasOwnProperty
(
'@width'
)
===
true
)
{
if
(
isNaN
(
parseInt
(
dimObj
[
'@width'
],
10
))
===
false
)
{
width
=
parseInt
(
dimObj
[
'@width'
],
10
);
}
tempInt
=
parseInt
(
dimObj
[
'@width'
],
10
);
if
(
isNaN
(
tempInt
)
===
false
)
{
width
=
tempInt
;
}
if
(
dimObj
.
hasOwnProperty
(
'@height'
)
===
true
)
{
if
(
isNaN
(
parseInt
(
dimObj
[
'@height'
],
10
))
===
false
)
{
height
=
parseInt
(
dimObj
[
'@height'
],
10
);
}
tempInt
=
parseInt
(
dimObj
[
'@height'
],
10
);
if
(
isNaN
(
tempInt
)
===
false
)
{
height
=
tempInt
;
}
}
...
...
@@ -84,9 +81,6 @@ define('Graph', ['logme'], function (logme) {
function
processTicks
(
ticksStr
,
ticksObj
)
{
var
ticksBlobs
,
min
,
tickSize
,
max
;
logme
(
'Processing ticks. Ticks string is: ['
+
ticksStr
+
']'
);
logme
(
'Original ticks object:'
,
ticksObj
);
ticksBlobs
=
ticksStr
.
split
(
','
);
if
(
ticksBlobs
.
length
!==
3
)
{
...
...
@@ -116,8 +110,42 @@ define('Graph', ['logme'], function (logme) {
if
(
ticksObj
.
tickSize
*
2
>=
ticksObj
.
max
-
ticksObj
.
min
)
{
ticksObj
.
tickSize
=
(
ticksObj
.
max
-
ticksObj
.
min
)
/
10.0
;
}
}
}
function
setGraphXRange
()
{
var
xRangeStr
,
xRangeBlobs
,
tempNum
;
xrange
=
{
'start'
:
0
,
'end'
:
30
,
'step'
:
0.1
};
if
(
typeof
config
.
plot
[
'xrange'
]
===
'string'
)
{
xRangeStr
=
config
.
plot
[
'xrange'
];
xRangeBlobs
=
xRangeStr
.
split
(
','
);
logme
(
'Modified ticks object:'
,
ticksObj
);
if
(
xRangeBlobs
.
length
===
2
)
{
tempNum
=
parseFloat
(
xRangeBlobs
[
0
]);
if
(
isNaN
(
tempNum
)
===
false
)
{
xrange
.
start
=
tempNum
;
}
tempNum
=
parseFloat
(
xRangeBlobs
[
1
]);
if
(
isNaN
(
tempNum
)
===
false
)
{
xrange
.
end
=
tempNum
;
}
}
}
if
(
typeof
config
.
plot
[
'num_points'
]
===
'string'
)
{
tempNum
=
parseInt
(
config
.
plot
[
'num_points'
],
10
);
if
(
isNaN
(
tempNum
)
===
false
)
{
xrange
.
step
=
(
xrange
.
end
-
xrange
.
start
)
/
tempNum
;
}
}
}
...
...
@@ -242,7 +270,7 @@ define('Graph', ['logme'], function (logme) {
}
function
generateData
()
{
var
c0
,
c1
,
functionObj
,
seriesObj
,
dataPoints
,
constValues
,
x
,
y
;
var
c0
,
functionObj
,
seriesObj
,
dataPoints
,
constValues
,
x
,
y
;
constValues
=
state
.
getAllConstantValues
();
...
...
@@ -254,8 +282,7 @@ define('Graph', ['logme'], function (logme) {
seriesObj
=
{};
dataPoints
=
[];
for
(
c1
=
0
;
c1
<
30
;
c1
+=
1
)
{
x
=
c1
;
for
(
x
=
xrange
.
start
;
x
<=
xrange
.
end
;
x
+=
xrange
.
step
)
{
// Push the 'x' variable to the end of the parameter array.
constValues
.
push
(
x
);
...
...
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