docs: public int dumpToFiles(final String basepath) throws IOException {
      int npoints = 0;
      final int nseries = datapoints.size();
      final String datafiles[] = nseries > 0 ? new String[nseries] : null;
      FileSystem.checkDirectory(new File(basepath).getParent(),
          Const.MUST_BE_WRITEABLE, Const.CREATE_IF_NEEDED);
      for (int i = 0; i < nseries; i++) {
        datafiles[i] = basepath + "_" + i + ".dat";
        final PrintWriter datafile = new PrintWriter(datafiles[i]);
        try {
          for (final DataPoint d : datapoints.get(i)) {
            final long ts = d.timestamp() / 1000;          
            if (d.isInteger()) {
              datafile.print(ts + utc_offset);
              datafile.print(' ');
              datafile.print(d.longValue());
            } else {
              final double value = d.doubleValue();
  
              if (Double.isInfinite(value)) {
                // Infinity is invalid.
                throw new IllegalStateException("Infinity found in"
                    + " datapoints #" + i + ": " + value + " d=" + d);
              } else if (Double.isNaN(value)) {
                // NaNs should be skipped.
                continue;
              }
  
              datafile.print(ts + utc_offset);
              datafile.print(' ');
              datafile.print(value);
            }
            
            datafile.print('\n');
            
            if (ts >= (start_time & UNSIGNED) && ts <= (end_time & UNSIGNED)) {
              npoints++;
            }
          }
        } finally {
          datafile.close();
        }
      }
  
      if (npoints == 0) {
        // Gnuplot doesn't like empty graphs when xrange and yrange aren't
        // entirely defined, because it can't decide on good ranges with no
        // data.  We always set the xrange, but the yrange is supplied by the
        // user.  Let's make sure it defines a min and a max.
        params.put("yrange", "[0:10]");  // Doesn't matter what values we use.
      }
      writeGnuplotScript(basepath, datafiles);
      return npoints;
    }