ICC-Profile
view release on metacpan or search on metacpan
lib/ICC/Javascripts/rgraph/RGraph.bipolar.js view on Meta::CPAN
this.drawLabelsAbove = function ()
{
var coordsLeft = RG.arrayReverse(this.coordsLeft);
var coordsRight = RG.arrayReverse(this.coordsRight);
// Draw the left sides above labels
for (var i=0,seq=0; i<coordsLeft.length; ++i, ++seq) {
if (typeof this.left[i] == 'number') {
var coords = coordsLeft[i];
RG.text2(this, {
font: prop['chart.labels.above.font'] || prop['chart.text.font'],
size: prop['chart.labels.above.size'] || prop['chart.text.size'],
x: coords[0] - 5,
y: coords[1] + (coords[3] / 2),
text: typeof prop['chart.labels.above.formatter'] === 'function' ? prop['chart.labels.above.formatter'](this, this.left[i]) : RG.numberFormat(
this,
this.left[i].toFixed(typeof prop['chart.labels.above.decimals'] === 'number' ? prop['chart.labels.above.decimals'] : 0),
prop['chart.labels.above.units.pre'],
prop['chart.labels.above.units.post']
),
valign: 'center',
halign: 'right',
color: prop['chart.labels.above.color'] || prop['chart.text.color'],
bold: typeof prop['chart.labels.above.bold'] === 'boolean' ? prop['chart.labels.above.bold'] : prop['chart.text.bold'],
italic: typeof prop['chart.labels.above.italic'] === 'boolean' ? prop['chart.labels.above.italic'] : prop['chart.text.italic'],
tag: 'labels.above'
});
// A grouped chart
} else if (typeof this.left[i] === 'object') {
// Loop through the group
for (var j=0; j<this.left[i].length; ++j,++seq) {
// Stacked charts only show the above label on the last
// segment of the bar
if (prop['chart.grouping'] === 'stacked' && j !== 0 ) {
continue;
}
var coords = coordsLeft[seq];
RG.text2(this, {
font: prop['chart.labels.above.font'] || prop['chart.text.font'],
size: prop['chart.labels.above.size'] || prop['chart.text.size'],
x: coords[0] - 5,
y: coords[1] + (coords[3] / 2),
text: typeof prop['chart.labels.above.formatter'] === 'function' ? prop['chart.labels.above.formatter'](this, this.left[i][j]) : RG.numberFormat(
this,
RG.isNull(this.left[i][j]) || isNaN(this.left[i][j]) ? '' : (prop['chart.grouping'] === 'stacked' ? RG.arraySum(this.left[i]): Number(this.left[i][j])).toFixed(typeof prop['chart.labels.above.decimals'] === 'nu...
prop['chart.labels.above.units.pre'],
prop['chart.labels.above.units.post']
),
valign: 'center',
halign: 'right',
color: prop['chart.labels.above.color'] || null,
bold: typeof prop['chart.labels.above.bold'] === 'boolean' ? prop['chart.labels.above.bold'] : false,
italic: typeof prop['chart.labels.above.italic'] === 'boolean' ? prop['chart.labels.above.italic'] : false,
tag: 'labels.above'
});
}
seq--;
}
}
// Draw the right sides above labels
for (i=0,seq=0; i<coordsRight.length; ++i,++seq) {
if (typeof this.right[i] === 'number') {
var coords = coordsRight[i];
RG.text2(this, {
font: prop['chart.labels.above.font'] || prop['chart.text.font'],
size: prop['chart.labels.above.size'] || prop['chart.text.size'],
x: coords[0] + coords[2] + 5,
y: coords[1] + (coords[3] / 2),
text: typeof prop['chart.labels.above.formatter'] === 'function' ? prop['chart.labels.above.formatter'](this, this.right[i]) : RG.numberFormat(
this,
this.right[i].toFixed(typeof prop['chart.labels.above.decimals'] === 'number' ? prop['chart.labels.above.decimals'] : 0),
prop['chart.labels.above.units.pre'],
prop['chart.labels.above.units.post']
),
valign: 'center',
halign: 'left',
color: prop['chart.labels.above.color'] || null,
bold: typeof prop['chart.labels.above.bold'] === 'boolean' ? prop['chart.labels.above.bold'] : false,
italic: typeof prop['chart.labels.above.italic'] === 'boolean' ? prop['chart.labels.above.italic'] : false,
tag: 'labels.above'
});
// A grouped/stacked chart
} else if (typeof this.right[i] === 'object') {
// Loop through the group
for (var j=0; j<this.right[i].length; ++j,++seq) {
// Stacked charts only show the above label on the last
// segment of the bar
if (prop['chart.grouping'] === 'stacked' && j !== 0) {
continue;
}
var coords = coordsRight[seq];
RG.text2(this, {
font: prop['chart.labels.above.font'] || prop['chart.text.font'],
size: prop['chart.labels.above.size'] || prop['chart.text.size'],
x: coords[0] + coords[2] + 5,
y: coords[1] + (coords[3] / 2),
text: typeof prop['chart.labels.above.formatter'] === 'function' ? prop['chart.labels.above.formatter'](this, this.right[i][j]) : RG.numberFormat(
this,
RG.isNull(this.right[i][j]) || isNaN(this.right[i][j]) ? '' : Number(this.right[i][j]).toFixed(typeof prop['chart.labels.above.decimals'] === 'number' ? prop['chart.labels.above.decimals'] : 0),
prop['chart.labels.above.units.pre'],
prop['chart.labels.above.units.post']
),
valign: 'center',
halign: 'left',
color: prop['chart.labels.above.color'] || null,
bold: typeof prop['chart.labels.above.bold'] === 'boolean' ? prop['chart.labels.above.bold'] : false,
italic: typeof prop['chart.labels.above.italic'] === 'boolean' ? prop['chart.labels.above.italic'] : false,
tag: 'labels.above'
});
}
--seq;
}
}
};
/**
* Draws the titles
*/
this.drawTitles =
this.DrawTitles = function ()
{
// Draw the left title
if (typeof prop['chart.title.left'] === 'string') {
RG.text2(this, {
font: prop['chart.title.left.font'] || prop['chart.text.font'],
size: prop['chart.title.left.size'] || prop['chart.text.size'],
x: this.gutterLeft + 5,
y: this.gutterTop - 5,
text: prop['chart.title.left'],
halign:'left',
valign: 'bottom',
bold: typeof prop['chart.title.left.bold'] === 'boolean' ? prop['chart.title.left.bold'] : prop['chart.text.bold'],
italic: typeof prop['chart.title.left.italic'] === 'boolean' ? prop['chart.title.left.italic'] : prop['chart.text.italic'],
color: prop['chart.title.left.color'] || prop['chart.text.color'],
tag: 'title.left'
});
}
// Draw the right title
if (typeof prop['chart.title.right'] === 'string') {
RG.text2(this, {
font: prop['chart.title.right.font'] || prop['chart.text.font'],
size: prop['chart.title.right.size'] || prop['chart.text.size'],
x: ca.width - this.gutterRight - 5,
y: this.gutterTop - 5,
text: prop['chart.title.right'],
halign: 'right',
valign: 'bottom',
bold: typeof prop['chart.title.right.bold'] === 'boolean' ? prop['chart.title.right.bold'] : prop['chart.right.bold'],
italic: typeof prop['chart.title.right.italic'] === 'boolean' ? prop['chart.title.right.italic'] : prop['chart.right.italic'],
color: prop['chart.title.right.color'] || prop['chart.text.color'],
( run in 2.813 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )