diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index daf03f8f827..63b3dd3837b 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -35,6 +35,7 @@ export default class TimeSeries { isOutsideRange: boolean; lines: any; + dashes: any; bars: any; points: any; yaxis: any; @@ -61,6 +62,9 @@ export default class TimeSeries { applySeriesOverrides(overrides) { this.lines = {}; + this.dashes = { + dashLength: [] + }; this.points = {}; this.bars = {}; this.yaxis = 1; @@ -74,11 +78,20 @@ export default class TimeSeries { continue; } if (override.lines !== void 0) { this.lines.show = override.lines; } + if (override.dashes !== void 0) { + this.dashes.show = override.dashes; + this.lines.lineWidth = 0; + } if (override.points !== void 0) { this.points.show = override.points; } if (override.bars !== void 0) { this.bars.show = override.bars; } if (override.fill !== void 0) { this.lines.fill = translateFillOption(override.fill); } if (override.stack !== void 0) { this.stack = override.stack; } - if (override.linewidth !== void 0) { this.lines.lineWidth = override.linewidth; } + if (override.linewidth !== void 0) { + this.lines.lineWidth = override.linewidth; + this.dashes.lineWidth = override.linewidth; + } + if (override.dashLength !== void 0) { this.dashes.dashLength[0] = override.dashLength; } + if (override.spaceLength !== void 0) { this.dashes.dashLength[1] = override.spaceLength; } if (override.nullPointMode !== void 0) { this.nullPointMode = override.nullPointMode; } if (override.pointradius !== void 0) { this.points.radius = override.pointradius; } if (override.steppedLine !== void 0) { this.lines.steps = override.steppedLine; } diff --git a/public/app/plugins/panel/graph/graph.ts b/public/app/plugins/panel/graph/graph.ts index ca1b5021ab0..3d4fd4c7edb 100755 --- a/public/app/plugins/panel/graph/graph.ts +++ b/public/app/plugins/panel/graph/graph.ts @@ -7,6 +7,7 @@ import 'jquery.flot.stack'; import 'jquery.flot.stackpercent'; import 'jquery.flot.fillbelow'; import 'jquery.flot.crosshair'; +import 'jquery.flot.dashes'; import './jquery.flot.events'; import $ from 'jquery'; @@ -215,6 +216,9 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv, popoverSrv) { // give space to alert editing thresholdManager.prepare(elem, data); + // un-check dashes if lines are unchecked + panel.dashes = panel.lines ? panel.dashes : false; + var stack = panel.stack ? true : null; // Populate element @@ -231,9 +235,14 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv, popoverSrv) { show: panel.lines, zero: false, fill: translateFillOption(panel.fill), - lineWidth: panel.linewidth, + lineWidth: panel.dashes ? 0 : panel.linewidth, steps: panel.steppedLine }, + dashes: { + show: panel.dashes, + lineWidth: panel.linewidth, + dashLength: [panel.dashLength, panel.spaceLength] + }, bars: { show: panel.bars, fill: 1, diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 0a55fe0a9df..e2dce12168d 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -67,6 +67,12 @@ class GraphCtrl extends MetricsPanelCtrl { fill : 1, // line width in pixels linewidth : 1, + // show/hide dashed line + dashes : false, + // length of a dash + dashLength : 10, + // length of space between two dashes + spaceLength : 10, // show hide points points : false, // point radius in pixels diff --git a/public/app/plugins/panel/graph/series_overrides_ctrl.js b/public/app/plugins/panel/graph/series_overrides_ctrl.js index f5dae8e3c7e..945f8340b33 100644 --- a/public/app/plugins/panel/graph/series_overrides_ctrl.js +++ b/public/app/plugins/panel/graph/series_overrides_ctrl.js @@ -100,6 +100,9 @@ define([ $scope.addOverrideOption('Null point mode', 'nullPointMode', ['connected', 'null', 'null as zero']); $scope.addOverrideOption('Fill below to', 'fillBelowTo', $scope.getSeriesNames()); $scope.addOverrideOption('Staircase line', 'steppedLine', [true, false]); + $scope.addOverrideOption('Dashes', 'dashes', [true, false]); + $scope.addOverrideOption('Dash Length', 'dashLength', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]); + $scope.addOverrideOption('Dash Space', 'spaceLength', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]); $scope.addOverrideOption('Points', 'points', [true, false]); $scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]); $scope.addOverrideOption('Stack', 'stack', [true, false, 'A', 'B', 'C', 'D']); diff --git a/public/app/plugins/panel/graph/specs/graph_specs.ts b/public/app/plugins/panel/graph/specs/graph_specs.ts index 0d8c088f704..161aca11e42 100644 --- a/public/app/plugins/panel/graph/specs/graph_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_specs.ts @@ -153,6 +153,20 @@ describe('grafanaGraph', function() { }); }); + graphScenario('dashed lines options', function(ctx) { + ctx.setup(function(ctrl) { + ctrl.panel.lines = true; + ctrl.panel.linewidth = 2; + ctrl.panel.dashes = true; + }); + + it('should configure dashed plot with correct options', function() { + expect(ctx.plotOptions.series.lines.show).to.be(true); + expect(ctx.plotOptions.series.dashes.lineWidth).to.be(2); + expect(ctx.plotOptions.series.dashes.show).to.be(true); + }); + }); + graphScenario('should use timeStep for barWidth', function(ctx) { ctx.setup(function(ctrl, data) { ctrl.panel.bars = true; diff --git a/public/app/plugins/panel/graph/tab_display.html b/public/app/plugins/panel/graph/tab_display.html index 8ace16c6078..9f8a90829ae 100644 --- a/public/app/plugins/panel/graph/tab_display.html +++ b/public/app/plugins/panel/graph/tab_display.html @@ -32,12 +32,28 @@ -