]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/static/AdminLTE-2.3.7/plugins/flot/jquery.flot.symbol.js
1 /* Flot plugin that adds some extra symbols for plotting points.
3 Copyright (c) 2007-2013 IOLA and Ole Laursen.
4 Licensed under the MIT license.
6 The symbols are accessed as strings through the standard symbol options:
10 symbol: "square" // or "diamond", "triangle", "cross"
17 function processRawData(plot
, series
, datapoints
) {
18 // we normalize the area of each symbol so it is approximately the
19 // same as a circle of the given radius
22 square: function (ctx
, x
, y
, radius
, shadow
) {
23 // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
24 var size
= radius
* Math
.sqrt(Math
.PI
) / 2;
25 ctx
.rect(x
- size
, y
- size
, size
+ size
, size
+ size
);
27 diamond: function (ctx
, x
, y
, radius
, shadow
) {
28 // pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
29 var size
= radius
* Math
.sqrt(Math
.PI
/ 2);
30 ctx
.moveTo(x
- size
, y
);
31 ctx
.lineTo(x
, y
- size
);
32 ctx
.lineTo(x
+ size
, y
);
33 ctx
.lineTo(x
, y
+ size
);
34 ctx
.lineTo(x
- size
, y
);
36 triangle: function (ctx
, x
, y
, radius
, shadow
) {
37 // pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
38 var size
= radius
* Math
.sqrt(2 * Math
.PI
/ Math
.sin(Math
.PI
/ 3));
39 var height
= size
* Math
.sin(Math
.PI
/ 3);
40 ctx
.moveTo(x
- size
/2, y + height/2);
41 ctx
.lineTo(x
+ size
/2, y + height/2);
43 ctx
.lineTo(x
, y
- height
/2);
44 ctx
.lineTo(x
- size
/2, y + height/2);
47 cross: function (ctx
, x
, y
, radius
, shadow
) {
48 // pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
49 var size
= radius
* Math
.sqrt(Math
.PI
) / 2;
50 ctx
.moveTo(x
- size
, y
- size
);
51 ctx
.lineTo(x
+ size
, y
+ size
);
52 ctx
.moveTo(x
- size
, y
+ size
);
53 ctx
.lineTo(x
+ size
, y
- size
);
57 var s
= series
.points
.symbol
;
59 series
.points
.symbol
= handlers
[s
];
63 plot
.hooks
.processDatapoints
.push(processRawData
);