Author: timopollmeier
Date: 2017-01-13 16:30:09 +0100 (Fri, 13 Jan 2017)
New Revision: 27210

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/html/classic/graphics.xsl
   trunk/gsa/src/html/classic/js/gsa_chart_helpers.js
   trunk/gsa/src/html/classic/js/gsa_line_chart.js
   trunk/gsa/src/html/classic/ng/src/web/dashboard/commoncharts.js
   trunk/gsa/src/html/classic/ng/src/web/hosts/charts.js
   trunk/gsa/src/html/classic/ng/src/web/notes/charts.js
   trunk/gsa/src/html/classic/ng/src/web/overrides/charts.js
   trunk/gsa/src/html/classic/ng/src/web/reports/charts.js
Log:
        Add Vulns by hosts area chart.  Generally allow line charts to fill the
        area under the lines and to have an x axis not using time values.

        * src/html/classic/graphics.xsl (report-charts): Add "is_timeline"
        gen-param to the timeline chart.
        (vuln-charts): Change title of "vuln-by-hosts" to "Vulns by host - bar"
        and add chart "vuln-by-hosts-area".
        (host-charts, note-charts, override-charts, common-charts)
        (js-scan-management-top-visualization): Add "is_timeline" gen-param to
        the timeline chart.

        * src/html/classic/js/gsa_chart_helpers.js (fill_in_numbered_records):
        New function.

        * src/html/classic/js/gsa_line_chart.js (find_record_index)
        (LineChartGenerator.prototype.init)
        (LineChartGenerator.prototype.generate)
        (LineChartGenerator.prototype.evaluateParams): Use a simple numeric
        scale for the x axis by default and add a special "timeline" mode for
        time scales and aggregating by date.  Also add option to fill area
        under y and y2 data lines.

        * src/html/classic/ng/src/web/dashboard/commoncharts.js: Add gen_param
        "is_timeline" to timeline chart.

        * src/html/classic/ng/src/web/hosts/charts.js: Add gen_param
        "is_timeline" to timeline chart.

        * src/html/classic/ng/src/web/notes/charts.js: Add gen_param
        "is_timeline" to timeline chart.

        * src/html/classic/ng/src/web/overrides/charts.js: Add gen_param
        "is_timeline" to timeline chart.

        * src/html/classic/ng/src/web/reports/charts.js: Add gen_param
        "is_timeline" to timeline chart.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog 2017-01-13 15:26:40 UTC (rev 27209)
+++ trunk/gsa/ChangeLog 2017-01-13 15:30:09 UTC (rev 27210)
@@ -1,3 +1,42 @@
+2017-01-13  Timo Pollmeier <timo.pollme...@greenbone.net>
+
+       Add Vulns by hosts area chart.  Generally allow line charts to fill the
+       area under the lines and to have an x axis not using time values.
+
+       * src/html/classic/graphics.xsl (report-charts): Add "is_timeline"
+       gen-param to the timeline chart.
+       (vuln-charts): Change title of "vuln-by-hosts" to "Vulns by host - bar"
+       and add chart "vuln-by-hosts-area".
+       (host-charts, note-charts, override-charts, common-charts)
+       (js-scan-management-top-visualization): Add "is_timeline" gen-param to
+       the timeline chart.
+
+       * src/html/classic/js/gsa_chart_helpers.js (fill_in_numbered_records):
+       New function.
+
+       * src/html/classic/js/gsa_line_chart.js (find_record_index)
+       (LineChartGenerator.prototype.init)
+       (LineChartGenerator.prototype.generate)
+       (LineChartGenerator.prototype.evaluateParams): Use a simple numeric
+       scale for the x axis by default and add a special "timeline" mode for
+       time scales and aggregating by date.  Also add option to fill area
+       under y and y2 data lines.
+
+       * src/html/classic/ng/src/web/dashboard/commoncharts.js: Add gen_param
+       "is_timeline" to timeline chart.
+
+       * src/html/classic/ng/src/web/hosts/charts.js: Add gen_param
+       "is_timeline" to timeline chart.
+
+       * src/html/classic/ng/src/web/notes/charts.js: Add gen_param
+       "is_timeline" to timeline chart.
+
+       * src/html/classic/ng/src/web/overrides/charts.js: Add gen_param
+       "is_timeline" to timeline chart.
+
+       * src/html/classic/ng/src/web/reports/charts.js: Add gen_param
+       "is_timeline" to timeline chart.
+
 2017-01-13 Bj�rn Ricks <bjoern.ri...@greenbone.net>
 
        * src/html/classic/ng/src/web/css/login.css,

Modified: trunk/gsa/src/html/classic/graphics.xsl
===================================================================
--- trunk/gsa/src/html/classic/graphics.xsl     2017-01-13 15:26:40 UTC (rev 
27209)
+++ trunk/gsa/src/html/classic/graphics.xsl     2017-01-13 15:30:09 UTC (rev 
27210)
@@ -165,7 +165,7 @@
       data-y-fields="high_max"
       data-z-fields="high_per_host_max"
       data-chart-title="{gsa:i18n ('Reports: High results timeline')}"
-      data-gen-params='{{"show_stat_type": 0}}'/>
+      data-gen-params='{{"show_stat_type": 0, "is_timeline": 1}}'/>
   </div>
   <div class="dashboard-data-source"
     data-source-name="report-severity-count-source"
@@ -274,10 +274,17 @@
     data-filter-id="{$filt_id}">
     <span class="dashboard-chart"
       data-chart-name="vuln-by-hosts"
-      data-chart-title="{gsa:i18n ('Vulnerabilities by Hosts')}"
+      data-chart-title="{gsa:i18n ('Vulns by Hosts - bar')}"
       data-chart-title-count="count"
       data-chart-type="bar"
       data-chart-template="quantile_histogram"/>
+    <span class="dashboard-chart"
+      data-chart-name="vuln-by-hosts-area"
+      data-chart-title="{gsa:i18n ('Vulns by Hosts - area')}"
+      data-chart-title-count="count"
+      data-chart-type="line"
+      data-gen-params='{{"is_timeline": 0, "y_area": 1, "y2_area": 0}}'
+      data-chart-template="quantile_split"/>
   </div>
 </xsl:template>
 
@@ -339,6 +346,7 @@
       data-chart-title-count="count"
       data-y-fields="c_count,c_count[High]"
       data-z-fields="count,count[High]"
+      data-gen-params='{{"is_timeline": 1}}'
       data-chart-type="line"/>
   </div>
   <div class="dashboard-data-source"
@@ -419,7 +427,8 @@
       data-chart-name="note-by-created"
       data-chart-title="{gsa:i18n ('Notes by creation time')}"
       data-chart-title-count="count"
-      data-chart-type="line"/>
+      data-chart-type="line"
+      data-gen-params='{{"is_timeline": 1}}'/>
   </div>
   <div class="dashboard-data-source"
     data-source-name="note-text-words-source"
@@ -466,7 +475,8 @@
       data-chart-name="override-by-created"
       data-chart-title="{gsa:i18n ('Overrides by creation time')}"
       data-chart-title-count="count"
-      data-chart-type="line"/>
+      data-chart-type="line"
+      data-gen-params='{{"is_timeline": 1}}'/>
   </div>
   <div class="dashboard-data-source"
     data-source-name="override-text-words-source"
@@ -533,7 +543,8 @@
       data-chart-name="{$type}-by-created"
       data-chart-title="{gsa-i18n:strformat (gsa:i18n ('%1 by creation time'), 
$title_type)}"
       data-chart-title-count="count"
-      data-chart-type="line"/>
+      data-chart-type="line"
+      data-gen-params='{{"is_timeline": 1}}'/>
   </div>
 </xsl:template>
 
@@ -772,7 +783,7 @@
           data-chart-title="{gsa:i18n ('Reports: Duration timeline')}"
           data-y-fields="duration_mean,duration_max"
           data-z-fields="duration_per_host_mean,duration_per_host_max"
-          data-gen-params='{{"show_stat_type": 0, "y_format": "duration", 
"y2_format": "duration"}}'/>
+          data-gen-params='{{"is_timeline": 1, "show_stat_type": 0, 
"y_format": "duration", "y2_format": "duration"}}'/>
       </div>
     </xsl:if>
 

Modified: trunk/gsa/src/html/classic/js/gsa_chart_helpers.js
===================================================================
--- trunk/gsa/src/html/classic/js/gsa_chart_helpers.js  2017-01-13 15:26:40 UTC 
(rev 27209)
+++ trunk/gsa/src/html/classic/js/gsa_chart_helpers.js  2017-01-13 15:30:09 UTC 
(rev 27210)
@@ -2414,6 +2414,81 @@
     return new_data;
   };
 
+  /**
+   * Fills in empty records in a data set where the x field contains numbers
+   *  that can be increased in fixed steps (e.g. integers in ascending order).
+   *
+   * @param old_data  The original data.
+   * @param params    The generator parameters.
+   *
+   * @return The data with missing values filled in.
+   */
+  gch.fill_in_numbered_records = function(old_data, params) {
+    var new_data = {
+      records: [],
+      column_info: old_data.column_info,
+      filter_info: old_data.filter_info
+    };
+
+    var x_field = 'value';
+    if (params) {
+      if (params.x_field) {
+        x_field = params.x_field;
+      }
+    }
+
+    var step = 1;
+    var old_index = 0;
+    var value = Number(old_data.records[0][x_field]);
+    var prev_values = {};
+    var fields = [];
+    for (var field in old_data.records[0]) {
+      if (field !== x_field) {
+        fields.push(field);
+      }
+    }
+    var fillers = {};
+
+    while (old_index < old_data.records.length) {
+      if (Number(old_data.records[old_index][x_field]) <= value) {
+        new_data.records.push(old_data.records[old_index]);
+        for (field in old_data.column_info.columns) {
+          prev_values[field] = old_data.records[old_index][field];
+        }
+        old_index ++;
+      }
+      else {
+        var new_record = {};
+        new_record[x_field] = value;
+
+        for (field in old_data.column_info.columns) {
+          if (field !== x_field) {
+            if (fillers[field] === '!previous') {
+              new_record[field] = prev_values[field] ? prev_values[field] : 0;
+            }
+            else if (gsa.has_value(fillers[field])) {
+              new_record[field] = fillers[field];
+            }
+            else if (old_data.column_info.columns[field].stat === 'c_count') {
+              new_record[field] = prev_values[field] ? prev_values[field] : 0;
+            }
+            else if (old_data.column_info.columns[field].stat === 'count') {
+              new_record[field] = 0;
+            }
+            else {
+              new_record[field] = null;
+            }
+          }
+        }
+
+        new_data.records.push(new_record);
+      }
+      value += step;
+    }
+
+    return new_data;
+  }
+
   /*
    * In-chart link generator functions
    */

Modified: trunk/gsa/src/html/classic/js/gsa_line_chart.js
===================================================================
--- trunk/gsa/src/html/classic/js/gsa_line_chart.js     2017-01-13 15:26:40 UTC 
(rev 27209)
+++ trunk/gsa/src/html/classic/js/gsa_line_chart.js     2017-01-13 15:30:09 UTC 
(rev 27210)
@@ -35,11 +35,20 @@
   * Finds the index of a record by the value of a given field
   */
   function find_record_index(records, value, field) {
-    for (var index in records) {
-      if (records[index][field].getTime() === value.getTime()) {
-        return index;
+    if (gsa.is_defined (value.getTime)) {
+      for (var index in records) {
+        if (records[index][field].getTime() === value.getTime()) {
+          return index;
+        }
       }
     }
+    else {
+      for (var index in records) {
+        if (records[index][field] === value) {
+          return index;
+        }
+      }
+    }
     return -1;
   }
 
@@ -55,11 +64,11 @@
   LineChartGenerator.prototype.init = function() {
     this.margin = {top: 55, right: 60, bottom: 25, left: 60};
 
-    this.x_scale = d3.time.scale.utc();
+    this.x_scale = d3.scale.linear();
     this.y_scale = d3.scale.linear();
     this.y2_scale = d3.scale.linear();
 
-    this.x_axis = d3.svg.axis().scale(this.x_scale).orient('bottom').ticks(6);
+    this.x_axis = d3.svg.axis().scale(this.x_scale).orient('bottom').ticks(10);
     this.y_axis = d3.svg.axis().scale(this.y_scale).orient('left');
     this.y2_axis = d3.svg.axis().scale(this.y2_scale).orient('right');
 
@@ -73,7 +82,6 @@
 
     this.show_stat_type = true;
 
-    this.setDataTransformFunc(this.timeLine);
     this.setColorScale(d3.scale.category20());
     this.setTitleGenerator(gch.title_static(
       gsa._('Loading line chart ...'), gsa._('Bubble Chart')));
@@ -91,15 +99,33 @@
         .defined(function(d) { return gsa.is_defined(d[field]); });
     }
 
+    function y_area(field, y_scale) {
+      return d3.svg.area()
+        .x(function(d) { return self.x_scale(d[self.x_field]); })
+        .y0(function(d) { return y_scale(0); })
+        .y1(function(d) { return y_scale(d[field]); })
+        .defined(function(d) { return gsa.is_defined(d[field]); });
+    }
+
     self.all_y_fields = self.y_fields.concat(self.y2_fields);
 
     var lines = [];
+    var areas = [];
+    var gradients = [];
     var line_index;
     for (line_index = 0; line_index < self.y_fields.length; line_index++) {
       lines.push(y_line(self.y_fields[line_index], self.y_scale));
+      if (self.y_area)
+        areas.push(y_area(self.y_fields[line_index], self.y_scale));
+      else
+        areas.push(null);
     }
     for (line_index = 0; line_index < self.y2_fields.length; line_index++) {
       lines.push(y_line(self.y2_fields[line_index], self.y2_scale));
+      if (self.y2_area)
+        areas.push(y_area(self.y2_fields[line_index], self.y2_scale));
+      else
+        areas.push(null);
     }
 
     var x_min, x_max;
@@ -114,23 +140,43 @@
     var column_info = data.column_info;
 
     function get_rounded_x(mouse_x) {
-      var rounded_x = self.x_step.round(self.x_scale.invert(mouse_x));
+      var rounded_x;
 
-      if (rounded_x.getTime() > x_max.getTime()) {
-        rounded_x = x_max;
+      if (self.is_timeline) {
+        rounded_x = self.x_step.round(self.x_scale.invert(mouse_x));
+        if (rounded_x.getTime() > x_max.getTime()) {
+          rounded_x = x_max;
+        }
+        else if (rounded_x.getTime() < x_min.getTime()) {
+          rounded_x = x_min;
+        }
       }
-      else if (rounded_x.getTime() < x_min.getTime()) {
-        rounded_x = x_min;
+      else {
+        rounded_x = Math.round (self.x_scale.invert(mouse_x))
+        if (rounded_x > x_max) {
+          rounded_x = x_max;
+        }
+        else if (rounded_x < x_min) {
+          rounded_x = x_min;
+        }
       }
       return rounded_x;
     }
 
     function resize_range_marker_elems() {
       var range_left_line_width = 2;
-      var range_right_line_width = 12;
+      var range_right_line_width = 2;
+      if (self.is_timeline) {
+        range_right_line_width = 12;
+      }
       var y_range = self.y_scale.range();
       var points;
 
+      if (self.range_marker_start === null) {
+        return;
+      }
+
+      // Center area
       self.range_marker_elem.select('.range_marker_c')
         .attr('x', self.x_scale(self.range_marker_start))
         .attr('y', 0)
@@ -139,13 +185,29 @@
             self.x_scale(self.range_marker_start))
         .attr('height', y_range[0] - y_range[1]);
 
+      // Left marker
+      points = [
+        self.x_scale(self.range_marker_start),
+        ',',
+        y_range[1],
+        ' ',
+        self.x_scale(self.range_marker_start),
+        ',',
+        y_range[0],
+        ' ',
+        self.x_scale(self.range_marker_start) - range_left_line_width,
+        ',',
+        y_range[0] - range_left_line_width,
+        ' ',
+        self.x_scale(self.range_marker_start) - range_left_line_width,
+        ',',
+        y_range[1] + range_left_line_width,
+      ];
+      points = points.join('');
       self.range_marker_elem.select('.range_marker_l')
-        .attr('x', self.x_scale(self.range_marker_start) -
-            range_left_line_width)
-        .attr('y', 0)
-        .attr('width', range_left_line_width)
-        .attr('height', y_range[0] - y_range[1]);
+        .attr('points', points);
 
+      // Right Marker
       points = [
         self.x_scale(self.range_marker_end),
         ',',
@@ -164,7 +226,6 @@
         y_range[1] + range_right_line_width,
       ];
       points = points.join('');
-
       self.range_marker_elem.select('.range_marker_r')
         .attr('points', points);
     }
@@ -210,20 +271,30 @@
       var value;
       var url;
 
-      if (self.range_marker_start.getTime() >=
-          self.range_marker_end.getTime()) {
-        start = new Date(self.range_marker_end);
-        end = new Date(self.range_marker_start);
+      if (self.is_timeline) {
+        if (self.range_marker_start.getTime() >=
+            self.range_marker_end.getTime()) {
+          start = new Date(self.range_marker_end);
+          end = new Date(self.range_marker_start);
+        } else {
+          start = new Date(self.range_marker_start);
+          end = new Date(self.range_marker_end);
+        }
+        start.setTime(start.getTime() - 60000);
+        end = self.x_step.offset(end, 1);
+        value = [gch.iso_time_format(start), gch.iso_time_format(end)];
       } else {
-        start = new Date(self.range_marker_start);
-        end = new Date(self.range_marker_end);
+        var step = 1;
+        if (self.range_marker_start >= self.range_marker_end) {
+          start = self.range_marker_end + step;
+          end = self.range_marker_start - step;
+        } else {
+          start = self.range_marker_start - step;
+          end = self.range_marker_end + step;
+        }
+        value = [start, end]
       }
 
-      start.setTime(start.getTime() - 60000);
-      end = self.x_step.offset(end, 1);
-
-      value = [gch.iso_time_format(start), gch.iso_time_format(end)];
-
       if (self.range_marker_resize) {
         url = gch.filtered_list_url(
             type, column, value, data.filter_info, 'range');
@@ -288,10 +359,24 @@
         line_x = width / 2;
       }
 
+      var marker_x_changed, info_x_changed;
+      if (self.is_timeline) {
+        marker_x_changed = (self.range_marker_last_x === null ||
+            self.range_marker_last_x.getTime() !== rounded_x.getTime());
+        info_x_changed = (!gsa.is_defined(info_last_x) ||
+            info_last_x.getTime() !== rounded_x.getTime());
+      }
+      else
+      {
+        marker_x_changed =
+            self.range_marker_last_x !== rounded_x;
+        info_x_changed =
+            info_last_x !== rounded_x;
+      }
+
       if (self.range_marker_mouse_down &&
           data.records.length > 1 &&
-          (self.range_marker_last_x === null ||
-           self.range_marker_last_x.getTime() !== rounded_x.getTime()) &&
+          marker_x_changed &&
           (Math.abs(self.range_marker_mouse_start_x - mouse_x) >= 10 ||
            self.range_marker_resize)) {
 
@@ -310,8 +395,7 @@
         resize_range_marker_elems();
       }
 
-      if (!gsa.is_defined(info_last_x) ||
-          info_last_x.getTime() !== rounded_x.getTime()) {
+      if (info_x_changed) {
         var max_line_width;
 
         info_last_x = rounded_x;
@@ -321,27 +405,59 @@
         max_line_width = 0;
 
         if (self.range_marker_resize) {
-          var end_date = self.x_step.offset(self.range_marker_end, 1);
-          end_date.setTime(end_date.getTime() - 1000);
-          var start_time = self.range_marker_start.getTime();
-          var end_time = end_date.getTime();
-          var range_count = 0;
-          for (var index in records) {
-            var record_time = records[index][self.x_field].getTime();
-            if (record_time >= start_time && record_time < end_time) {
-              range_count += records[index].count;
-            } else if (record_time >= end_time) {
-              break;
+          if (self.is_timeline) {
+            var end_date = self.x_step.offset(self.range_marker_end, 1);
+            end_date.setTime(end_date.getTime() - 1000);
+            var start_time = self.range_marker_start.getTime();
+            var end_time = end_date.getTime();
+            var range_count = 0;
+            for (var index in records) {
+              var record_time = records[index][self.x_field].getTime();
+              if (record_time >= start_time && record_time < end_time) {
+                range_count += records[index].count;
+              } else if (record_time >= end_time) {
+                break;
+              }
             }
+            var type = data.column_info.columns.count.type;
+            self.range_info_text_lines[0]
+                .text(gch.date_format(self.range_marker_start));
+            self.range_info_text_lines[1]
+                .text('to ' + gch.date_format(end_date));
+            self.range_info_text_lines[2]
+                .text(gch.resource_type_name_plural(type) + ': ' +
+                    range_count);
           }
-          var type = data.column_info.columns.count.type;
-          self.range_info_text_lines[0]
-              .text(gch.date_format(self.range_marker_start));
-          self.range_info_text_lines[1]
-              .text('to ' + gch.date_format(end_date));
-          self.range_info_text_lines[2]
-              .text(gch.resource_type_name_plural(type) + ': ' +
-                  range_count);
+          else {
+            var type = data.column_info.columns.count.type;
+            var range_count = 0;
+            var x_label = gch.column_label(
+                column_info.columns[self.x_field], true, false,
+                self.show_stat_type)
+            for (var index in records) {
+              var record_val = records[index][self.x_field];
+              if (record_val >= self.range_marker_start &&
+                  record_val <= self.range_marker_end) {
+                range_count += records[index].count;
+              } else if (record_val > self.range_marker_end) {
+                break;
+              }
+            }
+
+            self.range_info_text_lines[0]
+                .text(x_label + ":");
+            if (self.range_marker_start !== self.range_marker_end) {
+              self.range_info_text_lines[1]
+                  .text(self.range_marker_start +
+                      ' to ' + self.range_marker_end);
+            } else {
+              self.range_info_text_lines[1]
+                  .text(self.range_marker_start);
+            }
+            self.range_info_text_lines[2]
+                .text(gch.resource_type_name_plural(type) + ': ' +
+                    range_count);
+          }
         }
 
         var bbox;
@@ -362,6 +478,8 @@
         max_line_width = 0;
         for (line in self.info_text_lines) {
           var d = data.records[line_index];
+          var line_col_info =
+            data.column_info.columns[self.info_text_lines[line].field]
           if (gsa.has_value(d)) {
             d = d[self.info_text_lines[line].field];
 
@@ -372,8 +490,7 @@
                   d = self.duration_tick_format(d);
                   break;
                 default:
-                  d = gch.format_data(d,
-                    
data.column_info.columns[self.info_text_lines[line].field]);
+                  d = gch.format_data(d, line_col_info);
               }
             }
             else if (line >= 1) {
@@ -383,21 +500,25 @@
                   d = self.duration_tick_format(d);
                   break;
                 default:
-                  d = gch.format_data(d,
-                    
data.column_info.columns[self.info_text_lines[line].field]);
+                  d = gch.format_data(d, line_col_info);
               }
             }
             else {
-              d = gch.format_data(d,
-                data.column_info.columns[self.info_text_lines[line].field]);
+              d = gch.format_data(d, line_col_info);
             }
 
             self.info_text_lines[line].elem.text(d);
           }
           else {
             if (line === '0') {
-              self.info_text_lines[line].elem.text(
-                  gch.format_data(rounded_x, {data_type: 'js_date'}));
+              if (self.is_timeline) {
+                self.info_text_lines[line].elem.text(
+                    gch.format_data(rounded_x, {data_type: 'js_date'}));
+              }
+              else {
+                self.info_text_lines[line].elem.text(
+                    gch.format_data(rounded_x), line_col_info);
+              }
             }
             else {
               self.info_text_lines[line].elem.text('N/A');
@@ -529,6 +650,8 @@
 
     if (update) {
       svg.text('');
+      self.defs = svg.append ('defs');
+
       self.svg = svg.append('g');
 
       self.svg.attr('transform',
@@ -574,8 +697,32 @@
         .call(self.y2_axis);
 
       for (index = 0; index < self.all_y_fields.length; index++) {
+        gradients[index] = null;
+
+        if (areas[index] === null) {
+          continue;
+        }
+
+        var fill;
+        if (gradients[index]) {
+          fill = 'url(\'#gradient_' + index + '\')';
+        }
+        else {
+          fill = self.scaleColor(self.all_y_fields[index]);
+        }
+
         var new_path = self.svg.append('path');
         new_path
+          .attr('id', 'area_' + index)
+          .datum(records)
+          .style('fill', fill)
+          .style('opacity', 0.33)
+          .attr('d', areas[index]);
+      }
+
+      for (index = 0; index < self.all_y_fields.length; index++) {
+        var new_path = self.svg.append('path');
+        new_path
           .attr('id', 'line_' + index)
           .datum(records)
           .style('fill', 'transparent')
@@ -632,7 +779,7 @@
           .style('opacity', '0.125');
 
       self.range_marker_elem
-        .append('rect')
+        .append('polygon')
           .attr('class', 'range_marker_l')
           .style('fill', '#008800')
           .style('opacity', '0.25');
@@ -792,6 +939,14 @@
       .call(self.y2_axis)
       .attr('transform', 'translate(' + width + ', 0)');
 
+    for (index = 0; index < areas.length; index++) {
+      if (areas[index] === null)
+        continue;
+      self.svg.select('#area_' + index)
+        .datum(records)
+        .attr('d', areas[index]);
+    }
+
     for (index = 0; index < lines.length; index++) {
       self.svg.select('#line_' + index)
         .datum(records)
@@ -926,6 +1081,19 @@
       this.x_field = gen_params.x_field;
     }
 
+    this.is_timeline = false;
+    this.y_area = false;
+    this.y2_area = false;
+
+    if (gsa.is_defined (gen_params.extra)) {
+      if (gsa.is_defined (gen_params.extra.is_timeline))
+        this.is_timeline = gen_params.extra.is_timeline;
+      if (gsa.is_defined (gen_params.extra.y_area))
+        this.y_area = gen_params.extra.y_area;
+      if (gsa.is_defined (gen_params.extra.y2_area))
+        this.y2_area = gen_params.extra.y2_area;
+    }
+
     if (gen_params.y_fields && gen_params.y_fields[0]  &&
       gen_params.z_fields && gen_params.z_fields[0]) {
       this.y_fields = gen_params.y_fields;
@@ -960,6 +1128,15 @@
     else {
       this.fillers = {};
     }
+
+    if (this.is_timeline) {
+      this.x_scale = d3.time.scale.utc();
+      this.x_axis = 
d3.svg.axis().scale(this.x_scale).orient('bottom').ticks(6);
+      this.setDataTransformFunc(this.timeLine);
+    }
+    else if (1) {
+      this.setDataTransformFunc(gch.fill_in_numbered_records);
+    }
   };
 
   LineChartGenerator.prototype.timeLine = function(old_data) {

Modified: trunk/gsa/src/html/classic/ng/src/web/dashboard/commoncharts.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/dashboard/commoncharts.js     
2017-01-13 15:26:40 UTC (rev 27209)
+++ trunk/gsa/src/html/classic/ng/src/web/dashboard/commoncharts.js     
2017-01-13 15:30:09 UTC (rev 27210)
@@ -60,7 +60,8 @@
           name={type + '-by-created'}
           title={_('{{title}} by creation time', {title: titleType})}
           title-count="count"
-          type="line"/>
+          type="line"
+          gen-params={{is_timeline: 1}}/>
       </DataSource>
     </div>
   );

Modified: trunk/gsa/src/html/classic/ng/src/web/hosts/charts.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/hosts/charts.js       2017-01-13 
15:26:40 UTC (rev 27209)
+++ trunk/gsa/src/html/classic/ng/src/web/hosts/charts.js       2017-01-13 
15:30:09 UTC (rev 27210)
@@ -86,7 +86,8 @@
           title-count="count"
           y-fields={['c_count', 'c_count[High]']}
           z-fields={['count', 'count[High]']}
-          type="line"/>
+          type="line"
+          gen-params={{is_timeline: 1}}/>
       </DataSource>
       <DataSource
         name="host-topology-source"

Modified: trunk/gsa/src/html/classic/ng/src/web/notes/charts.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/notes/charts.js       2017-01-13 
15:26:40 UTC (rev 27209)
+++ trunk/gsa/src/html/classic/ng/src/web/notes/charts.js       2017-01-13 
15:30:09 UTC (rev 27210)
@@ -43,7 +43,8 @@
           name="note-by-created"
           title={_('Notes by creation time')}
           title-count="count"
-          type="line"/>
+          type="line"
+          gen-params={{is_timeline: 1}}/>
       </DataSource>
       <DataSource
         name="note-text-words-source"

Modified: trunk/gsa/src/html/classic/ng/src/web/overrides/charts.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/overrides/charts.js   2017-01-13 
15:26:40 UTC (rev 27209)
+++ trunk/gsa/src/html/classic/ng/src/web/overrides/charts.js   2017-01-13 
15:30:09 UTC (rev 27210)
@@ -43,7 +43,8 @@
           name="override-by-created"
           title={_('Overrides by creation time')}
           title-count="count"
-          type="line"/>
+          type="line"
+          gen-params={{is_timeline: 1}}/>
       </DataSource>
       <DataSource
         name="override-text-words-source"

Modified: trunk/gsa/src/html/classic/ng/src/web/reports/charts.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/reports/charts.js     2017-01-13 
15:26:40 UTC (rev 27209)
+++ trunk/gsa/src/html/classic/ng/src/web/reports/charts.js     2017-01-13 
15:30:09 UTC (rev 27210)
@@ -45,7 +45,7 @@
           y-fields={['high_max']}
           z-fields={['high_per_host_max']}
           title={_('Reports: High results timeline')}
-          gen-params={{show_stat_type: 0}}/>
+          gen-params={{show_stat_type: 0, is_timeline: 1}}/>
       </DataSource>
       <DataSource
         name="report-severity-count-source"

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to