private ChartPanel createChartPanel(final ValueCountingAnalyzerResult result) {
        if (_valueCounts.size() > ChartUtils.CATEGORY_COUNT_DISPLAY_THRESHOLD) {
            logger.info("Display threshold of {} in chart surpassed (got {}). Skipping chart.",
                    ChartUtils.CATEGORY_COUNT_DISPLAY_THRESHOLD, _valueCounts.size());
            return null;
        }

        final Integer distinctCount = result.getDistinctCount();
        final Integer unexpectedValueCount = result.getUnexpectedValueCount();
        final int totalCount = result.getTotalCount();

        // chart for display of the dataset
        final String title = "Value distribution of " + _groupOrColumnName;
        final JFreeChart chart = ChartFactory
                .createBarChart(title, "Value", "Count", _dataset, PlotOrientation.HORIZONTAL, true, true, false);

        final List<Title> titles = new ArrayList<>();
        titles.add(new ShortTextTitle("Total count: " + totalCount));
        if (distinctCount != null) {
            titles.add(new ShortTextTitle("Distinct count: " + distinctCount));
        }
        if (unexpectedValueCount != null) {
            titles.add(new ShortTextTitle("Unexpected value count: " + unexpectedValueCount));
        }
        chart.setSubtitles(titles);

        ChartUtils.applyStyles(chart);

        // code-block for tweaking style and coloring of chart
        {
            final CategoryPlot plot = (CategoryPlot) chart.getPlot();
            plot.getDomainAxis().setVisible(false);

            int colorIndex = 0;
            for (int i = 0; i < getDataSetItemCount(); i++) {
                final String key = getDataSetKey(i);
                final Color color;
                final String upperCaseKey = key.toUpperCase();
                if (_valueColorMap.containsKey(upperCaseKey)) {
                    color = _valueColorMap.get(upperCaseKey);
                } else {
                    if (i == getDataSetItemCount() - 1) {
                        // the last color should not be the same as the first
                        if (colorIndex == 0) {
                            colorIndex++;
                        }
                    }

                    Color colorCandidate = SLICE_COLORS[colorIndex];
                    final int darkAmount = i / SLICE_COLORS.length;
                    for (int j = 0; j < darkAmount; j++) {
                        colorCandidate = WidgetUtils.slightlyDarker(colorCandidate);
                    }
                    color = colorCandidate;

                    colorIndex++;
                    if (colorIndex >= SLICE_COLORS.length) {
                        colorIndex = 0;
                    }
                }

                plot.getRenderer().setSeriesPaint(i, color);
            }
        }

        return ChartUtils.createPanel(chart, false);
    }
private ChartPanel createChartPanel ( final ValueCountingAnalyzerResult result ) { if ( _valueCounts . size ( ) > ChartUtils . CATEGORY_COUNT_DISPLAY_THRESHOLD ) { logger . info ( "Display threshold of {} in chart surpassed (got {}). Skipping chart." , ChartUtils . CATEGORY_COUNT_DISPLAY_THRESHOLD , _valueCounts . size ( ) ) ; return null ; } final Integer distinctCount = result . getDistinctCount ( ) ; final Integer unexpectedValueCount = result . getUnexpectedValueCount ( ) ; final int totalCount = result . getTotalCount ( ) ; final String title = "Value distribution of " + _groupOrColumnName ; final JFreeChart chart = ChartFactory . createBarChart ( title , "Value" , "Count" , _dataset , PlotOrientation . HORIZONTAL , true , true , false ) ; final List < Title > titles = new ArrayList < > ( ) ; titles . add ( new ShortTextTitle ( "Total count: " + totalCount ) ) ; if ( distinctCount != null ) { titles . add ( new ShortTextTitle ( "Distinct count: " + distinctCount ) ) ; } if ( unexpectedValueCount != null ) { titles . add ( new ShortTextTitle ( "Unexpected value count: " + unexpectedValueCount ) ) ; } chart . setSubtitles ( titles ) ; ChartUtils . applyStyles ( chart ) ; { final CategoryPlot plot = ( CategoryPlot ) chart . getPlot ( ) ; plot . getDomainAxis ( ) . setVisible ( false ) ; int colorIndex = 0 ; for ( int i = 0 ; i < getDataSetItemCount ( ) ; i ++ ) { final String key = getDataSetKey ( i ) ; final Color color ; final String upperCaseKey = key . toUpperCase ( ) ; if ( _valueColorMap . containsKey ( upperCaseKey ) ) { color = _valueColorMap . get ( upperCaseKey ) ; } else { if ( i == getDataSetItemCount ( ) - 1 ) { if ( colorIndex == 0 ) { colorIndex ++ ; } } Color colorCandidate = SLICE_COLORS [ colorIndex ] ; final int darkAmount = i / SLICE_COLORS . length ; for ( int j = 0 ; j < darkAmount ; j ++ ) { colorCandidate = WidgetUtils . slightlyDarker ( colorCandidate ) ; } color = colorCandidate ; colorIndex ++ ; if ( colorIndex >= SLICE_COLORS . length ) { colorIndex = 0 ; } } plot . getRenderer ( ) . setSeriesPaint ( i , color ) ; } } return ChartUtils . createPanel ( chart , false ) ; }
Creates a chart panel, or null if chart display is not applicable.

@param result
@return