net.opentsdb.graph
public final class Plot extends Object
This class takes a bunch of DataPoints
instances and generates a
Gnuplot script as well as the corresponding data files to feed to Gnuplot.
Constructor and Description |
---|
Plot(long start_time,
long end_time)
Constructor.
|
Plot(long start_time,
long end_time,
TimeZone tz)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(DataPoints datapoints,
String options)
Adds some data points to this plot.
|
int |
dumpToFiles(String basepath)
Generates the Gnuplot script and data files.
|
Iterable<DataPoints> |
getDataPoints()
Returns a view on the datapoints in this plot.
|
void |
setDimensions(short width,
short height)
Sets the dimensions of the graph (in pixels).
|
void |
setGlobals(List<Annotation> globals) |
void |
setParams(Map<String,String> params)
Sets the global parameters for this plot.
|
public Plot(long start_time, long end_time)
start_time
- Timestamp of the start time of the graph.end_time
- Timestamp of the end time of the graph.IllegalArgumentException
- if either timestamp is 0 or negative.IllegalArgumentException
- if start_time >= end_time
.public Plot(long start_time, long end_time, TimeZone tz)
start_time
- Timestamp of the start time of the graph.end_time
- Timestamp of the end time of the graph.tz
- Timezone to use to render the timestamps.
If null
the current timezone as of when the JVM started is used.IllegalArgumentException
- if either timestamp is 0 or negative.IllegalArgumentException
- if start_time >= end_time
.public void setParams(Map<String,String> params)
params
- Each entry is a Gnuplot setting that will be written as-is
in the Gnuplot script file: set KEY VALUE
.
When the value is null
the script will instead contain
unset KEY
.
Special parameters with a special meaning (since OpenTSDB 1.1):
bgcolor
: Either transparent
or an RGB color in
hexadecimal (with a leading 'x' as in x01AB23
).fgcolor
: An RGB color in hexadecimal (x42BEE7
).public void setDimensions(short width, short height)
width
- The width of the graph produced (in pixels).height
- The height of the graph produced (in pixels).IllegalArgumentException
- if the width or height are negative,
zero or "too small" (e.g. less than 100x100 pixels).public void setGlobals(List<Annotation> globals)
globals
- A list of global annotation objects, may be nullpublic void add(DataPoints datapoints, String options)
datapoints
- The data points to plot.options
- The options to apply to this specific series.public Iterable<DataPoints> getDataPoints()
public int dumpToFiles(String basepath) throws IOException
basepath
- The base path to use. A number of new files will be
created and their names will all start with this string.IOException
- if there was an error while writing one of the files.