ICC-Profile
view release on metacpan or search on metacpan
lib/ICC/Javascripts/rgraph/RGraph.svg.pie.js view on Meta::CPAN
highlight.style.cursor = 'pointer';
}
}, false);
// Install the event listener that changes the
// cursor if necessary
if (prop.tooltipsEvent === 'click') {
arc.addEventListener('mousemove', function (e)
{
e.target.style.cursor = 'pointer';
}, false);
}
}(i, this));
}
}
//
// Redraw the segments if necessary so that they're on
// top of any shadow
//
if (prop.shadow && opt.shadow) {
this.redrawSegments();
}
};
//
// Redraw the Bars o that the bars appear above any shadow
//
this.redrawSegments = function ()
{
this.drawSegments({shadow: false});
};
//
// Draw the labels
//
this.drawLabels = function ()
{
var angles = this.angles,
prop = this.properties,
labels = prop.labels;
for (var i=0; i<angles.length; ++i) {
var endpoint = RG.SVG.TRIG.getRadiusEndPoint({
angle: angles[i].halfway - RG.SVG.TRIG.HALFPI,
r: angles[i].radius + 15
});
var x = endpoint[0] + angles[i].cx,
y = endpoint[1] + angles[i].cy,
valign,
halign;
// Figure out the valign and halign based on the quadrant
// the the center of the sgement is in.
if (angles[i].halfway > 0 && angles[i].halfway < RG.SVG.TRIG.HALFPI) {
halign = 'left';
valign = 'bottom';
} else if (angles[i].halfway > RG.SVG.TRIG.HALFPI && angles[i].halfway < RG.SVG.TRIG.PI) {
halign = 'left';
valign = 'top';
} else if (angles[i].halfway > RG.SVG.TRIG.PI && angles[i].halfway < (RG.SVG.TRIG.HALFPI + RG.SVG.TRIG.PI)) {
halign = 'right';
valign = 'top';
} else if (angles[i].halfway > (RG.SVG.TRIG.HALFPI + RG.SVG.TRIG.PI) && angles[i].halfway < RG.SVG.TRIG.TWOPI) {
halign = 'right';
valign = 'top';
}
RG.SVG.text({
object: this,
parent: this.svg.all,
tag: 'labels',
text: typeof labels[i] === 'string' ? labels[i] : '',
font: prop.textFont,
size: prop.textSize,
x: x,
y: y,
valign: valign,
halign: halign,
bold: prop.textBold,
italic: prop.textItalic,
color: prop.textColor
});
}
};
//
// Draws the ingraph labels
//
this.drawIngraphLabels = function ()
{
if (prop.labelsIngraph) {
for (var i=0; i<this.angles.length; ++i) {
// Some defaults
var halign = prop.labelsIngraphHalign || 'center',
valign = prop.labelsIngraphValign || 'center',
font = prop.labelsIngraphFont || prop.textFont,
size = prop.labelsIngraphSize || prop.textSize,
italic = typeof prop.labelsIngraphItalic === 'boolean' ? prop.labelsIngraphItalic : prop.textItalic,
bold = typeof prop.labelsIngraphBold === 'boolean' ? prop.labelsIngraphBold : prop.textBold,
lib/ICC/Javascripts/rgraph/RGraph.svg.pie.js view on Meta::CPAN
if (typeof prop.labelsIngraphFormatter === 'function') {
var str = prop.labelsIngraphFormatter({
object: this,
number: this.data[i].toFixed(decimals)
})
} else {
var str = RG.SVG.numberFormat({
prepend: prop.labelsIngraphUnitsPre,
append: prop.labelsIngraphUnitsPost,
point: prop.labelsIngraphPoint,
thousand: prop.labelsIngraphThousand,
num: this.data[i].toFixed(decimals),
object: this
});
}
}
//Draw the text
RG.SVG.text({
object: this,
parent: this.svg.all,
tag: 'labels.ingraph',
x: this.angles[i].cx + xy[0],
y: this.angles[i].cy + xy[1],
text: str,
halign: halign,
valign: valign,
font: font,
size: size,
bold: bold,
italic: italic,
color: color,
background: bgcolor,
padding: padding
});
}
}
};
//
// This function draws the labels in a list format
//
this.drawLabelsSticks = function ()
{
var labels_right = [],
labels_left = [],
labels_coords = [];
for (var i=0; i<this.angles.length; ++i) {
var angle = (this.angles[i].start + ((this.angles[i].end - this.angles[i].start) / 2)) - RGraph.SVG.TRIG.HALFPI, // Midpoint
endpoint_inner = RG.SVG.TRIG.getRadiusEndPoint({angle: angle, r: this.radius + 5}),
endpoint_outer = RG.SVG.TRIG.getRadiusEndPoint({angle: angle, r: this.radius + 20}),
explosion = [
(typeof prop.exploded === 'number' ? prop.exploded : prop.exploded[i]),
ma.cos(angle) * (typeof prop.exploded === 'number' ? prop.exploded : prop.exploded[i]),
ma.sin(angle) * (typeof prop.exploded === 'number' ? prop.exploded : prop.exploded[i])
];
// Initialise this array
labels_coords[i] = [];
// Initialise this
var labels = {};
// Push the label into the correct array
if (angle > RG.SVG.TRIG.HALFPI) {
var index = labels_left.length;
labels_left[index] = [];
labels_left[index].text = prop.labels[i];
labels_left[index].halign = 'right';
labels = labels_left;
labels_coords[i].halign = 'right';
} else {
var index = labels_right.length;
labels_right[index] = [];
labels_right[index].text = prop.labels[i];
labels_right[index].halign = 'right';
labels = labels_right;
labels_coords[i].halign = 'left';
}
endpoint_inner[0] += (explosion[1] || 0);
endpoint_inner[1] += (explosion[2] || 0);
endpoint_outer[0] += (explosion[1] || 0);
endpoint_outer[1] += (explosion[2] || 0);
var x,y;
if (labels[index].text) {
var stick = RG.SVG.create({
svg: this.svg,
parent: this.svg.all,
type: 'path',
attr: {
d: 'M {1} {2} L {3} {4}'.format(
this.centerx + endpoint_inner[0],
this.centery + endpoint_inner[1],
this.centerx + endpoint_outer[0],
this.centery + endpoint_outer[1]
),
stroke: '#999',
fill: 'rgba(0,0,0,0)'
}
});
}
// The path is altered later so this needs saving
if (stick) {
labels[index].stick = stick;
}
x = (this.centerx + endpoint_outer[0] + (angle > 1.57 ? -50 : 50));
y = (this.centery + endpoint_outer[1]);
labels_coords[i].x = x ;
labels_coords[i].y = y;
labels_coords[i].text = prop.labels[i];
}
// Calculate the spacing for each side
var vspace_right = (this.height - prop.gutterTop - prop.gutterBottom) / labels_right.length;
var vspace_left = (this.height - prop.gutterTop - prop.gutterBottom) / labels_left.length;
// Reset these
x = y = 0;
// Loop through the RHS labels
for (var i=0; i<labels_right.length; ++i) {
if (labels_right[i] && labels_right[i].text) {
x = this.centerx + this.radius + 100;
y = prop.gutterTop + (vspace_right * i) + (vspace_right / 2);
// Add the label to the scene
RGraph.SVG.text({
object: this,
parent: this.svg.all,
tag: 'labels.sticks',
text: typeof labels_right[i].text === 'string' ? labels_right[i].text : '',
font: prop.textFont,
size: prop.textSize,
x: x,
y: y,
valign: 'center',
halign: labels_right[i].text,
bold: prop.textBold,
italic: prop.textItalic,
color: prop.textColor
});
// Now update the path of the stick
labels_right[i].stick.setAttribute(
'd',
labels_right[i].stick.getAttribute('d') + ' H {3} L {1} {2} '.format(
x - 5,
y,
this.centerx + this.radius + prop.labelsSticksHlength
)
);
}
}
// Loop through the LHS labels
( run in 0.955 second using v1.01-cache-2.11-cpan-524268b4103 )