写代码的时候,碰到了这样的代码,其实里面的都弄明白了,但是那种function用括号括起来再加个节点的语法,表示不能得其要领,求解
(function basic_time(container) {
var
d1 = [],
options,
graph,
i, x, o;
data = eval(data);
for (i = 0; i < data.length; i++) {
x = data[i].time;
d1.push([x, data[i].val]);
}
options = {
xaxis: {
mode: 'time',
labelsAngle: 45
},
yaxis: {min: 0},
selection: {
mode: 'x'
},
HtmlText: false,
title: '报表' +tmpGraph
};
// Draw graph with default options, overwriting with passed options
function drawGraph(opts) {
// Clone the options, so the 'options' variable always keeps intact.
o = Flotr._.extend(Flotr._.clone(options), opts || {});
// Return a new graph.
return Flotr.draw(
container,
[
{data: d1, lines: {fill: true}}
], o);
}
graph = drawGraph();
Flotr.EventAdapter.observe(container, 'flotr:select', function(area) {
// Draw selected area
graph = drawGraph({
xaxis: {min: area.x1, max: area.x2, mode: 'time', labelsAngle: 45},
yaxis: {min: area.y1, max: area.y2}
});
});
// When graph is clicked, draw the graph with default area.
Flotr.EventAdapter.observe(container, 'flotr:click', function() {
graph = drawGraph();
});
})(document.getElementById("editor-render-0"));
你是指这个 http://segmentfault.com/q/1010000000135703 问题?
BTW, 提问的智慧