public static DataSeries parse(File file) throws NumberFormatException, IOException {
    DataSeries result = new DataSeries();

    BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

    try {
      boolean isFirstLine = true;
      String line;
      while ((line = reader.readLine()) != null) {
        if (isFirstLine) {
          isFirstLine = false;
          continue;
        }

        String[] parts = line.split("\\s+");
        if (parts.length != 3) {
          throw new RuntimeException(
              "In file " + file.getAbsolutePath() + ": Invalid line encountered: " + line);
        }

        Number value = Double.parseDouble(parts[0]);
        Number before = Double.parseDouble(parts[1]);
        Number after = Double.parseDouble(parts[1]);

        result.add(value, before, after);
      }
    } finally {
      reader.close();
    }

    return result;
  }
  private void fillScatter(DataSeries series, int points) {
    Random random = new Random();
    for (int i = 0; i < points; i++) {
      double x = random.nextDouble() * 30 + 150;
      double y = 60;
      if (random.nextBoolean()) {
        y += random.nextDouble() * 15;
        if (random.nextBoolean() && x > 170) {
          y += random.nextDouble() * 30;
        }
      } else {
        y -= random.nextDouble() * 20;
      }
      x = Math.floor(x * 10) / 10;
      y = Math.floor(y * 10) / 10;

      int colorNumber = (int) Math.floor((x - 150) / 30 * 255);

      Color color = new SolidColor(colorNumber, 0, 255 - colorNumber);
      DataSeriesItem item = new DataSeriesItem(x, y);
      // item.setColor(color);
      series.add(item);
    }
  }