public void doErrorsGraph(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> dataSetBuilderErrors =
        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;
        }
        dataSetBuilderErrors.add(
            performanceReport.errorPercent(), Messages.ProjectAction_Errors(), label);
      }
      nbBuildsToAnalyze--;
    }
    ChartUtil.generateGraph(
        request, response, createErrorsChart(dataSetBuilderErrors.build()), 400, 200);
  }
  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;
  }