17
dimensions : function (text, canvasStyle, htmlStyle, className) {
19
if (!text) return { width : 0, height : 0 };
21
return (this.o.html) ?
22
this.html(text, this.o.element, htmlStyle, className) :
23
this.canvas(text, canvasStyle);
26
canvas : function (text, style) {
28
if (!this.o.textEnabled) return;
32
metrics = this.measureText(text, style),
33
width = metrics.width,
34
height = style.size || F.defaultOptions.fontSize,
35
angle = style.angle || 0,
36
cosAngle = Math.cos(angle),
37
sinAngle = Math.sin(angle),
43
width: Math.abs(cosAngle * width) + Math.abs(sinAngle * height) + widthPadding,
44
height: Math.abs(sinAngle * width) + Math.abs(cosAngle * height) + heightPadding
50
html : function (text, element, style, className) {
52
var div = D.create('div');
54
D.setStyles(div, { 'position' : 'absolute', 'top' : '-10000px' });
55
D.insert(div, '<div style="'+style+'" class="'+className+' flotr-dummy-div">' + text + '</div>');
56
D.insert(this.o.element, div);
61
measureText : function (text, style) {
67
if (!context.fillText || (F.isIphone && context.measure)) {
68
return { width : context.measure(text, style)};
72
size: F.defaultOptions.fontSize,
78
context.font = (style.weight > 1 ? "bold " : "") + (style.size*1.3) + "px sans-serif";
79
metrics = context.measureText(text);