Commit 3eb3d7db by Alexander Kryklia

units implemented

parent 315cc7c7
......@@ -63,7 +63,7 @@ define('Graph', ['logme'], function (logme) {
'max': 10
};
if (typeof config.plot['xticks'] === 'string') {
processTicks(config.plot['xticks'], xaxis);
processTicks(config.plot['xticks'], xaxis, 'xunits');
} else {
logme('MESSAGE: "xticks" were not specified. Using defaults.');
}
......@@ -76,14 +76,14 @@ define('Graph', ['logme'], function (logme) {
'max': 10
};
if (typeof config.plot['yticks'] === 'string') {
processTicks(config.plot['yticks'], yaxis);
processTicks(config.plot['yticks'], yaxis, 'yunits');
} else {
logme('MESSAGE: "yticks" were not specified. Using defaults.');
}
return;
function processTicks(ticksStr, ticksObj) {
function processTicks(ticksStr, ticksObj, unitsType) {
var ticksBlobs, tempFloat;
// The 'ticks' setting is a string containing 3 floating-point
......@@ -134,6 +134,17 @@ define('Graph', ['logme'], function (logme) {
ticksObj.tickSize = (ticksObj.max - ticksObj.min) / 10.0;
}
// units: change last tick to units
if (typeof config.plot[unitsType] === 'string') {
var ticks = _.map(_.range(ticksObj.min,
ticksObj.max + ticksObj.tickSize, ticksObj.tickSize),
function(x){ return [x,
x > ticksObj.max - ticksObj.tickSize ? config.plot[unitsType] : x];
});
ticksObj.tickSize = null;
ticksObj.ticks = ticks;
}
}
}
......
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