Commit ad4f4144 by Valera Rozuvan Committed by Alexander Kryklia

New feature: Added ability to set "color" and "weight" property of moving label text.

parent bd605150
...@@ -105,7 +105,8 @@ define('Graph', ['logme'], function (logme) { ...@@ -105,7 +105,8 @@ define('Graph', ['logme'], function (logme) {
} }
function processMovingLabel(obj) { function processMovingLabel(obj) {
var labelText, funcString, disableAutoReturn, paramNames, func; var labelText, funcString, disableAutoReturn, paramNames, func,
fontWeight, fontColor;
if (obj.hasOwnProperty('@text') === false) { if (obj.hasOwnProperty('@text') === false) {
logme('ERROR: You did not define a "text" attribute for the moving_label.'); logme('ERROR: You did not define a "text" attribute for the moving_label.');
...@@ -131,6 +132,29 @@ define('Graph', ['logme'], function (logme) { ...@@ -131,6 +132,29 @@ define('Graph', ['logme'], function (logme) {
} }
funcString = obj['#text']; funcString = obj['#text'];
fontColor = 'black';
if (
(obj.hasOwnProperty('@color') === true) &&
(typeof obj['@color'] === 'string')
) {
fontColor = obj['@color'];
}
fontWeight = 'normal';
if (
(obj.hasOwnProperty('@weight') === true) &&
(typeof obj['@weight'] === 'string')
) {
if (
(obj['@weight'].toLowerCase() === 'normal') ||
(obj['@weight'].toLowerCase() === 'bold')
) {
fontWeight = obj['@weight'];
} else {
logme('ERROR: Moving label can have a weight property of "normal" or "bold".');
}
}
disableAutoReturn = obj['@disable_auto_return']; disableAutoReturn = obj['@disable_auto_return'];
funcString = $('<div>').html(funcString).text(); funcString = $('<div>').html(funcString).text();
...@@ -181,7 +205,9 @@ define('Graph', ['logme'], function (logme) { ...@@ -181,7 +205,9 @@ define('Graph', ['logme'], function (logme) {
movingLabels.push({ movingLabels.push({
'labelText': labelText, 'labelText': labelText,
'func': func, 'func': func,
'el': null 'el': null,
'fontColor': fontColor,
'fontWeight': fontWeight
}); });
} }
...@@ -1082,6 +1108,8 @@ define('Graph', ['logme'], function (logme) { ...@@ -1082,6 +1108,8 @@ define('Graph', ['logme'], function (logme) {
'</div>' '</div>'
); );
movingLabels[c1].el.css('position', 'absolute'); movingLabels[c1].el.css('position', 'absolute');
movingLabels[c1].el.css('color', movingLabels[c1].fontColor);
movingLabels[c1].el.css('font-weight', movingLabels[c1].fontWeight);
movingLabels[c1].el.appendTo(plotDiv); movingLabels[c1].el.appendTo(plotDiv);
movingLabels[c1].elWidth = movingLabels[c1].el.width(); movingLabels[c1].elWidth = movingLabels[c1].el.width();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment