web/data/cubicweb.flot.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 20 May 2010 20:47:55 +0200
changeset 5556 9ab2b4c74baf
parent 2564 5f38f5eaff86
child 5658 7b9553a9db65
permissions -rw-r--r--
[entity] introduce a new 'adapters' registry This changeset introduces the notion in adapters (as in Zope Component Architecture) in a cubicweb way, eg using a specific registry of appobjects. This allows nicer code structure, by avoid clutering entity classes and moving code usually specific to a place of the ui (or something else) together with the code that use the interface. We don't use actual interface anymore, they are implied by adapters (which may be abstract), whose reg id is an interface name. Appobjects that used to 'implements(IFace)' should now be rewritten by: * coding an IFaceAdapter(EntityAdapter) defining (implementing if desired) the interface, usually with __regid__ = 'IFace' * use "adaptable('IFace')" as selector instead Also, the implements_adapter_compat decorator eases backward compatibility with adapter's methods that may still be found on entities implementing the interface. Notice that unlike ZCA, we don't support automatic adapters chain (yagni?). All interfaces defined in cubicweb have been turned into adapters, also some new ones have been introduced to cleanup Entity / AnyEntity classes namespace. At the end, the pluggable mixins mecanism should disappear in favor of adapters as well.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
function showTooltip(x, y, contents) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
    $('<div id="tooltip">' + contents + '</div>').css( {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
            position: 'absolute',
2564
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
     4
        display: 'none',
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
     5
        top: y + 5,
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     6
            left: x + 5,
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
            border: '1px solid #fdd',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
            padding: '2px',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     9
            'background-color': '#fee',
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
            opacity: 0.80
2564
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    11
        }).appendTo("body").fadeIn(200);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    12
}
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    13
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    14
var previousPoint = null;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    15
function onPlotHover(event, pos, item) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
    if (item) {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
        if (previousPoint != item.datapoint) {
2564
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    18
            previousPoint = item.datapoint;
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    19
            $("#tooltip").remove();
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    20
            var x = item.datapoint[0].toFixed(2),
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    21
                y = item.datapoint[1].toFixed(2);
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    22
            if (item.datapoint.length == 3) {
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    23
                x = new Date(item.datapoint[2]);
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    24
                x = x.toLocaleDateString() + ' ' + x.toLocaleTimeString();
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    25
            } else if (item.datapoint.length == 4) {
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    26
               x = new Date(item.datapoint[2]);
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    27
               x = x.strftime(item.datapoint[3]);
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
            }
2564
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    29
            showTooltip(item.pageX, item.pageY,
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    30
            item.series.label + ': (' + x + ' ; ' + y + ')');
5f38f5eaff86 [F plot] make jquery plots accept a fourth column that specifies a date format for tooltips
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1888
diff changeset
    31
        }
1888
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
    } else {
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
        $("#tooltip").remove();
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
        previousPoint = null;
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
    }
f36d43f00f32 [views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
}