Search in sources :

Example 1 with Chart

use of com.github.lindenb.jvarkit.chart.Chart in project jvarkit by lindenb.

the class BamStatsJfx method save.

private void save() throws IOException {
    try (final PrintWriter pw = super.openFileOrStdoutAsPrintWriter(this.outputFile)) {
        final RExporter exporter = new RExporter();
        for (final ChartGenerator cg : this.chartGenerators) {
            LOG.info("saving " + cg.getChartTitle());
            if (!cg.isEnabled())
                continue;
            final Chart chart = cg.makeChart();
            if (chart == null)
                continue;
            exporter.exportToR(pw, chart);
        }
        pw.flush();
    }
}
Also used : RExporter(com.github.lindenb.jvarkit.chart.RExporter) LineChart(com.github.lindenb.jvarkit.chart.LineChart) XYChart(com.github.lindenb.jvarkit.chart.XYChart) BarChart(com.github.lindenb.jvarkit.chart.BarChart) Chart(com.github.lindenb.jvarkit.chart.Chart) StackedBarChart(com.github.lindenb.jvarkit.chart.StackedBarChart) PrintWriter(java.io.PrintWriter)

Example 2 with Chart

use of com.github.lindenb.jvarkit.chart.Chart in project jvarkit by lindenb.

the class VcfStatsJfx method save.

private void save() throws IOException {
    try (final PrintWriter pw = super.openFileOrStdoutAsPrintWriter(this.outputFile)) {
        final RExporter exporter = new RExporter();
        for (final ChartGenerator cg : this.chartGenerators) {
            LOG.info("saving " + cg.getChartTitle());
            if (!cg.isEnabled())
                continue;
            final Chart chart = cg.makeChart();
            if (chart == null)
                continue;
            exporter.exportToR(pw, chart);
        }
        pw.flush();
    }
}
Also used : RExporter(com.github.lindenb.jvarkit.chart.RExporter) XYChart(com.github.lindenb.jvarkit.chart.XYChart) BarChart(com.github.lindenb.jvarkit.chart.BarChart) Chart(com.github.lindenb.jvarkit.chart.Chart) StackedBarChart(com.github.lindenb.jvarkit.chart.StackedBarChart) PrintWriter(java.io.PrintWriter)

Example 3 with Chart

use of com.github.lindenb.jvarkit.chart.Chart in project jvarkit by lindenb.

the class SimplePlot method doWork.

@Override
public int doWork(final List<String> args) {
    Chart chartNode = null;
    try {
        final BufferedReader br = super.openBufferedReader(oneFileOrNull(args));
        this.lineSupplier = () -> {
            try {
                for (; ; ) {
                    final String L = br.readLine();
                    if (L == null)
                        return null;
                    return L;
                }
            } catch (final IOException err) {
                throw new RuntimeIOException(err);
            }
        };
        switch(this.chartType) {
            case BEDGRAPH:
                {
                    chartNode = new BedGraphSupplier().get();
                    break;
                }
            case PIE:
                chartNode = new PieChartSupplier().get();
                break;
            case SIMPLE_HISTOGRAM:
                chartNode = new SimpleHistogramSupplier().get();
                break;
            case HISTOGRAM:
                chartNode = new HistogramSupplier().get();
                break;
            case STACKED_HISTOGRAM:
                chartNode = new StackedHistogramSupplier().get();
                break;
            case STACKED_HISTOGRAM_PIVOTED:
                chartNode = new StackedHistogramPivoted().get();
                break;
            case XYV:
            case STACKED_XYV:
                chartNode = new XYVHistogramSupplier().setStacked(this.chartType == PlotType.STACKED_XYV).get();
                break;
            case HEATMAP:
                chartNode = new HeatmapSupplier().get();
                break;
            default:
                {
                    LOG.error("Bad chart type : " + this.chartType);
                    return -1;
                }
        }
        CloserUtil.close(br);
        if (chartNode == null) {
            LOG.error("No chart was generated");
            return -1;
        }
        if (StringUtil.isBlank(this.chartTitle)) {
            chartNode.setLegendVisible(false);
        } else {
            // chart.setTitleSide(this.titleSide);
            chartNode.setTitle(this.chartTitle);
        }
        // chart.setLegendSide(this.legendSide);
        chartNode.setLegendVisible(!this.hide_legend);
        try (PrintWriter pw = super.openFileOrStdoutAsPrintWriter(this.outputFile)) {
            final RExporter exporter = new RExporter();
            exporter.exportToR(pw, chartNode);
            pw.flush();
        }
    } catch (final Exception err) {
        LOG.error(err);
        return -1;
    } finally {
    }
    return 0;
}
Also used : RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) IOException(java.io.IOException) RExporter(com.github.lindenb.jvarkit.chart.RExporter) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) IOException(java.io.IOException) JvarkitException(com.github.lindenb.jvarkit.lang.JvarkitException) BufferedReader(java.io.BufferedReader) HeatMapChart(com.github.lindenb.jvarkit.chart.HeatMapChart) ScatterChart(com.github.lindenb.jvarkit.chart.ScatterChart) BubbleChart(com.github.lindenb.jvarkit.chart.BubbleChart) XYChart(com.github.lindenb.jvarkit.chart.XYChart) BarChart(com.github.lindenb.jvarkit.chart.BarChart) PieChart(com.github.lindenb.jvarkit.chart.PieChart) Chart(com.github.lindenb.jvarkit.chart.Chart) StackedBarChart(com.github.lindenb.jvarkit.chart.StackedBarChart) PrintWriter(java.io.PrintWriter)

Aggregations

BarChart (com.github.lindenb.jvarkit.chart.BarChart)3 Chart (com.github.lindenb.jvarkit.chart.Chart)3 RExporter (com.github.lindenb.jvarkit.chart.RExporter)3 StackedBarChart (com.github.lindenb.jvarkit.chart.StackedBarChart)3 XYChart (com.github.lindenb.jvarkit.chart.XYChart)3 PrintWriter (java.io.PrintWriter)3 BubbleChart (com.github.lindenb.jvarkit.chart.BubbleChart)1 HeatMapChart (com.github.lindenb.jvarkit.chart.HeatMapChart)1 LineChart (com.github.lindenb.jvarkit.chart.LineChart)1 PieChart (com.github.lindenb.jvarkit.chart.PieChart)1 ScatterChart (com.github.lindenb.jvarkit.chart.ScatterChart)1 JvarkitException (com.github.lindenb.jvarkit.lang.JvarkitException)1 RuntimeIOException (htsjdk.samtools.util.RuntimeIOException)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1