Skip to content

Commit 6292382

Browse files
committed
Gnuplot produces empty string when no plot in Dumb format
1 parent f4f054d commit 6292382

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

  • Source/Gnuplot/src/ca/uqac/lif/spreadsheet/chart/gnuplot

Source/Gnuplot/src/ca/uqac/lif/spreadsheet/chart/gnuplot/Gnuplot.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
A provenance-aware spreadsheet library
3-
Copyright (C) 2021 Sylvain Hallé
3+
Copyright (C) 2021-2022 Sylvain Hallé
44
55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU Lesser General Public License as published by
@@ -46,7 +46,7 @@ public abstract class Gnuplot implements Chart, ExplanationQueryable
4646
* The "dumb" plot format supported by GnuPlot.
4747
*/
4848
public static final transient ChartFormat DUMB = new ChartFormat("dumb", "txt", "text/plain");
49-
49+
5050
/**
5151
* The "GP" plot format. This simply outputs the Gnuplot text file that
5252
* Gnuplot uses to render a plot.
@@ -212,7 +212,7 @@ public Gnuplot setCustomHeader(String s)
212212
m_customParameters = s;
213213
return this;
214214
}
215-
215+
216216
/**
217217
* Generates a stand-alone Gnuplot file for this plot, and prints it to a
218218
* print stream.
@@ -284,7 +284,14 @@ public final Gnuplot render(OutputStream os, Spreadsheet table, ChartFormat term
284284
{
285285
os.write(s_blankImagePdf);
286286
}
287-
os.write(s_blankImagePng);
287+
else if (term.equals(DUMB))
288+
{
289+
os.write(new byte[] {});
290+
}
291+
else
292+
{
293+
os.write(s_blankImagePng);
294+
}
288295
return this;
289296
}
290297
}
@@ -296,6 +303,10 @@ public final Gnuplot render(OutputStream os, Spreadsheet table, ChartFormat term
296303
{
297304
image = s_blankImagePdf;
298305
}
306+
else if (term.equals(DUMB))
307+
{
308+
image = new byte[0];
309+
}
299310
else
300311
{
301312
image = s_blankImagePng;
@@ -365,7 +376,7 @@ protected void printHeader(PrintStream out, ChartFormat term, String comment_lin
365376
out.println(m_customParameters);
366377
}
367378
}
368-
379+
369380
/**
370381
* Sets the color palette to be used to render the plot.
371382
* @param p The palette
@@ -595,7 +606,7 @@ protected void explainChartPart(Part to_explain, Part suffix, PartNode root, Nod
595606
{
596607
root.addChild(f.getUnknownNode());
597608
}
598-
609+
599610
/**
600611
* Gets the Gnuplot string corresponding to the definition of a
601612
* discrete palette.

0 commit comments

Comments
 (0)