Permalink
Browse files

Allow labeling and color of axes

  • Loading branch information...
1 parent 421ea70 commit fd2fe8ea9f471f3fd2d5402f49a912bd4914fe83 @rashidkpc rashidkpc committed May 11, 2016
View
@@ -266,4 +266,6 @@ yaxis | *number* | The numbered y-axis to plot this series on, eg .yaxis(2) for
min | *number* | Min value
max | *number* | Max value
position | *string* | left or right
+label | *string* | Label for axis
+color | *string* | Color of axis label
View
@@ -32,6 +32,7 @@ var include = [
'node_modules',
'public',
'bower_components',
+ 'vendor_components',
'init.js',
'server',
'timelion.json',
@@ -186,6 +187,7 @@ gulp.task('dev', ['sync'], function (done) {
'node_modules',
'public/**/*',
'bower_components',
+ 'vendor_components',
'init.js',
'server/**/*',
'timelion.json'
View
@@ -64,6 +64,10 @@ module.exports = function (kibana) {
flotStack$: {
path: path.resolve(__dirname, 'bower_components/flot/jquery.flot.stack'),
imports: 'flot'
+ },
+ flotAxisLabels$: {
+ path: path.resolve(__dirname, 'vendor_components/flot/jquery.flot.axislabels'),
+ imports: 'flot'
}
}
},
View
@@ -1,6 +1,6 @@
{
"name": "timelion",
- "version": "5.0.0-0.1.310",
+ "version": "5.0.0-0.1.311",
"dependencies": {
"body-parser": "^1.12.0",
"boom": "^2.8.0",
@@ -10,6 +10,8 @@ require('flotCanvas');
require('flotSelection');
require('flotSymbol');
require('flotStack');
+require('flotAxisLabels');
+
require('./observe_resize');
@@ -224,7 +226,11 @@ app.directive('chart', function ($compile, $rootScope, timefilter, $timeout, Pri
}
if (series._global) {
- _.merge(options, series._global);
+ _.merge(options, series._global, function (objVal, srcVal) {
+ // This is kind of gross, it means that you can't replace a global value with a null
+ // best you can do is an empty string. Deal with it.
+ if (objVal == null) return srcVal;
+ });
}
return series;
View
@@ -9,6 +9,7 @@ var _ = require('lodash');
*/
module.exports = function alter(args, fn) {
+ // In theory none of the args should ever be promises. This is probably a waste.
return Promise.all(args).then(function (args) {
var seriesList = args.shift();
@@ -26,4 +27,4 @@ module.exports = function alter(args, fn) {
}).catch(function (e) {
throw e;
});
-};
+};
@@ -27,20 +27,37 @@ module.exports = new Chainable('yaxis', {
types: ['string', 'null'],
help: 'left or right'
},
+ {
+ name: 'label',
+ types: ['string', 'null'],
+ help: 'Label for axis'
+ },
+ {
+ name: 'color',
+ types: ['string', 'null'],
+ help: 'Color of axis label'
+ },
],
help: 'Configures a variety of y-axis options, the most important likely being the ability to add an Nth (eg 2nd) y-axis',
fn: function yaxisFn(args) {
- return alter(args, function (eachSeries, yaxis, min, max, position) {
+ return alter(args, function (eachSeries, yaxis, min, max, position, label, color) {
yaxis = yaxis || 1;
eachSeries.yaxis = yaxis;
eachSeries._global = eachSeries._global || {};
- var yaxes = eachSeries._global.yaxes = eachSeries._global.yaxes || [];
- var myAxis = yaxes[yaxis - 1] = yaxes[yaxis - 1] || {};
+ eachSeries._global.yaxes = eachSeries._global.yaxes || [];
+ eachSeries._global.yaxes[yaxis - 1] = eachSeries._global.yaxes[yaxis - 1] || {};
+
+ var myAxis = eachSeries._global.yaxes[yaxis - 1];
myAxis.position = position || (yaxis % 2 ? 'left' : 'right');
myAxis.min = min == null ? 0 : min;
myAxis.max = max;
+ myAxis.axisLabelFontSizePixels = 11;
+ myAxis.axisLabel = label;
+ myAxis.axisLabelColour = color;
+ myAxis.axisLabelUseCanvas = true;
+
return eachSeries;
Oops, something went wrong.

0 comments on commit fd2fe8e

Please sign in to comment.