public void doRespondingTimeGraph(StaplerRequest request, StaplerResponse response)
      throws IOException {
    PerformanceReportPosition performanceReportPosition = new PerformanceReportPosition();
    request.bindParameters(performanceReportPosition);
    String performanceReportNameFile = performanceReportPosition.getPerformanceReportPosition();
    if (performanceReportNameFile == null) {
      if (getPerformanceReportList().size() == 1) {
        performanceReportNameFile = getPerformanceReportList().get(0);
      } else {
        return;
      }
    }
    if (ChartUtil.awtProblemCause != null) {
      // not available. send out error message
      response.sendRedirect2(request.getContextPath() + "/images/headless.png");
      return;
    }
    DataSetBuilder<String, NumberOnlyBuildLabel> dataSetBuilderAverage =
        new DataSetBuilder<String, NumberOnlyBuildLabel>();
    List<?> builds = getProject().getBuilds();
    List<Integer> buildsLimits = getFirstAndLastBuild(request, builds);

    int nbBuildsToAnalyze = builds.size();
    for (Iterator<?> iterator = builds.iterator(); iterator.hasNext(); ) {
      AbstractBuild<?, ?> currentBuild = (AbstractBuild<?, ?>) iterator.next();
      if (nbBuildsToAnalyze <= buildsLimits.get(1) && buildsLimits.get(0) <= nbBuildsToAnalyze) {
        NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild);
        PerformanceBuildAction performanceBuildAction =
            currentBuild.getAction(PerformanceBuildAction.class);
        if (performanceBuildAction == null) {
          continue;
        }
        PerformanceReport performanceReport =
            performanceBuildAction
                .getPerformanceReportMap()
                .getPerformanceReport(performanceReportNameFile);
        if (performanceReport == null) {
          nbBuildsToAnalyze--;
          continue;
        }
        dataSetBuilderAverage.add(
            performanceReport.getMedian(), Messages.ProjectAction_Median(), label);
        dataSetBuilderAverage.add(
            performanceReport.getAverage(), Messages.ProjectAction_Average(), label);
        dataSetBuilderAverage.add(
            performanceReport.get90Line(), Messages.ProjectAction_Line90(), label);
      }
      nbBuildsToAnalyze--;
    }
    ChartUtil.generateGraph(
        request, response, createRespondingTimeChart(dataSetBuilderAverage.build()), 400, 200);
  }
  private CategoryDataset buildDataSet(Map<LocalDate, TestResultSummary> summaries) {
    DataSetBuilder<String, LocalDateLabel> dsb = new DataSetBuilder<String, LocalDateLabel>();

    for (Map.Entry<LocalDate, TestResultSummary> entry : summaries.entrySet()) {
      LocalDateLabel label = new LocalDateLabel(entry.getKey());

      switch (getDisplayStatusEnum()) {
        case SUCCESS:
          dsb.add(entry.getValue().getSuccess(), Messages.Dashboard_Total(), label);
          break;
        case SKIPPED:
          dsb.add(entry.getValue().getSkipped(), Messages.Dashboard_Skipped(), label);
          break;
        case FAILED:
          dsb.add(entry.getValue().getFailed(), Messages.Dashboard_Failed(), label);
          break;
        default:
          dsb.add(entry.getValue().getSuccess(), Messages.Dashboard_Total(), label);
          dsb.add(entry.getValue().getFailed(), Messages.Dashboard_Failed(), label);
          dsb.add(entry.getValue().getSkipped(), Messages.Dashboard_Skipped(), label);
      }
    }
    return dsb.build();
  }
  private DataSetBuilder getTrendReportData(
      final StaplerRequest request, String performanceReportNameFile) {

    DataSetBuilder<String, NumberOnlyBuildLabel> dataSet =
        new DataSetBuilder<String, NumberOnlyBuildLabel>();
    List<?> builds = getProject().getBuilds();
    List<Integer> buildsLimits = getFirstAndLastBuild(request, builds);

    int nbBuildsToAnalyze = builds.size();
    for (Iterator<?> iterator = builds.iterator(); iterator.hasNext(); ) {
      AbstractBuild<?, ?> currentBuild = (AbstractBuild<?, ?>) iterator.next();
      if (nbBuildsToAnalyze <= buildsLimits.get(1) && buildsLimits.get(0) <= nbBuildsToAnalyze) {
        NumberOnlyBuildLabel label = new NumberOnlyBuildLabel(currentBuild);
        PerformanceBuildAction performanceBuildAction =
            currentBuild.getAction(PerformanceBuildAction.class);
        if (performanceBuildAction == null) {
          continue;
        }
        PerformanceReport report = null;
        report =
            performanceBuildAction
                .getPerformanceReportMap()
                .getPerformanceReport(performanceReportNameFile);
        if (report == null) {
          nbBuildsToAnalyze--;
          continue;
        }
        dataSet.add(Math.round(report.getAverage()), Messages.ProjectAction_Average(), label);
        dataSet.add(Math.round(report.getMedian()), Messages.ProjectAction_Median(), label);
        dataSet.add(Math.round(report.get90Line()), Messages.ProjectAction_Line90(), label);
        dataSet.add(Math.round(report.getMin()), Messages.ProjectAction_Minimum(), label);
        dataSet.add(Math.round(report.getMax()), Messages.ProjectAction_Maximum(), label);
        dataSet.add(
            Math.round(report.errorPercent()), Messages.ProjectAction_PercentageOfErrors(), label);
        dataSet.add(Math.round(report.countErrors()), Messages.ProjectAction_Errors(), label);
      }
      nbBuildsToAnalyze--;
    }
    return dataSet;
  }