# Class: Trace
plotting.Trace
Component representing the data trace on a plot.
# Hierarchy
-
↳
Trace
# Table of contents
# Properties
- Defaults
- xData
- yData
- traceColour
- traceStyle
- traceWidth
- markerColour
- markerStyle
- markerSize
- visibility
- canvas
- draw
# Constructors
# Methods
- setData
- setTraceColour
- setTraceStyle
- setTraceWidth
- setMarkerColour
- setMarkerStyle
- setMarkerSize
- setVisibility
# Properties
# Defaults
▪ Static Defaults: Object
| Name | Default value |
|---|---|
traceColour | "blue" |
traceStyle | "solid" |
traceWidth | 3 |
markerColour | "blue" |
markerStyle | "none" |
markerSize | 1 |
visibility | true |
# Type declaration
| Name | Type |
|---|---|
traceColour | string |
traceStyle | "solid" |
traceWidth | number |
markerColour | string |
markerStyle | "none" |
markerSize | number |
visibility | boolean |
# Defined in
plotting/Trace.ts:68 (opens new window)
# xData
• xData: NDArray
The x-axis data.
# Defined in
plotting/Trace.ts:23 (opens new window)
# yData
• yData: NDArray
The y-axis data.
# Defined in
plotting/Trace.ts:27 (opens new window)
# traceColour
• traceColour: string = Trace.Defaults.traceColour
Colour of the data trace.
# Defined in
plotting/Trace.ts:31 (opens new window)
# traceStyle
• traceStyle: "none" | "solid" | "dotted" | "dashed" | "dashdot" = Trace.Defaults.traceStyle
Line style of the data trace.
# Defined in
plotting/Trace.ts:35 (opens new window)
# traceWidth
• traceWidth: number = Trace.Defaults.traceWidth
Line thickness of the data trace in pixels.
# Defined in
plotting/Trace.ts:39 (opens new window)
# markerColour
• markerColour: string = Trace.Defaults.markerColour
Colour of the data markers.
# Defined in
plotting/Trace.ts:43 (opens new window)
# markerStyle
• markerStyle: "none" | "circle" | "plus" | "cross" | "arrow" = Trace.Defaults.markerStyle
Style of the data markers.
# Defined in
plotting/Trace.ts:47 (opens new window)
# markerSize
• markerSize: number = Trace.Defaults.markerSize
Size of the data markers in pixels.
# Defined in
plotting/Trace.ts:51 (opens new window)
# visibility
• visibility: boolean = Trace.Defaults.visibility
Visibility of the data trace.
# Defined in
plotting/Trace.ts:55 (opens new window)
# canvas
• canvas: ResponsiveCanvas
The canvas which the component is attached to.
# Inherited from
# Defined in
core/Component.ts:11 (opens new window)
# draw
• draw: (context: CanvasRenderingContext2D) => void
# Type declaration
▸ (context): void
Function which draws the component on the canvas.
# Parameters
| Name | Type |
|---|---|
context | CanvasRenderingContext2D |
# Returns
void
# Inherited from
# Defined in
core/Component.ts:15 (opens new window)
# Constructors
# constructor
• new Trace(canvas, x, y, options)
# Parameters
| Name | Type | Description |
|---|---|---|
canvas | ResponsiveCanvas | The parent canvas. |
x | number[] | NDArray | Data for the x-axis (optional, see setData()). |
y | number[] | NDArray | Data for the y-axis |
options | Partial<{ traceColour: string ; traceStyle: "none" | "solid" | "dotted" | "dashed" | "dashdot" ; traceWidth: number ; markerColour: string ; markerStyle: "none" | "circle" | "plus" | "cross" | "arrow" ; markerSize: number ; visibility: boolean }> | Options for the data trace. |
# Overrides
# Defined in
plotting/Trace.ts:86 (opens new window)
# Methods
# setData
▸ setData(x, y): void
Set the plotting data for the data trace.
x argument is optional. If it is omitted, the x data becomes the indices of the y data array.
# Parameters
| Name | Type | Description |
|---|---|---|
x | number[] | NDArray | Data for the x-axis. |
y | number[] | NDArray | Data for the y-axis. |
# Returns
void
# Defined in
plotting/Trace.ts:110 (opens new window)
# setTraceColour
▸ setTraceColour(colour): void
Sets the colour of the data trace. Must be a browser-recognised colour name.
# Parameters
| Name | Type |
|---|---|
colour | string |
# Returns
void
# Defined in
plotting/Trace.ts:223 (opens new window)
# setTraceStyle
▸ setTraceStyle(style): void
Sets the style of the data trace.
# Parameters
| Name | Type |
|---|---|
style | "none" | "solid" | "dotted" | "dashed" | "dashdot" |
# Returns
void
# Defined in
plotting/Trace.ts:232 (opens new window)
# setTraceWidth
▸ setTraceWidth(width): void
Sets the line width of the data trace in pixels.
# Parameters
| Name | Type |
|---|---|
width | number |
# Returns
void
# Defined in
plotting/Trace.ts:241 (opens new window)
# setMarkerColour
▸ setMarkerColour(colour): void
Sets the colour of the data markers. Must be a browser-recognised colour name.
# Parameters
| Name | Type |
|---|---|
colour | string |
# Returns
void
# Defined in
plotting/Trace.ts:251 (opens new window)
# setMarkerStyle
▸ setMarkerStyle(style): void
Sets the style of the data markers.
# Parameters
| Name | Type |
|---|---|
style | "none" | "circle" | "plus" | "cross" | "arrow" |
# Returns
void
# Defined in
plotting/Trace.ts:260 (opens new window)
# setMarkerSize
▸ setMarkerSize(size): void
Sets the size of the data markers in pixels.
# Parameters
| Name | Type |
|---|---|
size | number |
# Returns
void
# Defined in
plotting/Trace.ts:269 (opens new window)
# setVisibility
▸ setVisibility(value): void
Toggles the visibility of the data trace.
# Parameters
| Name | Type |
|---|---|
value | boolean |
# Returns
void
# Defined in
← Plot