<commit_before>package com.github.esfbench.chartgen;

import static com.github.esfbench.chartgen.BenchmarkUtil.toDatasets;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.DefaultCategoryDataset;

import com.github.esfbench.chartgen.model.Benchmark;
import com.github.esfbench.chartgen.model.Benchmark.BenchmarkGroup;
import com.github.esfbench.chartgen.model.BenchmarkCollection;
import com.github.esfbench.chartgen.model.ResultTable;

public final class ChartWriterFactory {
	private ChartWriterFactory() {}
	
	private static void generateChart(String benchmark, DefaultCategoryDataset dataset) {
		JFreeChart chart = ChartFactory.createBarChart(
				benchmark, "framework", "throughput", dataset,
				PlotOrientation.HORIZONTAL, true, false, false);
		
		CategoryPlot plot = chart.getCategoryPlot();
		BarRenderer renderer = (BarRenderer) plot.getRenderer();
		renderer.setItemMargin(0);
		
		
		String pngFile = getOutputName(benchmark);
		
		try {
			ChartUtilities.saveChartAsPNG(new File(pngFile), chart, 600, 500);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static void generate(String benchmark, Map<Integer, DefaultCategoryDataset> data) {
		
		for (Entry<Integer, DefaultCategoryDataset> entry : data.entrySet()) {
			String title = benchmark + ": " + entry.getKey() + " entities";
			generateChart(title, entry.getValue());
		}
	}
	
	private static String getOutputName(String benchmark) {
		return benchmark.replaceAll("[: /]", "_") + ".png";<commit_msg>tweaking image size<commit_after>package com.github.esfbench.chartgen;

import static com.github.esfbench.chartgen.BenchmarkUtil.toDatasets;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.data.category.DefaultCategoryDataset;

import com.github.esfbench.chartgen.model.Benchmark;
import com.github.esfbench.chartgen.model.Benchmark.BenchmarkGroup;
import com.github.esfbench.chartgen.model.BenchmarkCollection;
import com.github.esfbench.chartgen.model.ResultTable;

public final class ChartWriterFactory {
	private ChartWriterFactory() {}
	
	private static void generateChart(String benchmark, DefaultCategoryDataset dataset) {
		JFreeChart chart = ChartFactory.createBarChart(
				benchmark, "framework", "throughput", dataset,
				PlotOrientation.HORIZONTAL, true, false, false);
		
		CategoryPlot plot = chart.getCategoryPlot();
		BarRenderer renderer = (BarRenderer) plot.getRenderer();
		renderer.setItemMargin(0);
		
		
		String pngFile = getOutputName(benchmark);
		
		try {
			ChartUtilities.saveChartAsPNG(new File(pngFile), chart, 700, 450);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static void generate(String benchmark, Map<Integer, DefaultCategoryDataset> data) {
		
		for (Entry<Integer, DefaultCategoryDataset> entry : data.entrySet()) {
			String title = benchmark + ": " + entry.getKey() + " entities";
			generateChart(title, entry.getValue());
		}
	}
	
	private static String getOutputName(String benchmark) {
		return benchmark.replaceAll("[: /]", "_") + ".png";
{'fraction_non_alphanumeric': 0.11325818572195384, 'fraction_numerical': 0.003757380568974772, 'mean_word_length': 5.3709401709401705, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4443874', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1132, 'n_words': 225}