Dataset Class
The Dataset class represents one dataset loaded in PrestoPlot. It gives access to its properties/attributes and its data values.
Public Properties
dateformat
description
length(read only)
name
source
unit
xlabel
Public Functions
addPoint(date, value)
addPointRealTime(date, value)
addPoints(dates, values)
adjustDate(from, to, format)
convertToSeconds()
removeLabels()
setLabel(value, label)
sort()
spreadlabels(keepUnused)
x(indexFrom, indexTo)
y(indexFrom, indexTo)
Detailed Properties Descriptions
dateformat
dateformat
The original date format (see DateManager)
description
description
The dataset description
length (read only)
length
Get the dataset length, that is, its number of points.
Return : An integer representing the number of points.
name
name
The displayed name of the dataset
source
source
Indicates the origin of the dataset (file name, computed, socket, ...).
unit
unit
The dataset unit
xlabel
xlabel
The XLabel that can be displayed on graphs.
Detailed Functions Descriptions
addPoint
addPoint(date, value)
Append a point at the end of the dataset. The point will not be inserted in the middle of the dataset if the date is within the current range (instead, the plot will go backward).
If you intend to add several points, prefer building a buffered list of x values and y values, and use addPoints
If you intend to add points in a real-time way (for example from a stream), prefer using addPointRealTime.
Parameters :
-
date: The point date in the unix GMT format. -
value: The point value at the given date. The value can be either a double value or a label.
addPointRealTime
addPointRealTime(date, value)
Append a point at the end of the data vector. Use this function if you are feeding the dataset with a real-time stream. This function is optimized for real-time processing and it enables real-time features.
Do not use this function for a static initial data feeding.
Parameters :
-
date: The point date in the unix GMT format. -
value: The point value at the given date. The value can be either a double value or a label.
addPoints
addPoints(dates, values)
Append a list of points at the end of the dataset. The points will not be inserted in the middle of the dataset if the dates are within the current range (instead, the plot will go backward).
If you intend to add points in a real-time way (for example from a stream), prefer using addPointRealTime.
Parameters :
-
dates: A list of dates in the unix GMT format. -
values: A list of point values at the corresponding date in thedateslist. The value can be either a double value or a label.
adjustDate
adjustDate(from, to, format)
Adjust the dataset date. The given from date will become to date after the adjustment.
All points will be time shifted of the amount (to - from).
Optionally, the date format can be changed.
The new dates are applied in place in the current dataset.
Parameters :
-
from: A date reference, in the unix GMT format, that will be shifted toto. See DateManager for date conversions. An empty string means the date of the first data point will becometo. -
to: The new date, in the unix GMT format, to apply at the previousfromdate. See DateManager for date conversions. -
format:(Optional)The new date format to apply. See DateManager for the format list.
convertToSeconds
convertToSeconds()
On a non-dated dataset, this function will make the dataset dated, considering its X data as seconds.
removeLabels
removeLabels()
Remove all labels of the dataset. It will then be marked as a FLT dataset.
setLabel
setLabel(value, label)
Set a label to display in place of a specific integer value.
Parameters :
-
value: The value to map to a label. It must be an integer value. -
label: The label to display at the given value.
sort
sort()
Sort the dataset into chronological order.
spreadlabels
spreadlabels(keepUnused)
Spread the labels by renumbering their raw values starting from the PrestoPlot BaseLabelOffset configuration value.
Parameters :
keepUnused: Indicates whether unused labels should be kept (default) or stripped.
x
x(indexFrom, indexTo)
Get one or more X values from this dataset. X values are generally dates in the PrestoPlot internal format (see DateManager). If you only give an index, the X value at this position is returned. The first value is the 0'th index. If you give both an index From and an index To, a list of all values between those indices (both included) is returned.
Parameters :
-
indexFrom: The first index to read. -
indexTo:(Optional)The last index to read.
Return : An X value, or a list of X values.
y
y(indexFrom, indexTo)
Get one or more Y values from this dataset. If you only give an index, the Y value at this position is returned. The first value is the 0'th index. If you give both an index From and an index To, a list of all values between those indices (both included) is returned.
Parameters :
-
indexFrom: The first index to read. -
indexTo:(Optional)The last index to read.
Return : A Y value, or a list of Y values.