Przeglądaj źródła

graph: dashes with linewidth fix. Fixes #8469

Adds series override options for dash spaces and dash length.
Daniel Lee 8 lat temu
rodzic
commit
3292a48381

+ 3 - 1
public/app/core/time_series2.ts

@@ -87,9 +87,11 @@ export default class TimeSeries {
       if (override.fill !== void 0) { this.lines.fill = translateFillOption(override.fill); }
       if (override.fill !== void 0) { this.lines.fill = translateFillOption(override.fill); }
       if (override.stack !== void 0) { this.stack = override.stack; }
       if (override.stack !== void 0) { this.stack = override.stack; }
       if (override.linewidth !== void 0) {
       if (override.linewidth !== void 0) {
-         this.lines.lineWidth = override.linewidth;
+         this.lines.lineWidth = this.dashes.show ? 0: override.linewidth;
          this.dashes.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.nullPointMode !== void 0) { this.nullPointMode = override.nullPointMode; }
       if (override.pointradius !== void 0) { this.points.radius = override.pointradius; }
       if (override.pointradius !== void 0) { this.points.radius = override.pointradius; }
       if (override.steppedLine !== void 0) { this.lines.steps = override.steppedLine; }
       if (override.steppedLine !== void 0) { this.lines.steps = override.steppedLine; }

+ 2 - 0
public/app/plugins/panel/graph/series_overrides_ctrl.js

@@ -101,6 +101,8 @@ define([
     $scope.addOverrideOption('Fill below to', 'fillBelowTo', $scope.getSeriesNames());
     $scope.addOverrideOption('Fill below to', 'fillBelowTo', $scope.getSeriesNames());
     $scope.addOverrideOption('Staircase line', 'steppedLine', [true, false]);
     $scope.addOverrideOption('Staircase line', 'steppedLine', [true, false]);
     $scope.addOverrideOption('Dashes', 'dashes', [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', 'points', [true, false]);
     $scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]);
     $scope.addOverrideOption('Points Radius', 'pointradius', [1,2,3,4,5]);
     $scope.addOverrideOption('Stack', 'stack', [true, false, 'A', 'B', 'C', 'D']);
     $scope.addOverrideOption('Stack', 'stack', [true, false, 'A', 'B', 'C', 'D']);

+ 13 - 0
public/test/core/time_series_specs.js

@@ -211,6 +211,19 @@ define([
         });
         });
       });
       });
 
 
+      describe('series option overrides, dashes and lineWidth', function() {
+        beforeEach(function() {
+          series.alias = 'test';
+          series.applySeriesOverrides([{ alias: 'test', linewidth: 5, dashes: true }]);
+        });
+
+        it('should enable dashes, set dashes lineWidth to 5 and lines lineWidth to 0', function() {
+          expect(series.dashes.show).to.be(true);
+          expect(series.dashes.lineWidth).to.be(5);
+          expect(series.lines.lineWidth).to.be(0);
+        });
+      });
+
       describe('series option overrides, fill below to', function() {
       describe('series option overrides, fill below to', function() {
         beforeEach(function() {
         beforeEach(function() {
           series.alias = 'test';
           series.alias = 'test';