-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.js
53 lines (49 loc) · 1.58 KB
/
plotter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Function plotter enthraler.
*/
// Use an AMD module definition.
// We will import jQuery, enthraler, and local CSS.
define(['enthraler', './function-plot.min.js', 'css!plotter'], function (enthraler, functionPlot) {
var Hello = function(environment) {
environment.container.innerHTML = '<div id="function-plot-canvas"></div>';
this.render = function (authorData) {
functionPlot({
target: '#function-plot-canvas',
width: parseInt(window.getComputedStyle(environment.container).width, 10),
grid: authorData.showGrid,
disableZoom: authorData.allowZoom !== true,
xAxis: {
label: authorData.xLabel,
domain: (authorData.defaultSize) ? [authorData.defaultSize.xMin, authorData.defaultSize.xMax] : undefined
},
yAxis: {
label: authorData.yLabel,
domain: (authorData.defaultSize) ? [authorData.defaultSize.yMin, authorData.defaultSize.yMax] : undefined
},
tip: {
xLine: true,
yLine: true,
renderer: function (x, y, index) {
var name = authorData.lines[index].name || '',
coordinates = "[" + x.toFixed(2) + ", " + y.toFixed(2) + "]";
if (name) {
return name + ": " + coordinates;
} else {
return coordinates;
}
}
},
data: authorData.lines.map(function (l) {
if (!l.graphType) {
l.graphType = 'polyline';
}
return l;
})
});
// Resize the iframe to fit the new height.
environment.requestHeightChange();
}
};
Hello.enthralerSchema = 'components/examples/function-plotter/schema.json';
return Hello;
});