A TypeScript library for creating d3-driven geochronological data visualizations.
Browser:
Save a copy of dist/topsoil.js
and reference it with a script
tag. The library will be added as a member of window
called topsoil
.
Node.js:
npm install CIRDLES/topsoil-js
const data = [
{ label: "row1", selected: true, x: 27.9, sigma_x: 1.3, y: 0.71, sigma_y: 0.02, rho: 0.89 }
];
const options = {
title: "Example Plot",
points: true,
points_fill: "#00ff00",
ellipses: true,
concordia_type: "wetherill",
concordia_line: true,
concordia_envelope: true
}
const layers = ["points", ["ellipses", "error_bars"], ["concordia", "evolution"]];
const plot = new ScatterPlot(
document.getElementById("plot"),
data,
options,
layers
);
Name | Type | Access | Description |
---|---|---|---|
root |
HTMLDivElement |
readonly | The element in which the plot is drawn. |
data |
{}[] |
get/set | An array of data objects (see Data Variables) |
options |
{} |
get/set | An object of plot options (see Plot Options) |
x.axis |
d3.svg.Axis |
readonly | The plot's X axis. |
x.scale |
d3.scale.Linear<number, number> |
readonly | The scale responsible for mapping X axis values to X coordinates. |
y.axis |
d3.svg.Axis |
readonly | The plot's Y axis. |
y.scale |
d3.scale.Linear<number, number> |
readonly | The scale responsible for mapping Y axis values to Y coordinates. |
Draws a plot in the specified root
element.
Data is defined as an array of objects in which the keys are in the enum Variable
. (For possible values, see Data Variables).
Options are defined as an object in which the keys are in the enum Option
. (For possible values, see Plot Options).
Layers are optional, and may be defined as an array that represents the order of each of the plot features, where the first feature is drawn on top, and the last feature is drawn on the bottom. Features may also be grouped; for example, the following array specifies that data points will appear on top, followed by a group containing both error ellipses and error bars, followed by another group containing the concordia and the evolution matrix:
const layers = ["points", ["ellipses", "error_bars"], ["concordia", "evolution"]];
String value | Enum value |
---|---|
"points" | Feature.POINTS |
"ellipses" | Feature.ELLIPSES |
"error_bars" | Feature.ERROR_BARS |
"concordia" | Feature.CONCORDIA |
"evolution" | Feature.EVOLUTION |
Sets the plot's data from the provided JSON string.
Sets the plot's options from the provided JSON string.
Returns an array containing the minimum and maximum data values for each axis at the following indices:
[0] Minimum X value
[1] Maximum X value
[2] Minimum Y value
[3] Maximum Y value
.changeAxisExtents(xMin: number, xMax: number, yMin: number, yMax: number, doInterpolate?: boolean = false)
: void
Sets the plot's axes to the provided extents. If doInterpolate
is true, then the transition will be animated.
Zooms the plot to fit the data extents.
Zooms the plot so that the Wetherill concordia passes through the lower-left and upper-right corners.
Data rows are defined as objects in which the keys are in the enum Variable
. For example:
{
"label": "row1",
"selected": true,
"x": 27.4,
"sigma_x": 1.3,
"y": 0.7,
"sigma_y": 0.014,
"rho": 0.89
}
default: ""
The label describing a row.
default: true
Rows may be selected or deselected in order to modify the appearance of certain plot features. For example, if a row is deselected, the error ellipse for that row will be grayed out.
required for ScatterPlot
The value used for the X component of the row.
default: 0.0
The value used for error/uncertainty along the X axis. This must be provided in 1-sigma absolute format.
required for ScatterPlot
The value used for the Y component of the row.
default: 0.0
The value used for error/uncertainty along the Y axis. This must be provided in 1-sigma absolute format.
default: 0.0
The rho value, or the correlation coefficient, used to calculate error ellipses. This must be a value between -1.0 and 1.0, inclusive.
default: "New Plot"
default: "X Axis"
The title of the plot's X axis.
default: 0.0
The lower bound of the plot's X axis.
default: 1.0
The upper bound of the plot's X axis.
default: "Y Axis"
The title of the plot's X axis.
default: 0.0
The lower bound of the plot's Y axis.
default: 1.0
The upper bound of the plot's Y axis.
default: "Generic"
The isotope system of the plot. Can be "Generic", "Uranium Lead", or "Uranium Thorium".
default: 1.0
The multiplier used to calculate error values. An uncertainty value of 2.0 would yield 2-sigma values.
default: true
Determines whether or not to display data points for each row.
default: "#4682b4"
The color of the plot's data points.
default: 1.0
The opacity of the plot's data points, a value between 0.0 and 1.0, inclusive.
default: false
Determines whether or not to display error ellipses for each row.
default: "#ff0000"
The fill color of the plot's selected error ellipses.
default: 1.0
The opacity of the plot's error ellipses.
default: false
Determines whether or not to display error bars for each row.
default: "#000000"
The fill color of the plot's selected error bars.
default: 1.0
The opacity of the plot's error bars.
default: "none"
The type of concordia to display. Valid values include "none"
, "wetherill"
, and "tera-wasserburg"
.
default: false
Determines whether or not to show a concordia line.
default: "#0000ff"
The color of the concordia line.
default: 1.0
The opacity of the concordia line. May be between 0.0 and 1.0, inclusive.
default: false
Determines whether or not to show a concordia error envelope.
default: "#0000ff"
The color of the concordia error envelope.
default: 1.0
The opacity of the concordia error envelope. May be between 0.0 and 1.0, inclusive.
default: false
Determines whether or not to draw an evolution matrix.
default: 9.1705E-6
default: 2.82206E-6
default: 9.8485e-10
default: 1.55125e-10
default: 137.88
Using a JavaFX WebView, it is possible to execute JavaScript within a Java application, as is done in the desktop version of Topsoil. In order to support upcalls from JavaScript to Java, the optional javaBridge
member may be set on a plot object.
- Topsoil (desktop) - Java application and library
- Topsoil (web) - Web application