diff --git a/views/vpl_grapher.class.php b/views/vpl_grapher.class.php
index 236aab2b10ab535eedd16b2086f61c0390ba6622..8c73967053109c226fb27e61968f08661e8f5c82 100644
--- a/views/vpl_grapher.class.php
+++ b/views/vpl_grapher.class.php
@@ -184,9 +184,6 @@ class vpl_grapher {
                 $i++;
             }
             if ($diff && count($names) > 1) {
-                $names[] = get_string('total');
-                $series[get_string('total')] = $totalseries;
-
                 // Filter out all zero-diff files.
                 $names = array_filter($names, function($name) use(&$series){
                     foreach ($series[$name] as $value){
@@ -198,6 +195,12 @@ class vpl_grapher {
                     unset($series[$name]);
                     return false;
                 });
+
+                if (count($names) != 1) {
+                    // Add Total series.
+                    $names[] = get_string('total');
+                    $series[get_string('total')] = $totalseries;
+                }
             }
             self::draw( $title, get_string( 'submissions', VPL ) , get_string( "sizeb" ), $subsn, $series, $names );
         } catch (moodle_exception $e) {