public class XYChart extends AbstractChart
AbstractChart.Side
axisColour, axisFormatter, axisLabelColour, axisValuesColour, data, drawDecorations, graphics, logTics, parent, renderer, showEdge, tics, transposeAxes
Constructor and Description |
---|
XYChart(processing.core.PApplet parent)
Initialises an XY chart.
|
Modifier and Type | Method and Description |
---|---|
void |
calcDataSpacing()
Calculates the spacing between the graph area and the data to display.
|
void |
draw(float xOrigin,
float yOrigin,
float width,
float height)
Draws the X-Y chart within the given bounds.
|
float |
getBottomSpacing()
Reports the spacing between the bottom of the chart and the bottom of the dataspace within the chart.
|
processing.core.PVector |
getDataToScreen(processing.core.PVector dataPoint)
Converts given data point into its screen location.
|
float |
getLeftSpacing()
Reports the spacing between the left of the chart and the left of the dataspace within the chart.
|
float |
getMaxX()
Reports the maximum x value that can be displayed by the XY chart.
|
float |
getMaxY()
Reports the maximum y value that can be displayed by the XY chart.
|
float |
getMinX()
Reports the minimum x value that can be displayed by the XY chart.
|
float |
getMinY()
Reports the minimum y value that can be displayed by the XY chart.
|
float |
getRightSpacing()
Reports the spacing between the right of the chart and the right of the dataspace within the chart.
|
processing.core.PVector |
getScreenToData(processing.core.PVector screenPoint)
Converts given screen coordinate into its equivalent data value.
|
float |
getTopSpacing()
Reports the spacing between the top of the chart and the top of the dataspace within the chart.
|
float[] |
getXData()
Reports the data values that are displayed in the chart along the X axis.
|
float[] |
getYData()
Reports the data values that are displayed in the chart along the Y axis.
|
void |
setData(float[] xValues,
float[] yValues)
Sets the data to be plotted in the X-Y chart.
|
void |
setData(java.util.List<processing.core.PVector> data)
Sets the data to be plotted in the X-Y chart
|
void |
setLineColour(int colour)
Determines the colour of the line to be displayed on the chart.
|
void |
setLineWidth(float width)
Determines the width of the line to be displayed on the chart.
|
void |
setLogX(boolean isLog)
Determines whether or not the values on the x axis are log10 scaled.
|
void |
setLogY(boolean isLog)
Determines whether or not the values on the y axis are log10 scaled.
|
void |
setMaxX(float maxX)
Sets the maximum value for x values to be represented.
|
void |
setMaxY(float maxY)
Sets the maximum value for y values to be represented.
|
void |
setMinX(float minX)
Sets the minimum value for x values to be represented.
|
void |
setMinY(float minY)
Sets the minimum value for y values to be represented.
|
void |
setPointColour(float[] colourData,
ColourTable cTable)
Provides the data and colour table from which to colour points.
|
void |
setPointColour(int colour)
Determines the colour of the points to be displayed on the chart.
|
void |
setPointSize(float size)
Determines the size of the points to be displayed on the chart.
|
void |
setPointSize(float[] sizeData,
float maxSize)
Sizes points to be displayed on the chart according to the given set of data.
|
void |
setXAxisAt(float yValue)
Sets the position of the x-axis.
|
void |
setXAxisLabel(java.lang.String label)
Sets the x-axis label.
|
void |
setXFormat(java.lang.String format)
Sets the numerical format for numbers shown on the x-axis.
|
void |
setYAxisAt(float xValue)
Sets the position of the y-axis.
|
void |
setYAxisLabel(java.lang.String label)
Sets the y-axis label.
|
void |
setYFormat(java.lang.String format)
Sets the numerical format for numbers shown on the y-axis.
|
void |
showXAxis(boolean showAxis)
Determines whether or not the axis representing the x data is shown.
|
void |
showYAxis(boolean showAxis)
Determines whether or not the axis representing the y data is shown.
|
void |
transposeAxes(boolean transpose)
Determines if the axes should be transposed (so that the x-axis is vertical
and y-axis is horizontal).
|
void |
updateLayout()
Updates the layout of the chart if, for example the font has been changed externally.
|
convertFromLog, convertToLog, getBorder, getData, getIsLogScale, getMax, getMaxLog, getMin, getMinBorder, getMinLog, getShowAxis, setAxisColour, setAxisLabelColour, setAxisValuesColour, setBorder, setData, setDecorations, setFormat, setGraphics, setIsLogScale, setMax, setMin, setMinBorder, setMinBorder, setRange, setRenderer, setShowEdge, showAxis
public XYChart(processing.core.PApplet parent)
parent
- Parent sketch in which this chart is to be drawn.public void setData(float[] xValues, float[] yValues)
xValues
- Array of x values to plot.yValues
- Array of y values to plot.public void setData(java.util.List<processing.core.PVector> data)
data
- Collection of pairs of (x,y) data values, each stored in a PVector.public void draw(float xOrigin, float yOrigin, float width, float height)
draw
in class AbstractChart
xOrigin
- left-hand pixel coordinate of the area in which to draw the chart.yOrigin
- top pixel coordinate of the area in which to draw the chart.width
- Width in pixels of the area in which to draw the chart.height
- Height in pixels of the area in which to draw the chart.public processing.core.PVector getDataToScreen(processing.core.PVector dataPoint)
draw()
method. If this is
called before any call to draw()
has been made, it will return null.dataPoint
- (x,y) pair representing an item of data.public processing.core.PVector getScreenToData(processing.core.PVector screenPoint)
draw()
method.
If this is called before any call to draw()
has been made, it will return null.screenPoint
- Screen coordinates to convert into data pair.public void setPointColour(int colour)
colour
- Colour of points to be displayed.public void setPointColour(float[] colourData, ColourTable cTable)
setData()
.colourData
- Data used to colour points.cTable
- Colour table that translates data values into colours.public void setLineColour(int colour)
colour
- Colour of line to be displayed.public void setPointSize(float size)
size
- Size of points to be displayed in pixel units.public void setPointSize(float[] sizeData, float maxSize)
setData()
.sizeData
- Data used to size points.maxSize
- Size in pixel units of the largest point.public void setLineWidth(float width)
width
- Width of line to be displayed in pixel units.public void showXAxis(boolean showAxis)
showAxis
- x-axis is shown if true.public void showYAxis(boolean showAxis)
showAxis
- y-axis is shown if true.public void setMinX(float minX)
Float.NaN
,
then the minimum x-value will be set to the minimum of the data x-values in the chart.minX
- Minimum x-value to be represented on the x-axis.public void setMinY(float minY)
Float.NaN
,
then the minimum y-value will be set to the minimum of the data y-values in the chart.minY
- Minimum y-value to be represented on the y-axis.public void setMaxX(float maxX)
Float.NaN
, then the maximum x-value will be set
to the maximum of the data x-values in the chart.maxX
- Maximum x-value to be represented on the x-axis or Float.NaN
to use data maximum.public void setMaxY(float maxY)
Float.NaN
, then the minimum y-value will be set
to the maximum of the data y-values in the chart.maxY
- Maximum y-value to be represented on the y-axis or Float.NaN
go use the data maximum.public float[] getXData()
public float[] getYData()
public float getMinX()
setMinX()
can affect the value.public float getMaxX()
setMaxX()
can affect the value.public float getMinY()
setMinY()
can affect the value.public float getMaxY()
setMaxY()
can affect the value.public float getLeftSpacing()
public float getRightSpacing()
public float getBottomSpacing()
public float getTopSpacing()
public void setXAxisLabel(java.lang.String label)
label
- x-axis label to draw or null if no label to be drawn.public void setYAxisLabel(java.lang.String label)
label
- y-axis label to draw or null if no label to be drawn.public void setXAxisAt(float yValue)
yValue
- Position of axis in data units.public void setYAxisAt(float xValue)
xValue
- Position of axis in data units.public void setXFormat(java.lang.String format)
format
- Format for numbers on the x-axis.public void setYFormat(java.lang.String format)
format
- Format for numbers on the y-axis.public void setLogX(boolean isLog)
isLog
- True if x-axis values are to be log10-scaled or false if linear.public void setLogY(boolean isLog)
isLog
- True if y-axis values are to be log10-scaled or false if linear.public void transposeAxes(boolean transpose)
transpose
- Axes are transposed if true.public void updateLayout()
public void calcDataSpacing()