diff --git a/src/arraylayer.js b/src/arraylayer.js
deleted file mode 100644
index 3c32a0b..0000000
--- a/src/arraylayer.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import React from 'react'; // eslint-disable-line no-unused-vars
-import Layer from './layer';
-
-/**
- * ArrayLayer wrapper for sigplot.layer1d and sigplot.layer2d
- *
- * This layer is meant for static 1D and 2D (or 1D with `framesize`)
- * JS arrays/ArrayBuffers. A typical use case looks like
- *
- * For a 1-D spectral or time-series plot:
- *
- *
- *
- *
- *
- * For a 2-D raster/heatmap:
- *
- *
- *
- *
- */
-class ArrayLayer extends Layer {
- /**
- * Handles ArrayLayer being mounted onto the DOM
- *
- * All we need to do when the component 'mounts',
- * is call `plot.overlay_array` with the relevant
- * data and options. This will return our layer object.
- *
- * A large portion of the time, especially for dynamic
- * systems, this will look like
- * `this.context.overlay_array([], undefined)` upon mount.
- */
- componentDidMount() {
- const { data, options, layerOptions } = this.props;
- this.layer = this.context.overlay_array(data, options, layerOptions);
- }
-
- /**
- * Handles new properties being passed into
- *
- * UNSAFE_componentWillReceiveProps() replaced with
- * shouldComponentUpdate() as they have similar calling patterns.
- * We are using this method for a side-effect, and therefore
- * returning True. getDerivedStateFromProps() had an additional
- * call at mount which UNSAFE_componentWillReceiveProps() lacked.
- * Thus the usage of shouldComponentUpdate().
- *
- * This sits in the lifecycle right before `componentWillUpdate`,
- * and most importantly `render`, so this is where we will call
- * the plot's `reload` and `headermod` methods.
- *
- * @param nextProps the newly received properties
- */
- shouldComponentUpdate(nextProps, _nextState) {
- const {
- data: currentData,
- options: currentOptions,
- layerOptions: currentLayerOptions,
- } = this.props;
-
- const {
- data: nextData,
- options: nextOptions,
- layerOptions: nextLayerOptions,
- } = nextProps;
-
- // if the data changes, we'll go ahead
- // and do a full `reload`;
- // otherwise, we only need to headermod
- // with the new options
- if (nextData !== currentData) {
- this.context.reload(this.layer, nextData, nextOptions);
- } else if (nextOptions !== currentOptions) {
- this.context.headermod(this.layer, nextOptions);
- } else if (nextLayerOptions !== currentLayerOptions) {
- this.context.get_layer(this.layer).change_settings(nextLayerOptions);
- }
-
- return true;
- }
-}
-
-export default ArrayLayer;
diff --git a/src/bluelayer.js b/src/bluelayer.js
deleted file mode 100644
index 3e58896..0000000
--- a/src/bluelayer.js
+++ /dev/null
@@ -1,85 +0,0 @@
-import React from 'react'; // eslint-disable-line no-unused-vars
-import Layer from './layer';
-
-/**
- * BlueLayer wrapper for sigplot.layer1d and sigplot.layer2d
- *
- * This layer is meant for Bluefiles
- * ArrayBuffers. A typical use case looks like
- *
- * For a 1-D spectral or time-series plot:
- *
- *
- *
- *
- *
- * For a 2-D raster/heatmap:
- *
- *
- *
- *
- */
-class BlueLayer extends Layer {
- /**
- * Handles BlueLayer being mounted onto the DOM
- *
- * All we need to do when the component 'mounts',
- * is call `plot.overlay_bluefile` with the relevant
- * data and options. This will return our layer object.
- */
- componentDidMount() {
- const { data, layerOptions } = this.props;
- this.layer = this.context.overlay_bluefile(data, layerOptions);
- }
-
- /**
- * Handles new properties being passed into
- *
- * UNSAFE_componentWillReceiveProps() replaced with
- * shouldComponentUpdate() as they have similar calling patterns.
- * We are using this method for a side-effect, and therefore
- * returning True. getDerivedStateFromProps() had an additional
- * call at mount which UNSAFE_componentWillReceiveProps() lacked.
- * Thus the usage of shouldComponentUpdate().
- *
- * This sits in the lifecycle right before `componentWillUpdate`,
- * and most importantly `render`, so this is where we will call
- * the plot's `reload` and `headermod` methods.
- *
- * @param nextProps the newly received properties
- */
- shouldComponentUpdate(nextProps, _nextState) {
- const {
- data: currentData,
- options: currentOptions,
- layerOptions: currentLayerOptions,
- } = this.props;
-
- const {
- data: nextData,
- options: nextOptions,
- layerOptions: nextLayerOptions,
- } = nextProps;
-
- // if the data changes, we'll go ahead
- // and do a full `reload`;
- // otherwise, we only need to headermod
- // with the new options
- if (nextData !== currentData) {
- this.context.reload(this.layer, nextData, nextOptions);
- } else if (nextOptions !== currentOptions) {
- this.context.headermod(this.layer, nextOptions);
- } else if (nextLayerOptions !== currentLayerOptions) {
- this.context.get_layer(this.layer).change_settings(nextLayerOptions);
- }
-
- return true;
- }
-}
-
-export default BlueLayer;
diff --git a/src/boxesplugin.tsx b/src/boxesplugin.tsx
new file mode 100644
index 0000000..20c436e
--- /dev/null
+++ b/src/boxesplugin.tsx
@@ -0,0 +1,200 @@
+import React, { useEffect, useState } from "react";
+import { Plot } from "sigplot";
+import Plugins from "../../node_modules/sigplot/js/plugins.js";
+import { box } from "./typing";
+
+/**
+ * Boxes Plugin wrapper for sigplot
+ *
+ * This layer adds a plugin to sigplot
+ *
+ *
+ *
+ *
+ */
+
+interface pluginOptions {
+ display?: boolean;
+ enableSelect?: boolean;
+ enableMove?: boolean;
+ enableResize?: boolean;
+ lineWidth?: number;
+ alpha?: number;
+ font?: string;
+ fill?: boolean;
+ strokeStyle?: string;
+ fillStyle?: string;
+ absolutePlacement?: boolean;
+}
+
+interface pluginProps {
+ /** Options to be passed to the plugin regarding global defaults */
+ options?: pluginOptions;
+ /** The reference to the Plot to which this plugin is attached.
+ * If this is a child component of SigPlot, then this gets added
+ * automatically for you and you should leave it blank. */
+ plot?: Plot;
+ /** Any boxes passed to this property will be inserted onto the
+ * plot. If this input changes, all those items will be added to the
+ * plot without regard for if they were already there. In essence
+ * This just mimicks the boxAdd function in the plugin. I do allow
+ * passing a list of boxes in addition to one by one.
+ */
+ addBox?: box[] | box;
+ /** Any box IDs passed to this function will be removed from the plot.
+ * It will "watch" changes much like addBox so you can interact with it.
+ * You can either pass a single box id or a list of box ids
+ */
+ removeBox?: string[] | string;
+ /** If you would like to programatically take a box that is already
+ * on the screen and move it, then put the box info here. If the box.id
+ * contained in the box does not exist, then nothing will happen.
+ */
+ moveBox?: box;
+ /** If this is set to True then a handler will be setup to add boxes
+ * to the plot on "mtag" events - i.e. if you hold control while drawing
+ * a box with your mouse.
+ */
+ addOnMtag?: boolean;
+ /** If you move (or resize) a box on the plot, this callback will be
+ * triggered. The passed box will be the "new" box position.
+ */
+ onMove?(box: box): void;
+ /** Subscribing to this callback will allow you to retrieve the IDs of
+ * any boxes added to the plot.
+ */
+ onAdd?(box: box): void;
+ /** This callback will be triggered anytime a box is removed from the plot */
+ onRemove?(box: box): void;
+ /** This callback will be triggered anytime a box on the plot is selected */
+ onSelect?(box: box): void;
+}
+
+function BoxesPlugin({
+ plot,
+ options,
+ addBox,
+ removeBox,
+ moveBox,
+ addOnMtag,
+ onMove,
+ onAdd,
+ onRemove,
+ onSelect,
+}: pluginProps) {
+ const [plugin, setPlugin] = useState(undefined);
+
+ useEffect(() => {
+ // This will be called on mount
+ const bPlugin = new Plugins.BoxesPlugin(options);
+ plot.add_plugin(bPlugin, 2);
+ setPlugin(bPlugin);
+
+ /** Add callbacks if the user wants them. Make sure that the
+ * despread operator is used everywhere as the objects being
+ * returned in event.box are just references to the object on
+ * the plot. That can cause weird behavior... Therefore, we
+ * will just return copies of those original objects.
+ */
+ if (onMove) {
+ plot.addListener("boxmove", function (event) {
+ const curBox: box = { ...event.box };
+ onMove(curBox);
+ });
+ }
+
+ if (onAdd) {
+ plot.addListener("boxadd", function (event) {
+ const curBox: box = { ...event.box };
+ onAdd(curBox);
+ });
+ }
+
+ if (onSelect) {
+ plot.addListener("boxselect", function (event) {
+ const curBox: box = { ...event.box };
+ onSelect(curBox);
+ });
+ }
+
+ if (onRemove) {
+ plot.addListener("boxremove", function (event) {
+ const curBox: box = { ...event.box };
+ onRemove(curBox);
+ });
+ }
+
+ if (addOnMtag) {
+ plot.addListener("mtag", function (event) {
+ bPlugin.addBox({ x: event.x, y: event.y, h: event.h, w: event.w });
+ });
+ }
+
+ /** There is a bug in the boxes plugin where if certain modes are selected
+ * then boxes with no width or height can be created. This is a hacky
+ * bugfix to tide over until the actual bug is fixed
+ *
+ * TODO Remove when original bug is fixed
+ */
+ plot.addListener("boxadd", function (event) {
+ if (!event.box.w || !event.box.h) {
+ // There appears to be a bug in the boxes plugin where you can
+ // create boxes just by clicking on the screen of 0 w an 0 h
+ bPlugin.removeBox(event.box.id);
+ }
+ });
+
+ // Called on unmount
+ return () => {
+ plot.remove_plugin(bPlugin);
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ if (plugin) {
+ if (addBox instanceof Array) {
+ addBox.forEach((box) => plugin.addBox(box));
+ } else if (addBox) {
+ plugin.addBox(addBox);
+ }
+ }
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [plugin, addBox]);
+
+ useEffect(() => {
+ if (plugin) {
+ if (removeBox instanceof Array) {
+ removeBox.forEach((box) => plugin.removeBox(box));
+ } else if (removeBox) {
+ plugin.removeBox(removeBox);
+ }
+ }
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [plugin, removeBox]);
+
+ useEffect(() => {
+ if (plugin) {
+ // Manually insert the box into the array held by the plugin
+ let curBoxes: box[] = plugin.getBoxes();
+ const idx = curBoxes.findIndex((box) => box.id === moveBox.id);
+ if (idx !== -1) curBoxes[idx] = { ...moveBox };
+
+ // Redraw the plot
+ plot.redraw();
+
+ // Send out a resize event if we need to
+ if (onMove) {
+ onMove(moveBox);
+ }
+ }
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [plugin, moveBox]);
+
+ return
;
+}
+
+export default BoxesPlugin;
diff --git a/src/datalayer.tsx b/src/datalayer.tsx
new file mode 100644
index 0000000..897b3de
--- /dev/null
+++ b/src/datalayer.tsx
@@ -0,0 +1,128 @@
+import React, { useEffect, useState } from "react";
+import { Plot } from "sigplot";
+import { dataOptions, layerOptions } from "./typing";
+
+export interface dataLayerProps {
+ /** The data you intend to plot. This should be a numeric array if
+ * of type "array", "pipe", or "bluefile". It should be a string if
+ * of type "websocket"
+ */
+ data: number[] | string;
+
+ /** The format your data takes (bluefile, array, pipe, websocket) */
+ format: "array" | "pipe" | "bluefile" | "websocket" | "wpipe";
+
+ /** Options for how to interpret the data as a bluefile */
+ options?: dataOptions;
+
+ /** Options for how to display the layer */
+ layerOptions?: layerOptions;
+
+ /** This is only used when doing a wpipe. It must be supplied if format === "wpipe".
+ * The fps stands for frames per second and sets the update rate.
+ */
+ fps?: number;
+
+ /** This in almost all instances should not be inserted by the user. This is intended
+ * to be a child of the in which case this is put in there automatically.
+ */
+ plot?: Plot;
+}
+
+function DataLayer({
+ plot,
+ data,
+ format,
+ options,
+ layerOptions,
+ fps,
+}: dataLayerProps) {
+ /** Other than hreflayer - this is the method used to get data to show up on the plot.
+ * Functionally, it allows setting the format to one of 5 different types. Each
+ * type is a different input type to sigplot. The different all call different
+ * sigplot functions under the hood, but there is enough commonality where it is
+ * easiest to keep them all together. Examples of how to call them are seen below:
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+ const [layer, setLayer] = useState(undefined);
+ const [resetSocket, setResetSocket] = useState(false);
+
+ useEffect(() => {
+ // Setup our layer & adjust if we change types.
+ let curLayer = undefined;
+ switch (format) {
+ case "array":
+ curLayer = plot.overlay_array(data, options, layerOptions);
+ break;
+ case "bluefile":
+ curLayer = plot.overlay_bluefile(data, options, layerOptions);
+ break;
+ case "websocket":
+ curLayer = plot.overlay_websocket(data, options, layerOptions);
+ break;
+ case "wpipe":
+ curLayer = plot.overlay_wpipe(data, options, layerOptions, fps);
+ break;
+ case "pipe":
+ curLayer = plot.overlay_pipe(data, options, layerOptions);
+ if (data !== undefined && data.length > 0) {
+ plot.push(curLayer, data);
+ }
+ break;
+ }
+ setLayer(curLayer);
+
+ // This removes the layer on unmount or if the layer type changes.
+ return () => {
+ curLayer && plot.remove_layer(curLayer);
+ };
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [format, resetSocket]);
+
+ useEffect(() => {
+ // Push more data to the plot, or reload
+ if (layer) {
+ if (format === "pipe") {
+ plot.push(layer, data, options);
+ } else if (format === "websocket" || format === "wpipe") {
+ // We need to tear down the layer and make a new one.
+ // We created a state just for that. We don't want to remove and
+ // reset the layer here as it would break the teardown function.
+ setResetSocket(!resetSocket);
+ } else {
+ plot.reload(layer, data, options);
+ }
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [data, layer]);
+
+ useEffect(() => {
+ // Change the data options
+ if (layer) {
+ plot.headermod(layer, options);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [options, layer]);
+
+ useEffect(() => {
+ // Change the settings for the layer
+ if (layer) {
+ plot.get_layer(layer).change_settings(layerOptions);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [layerOptions, layer]);
+
+ return ;
+}
+
+export default DataLayer;
diff --git a/src/hreflayer.js b/src/hreflayer.js
deleted file mode 100644
index 066696c..0000000
--- a/src/hreflayer.js
+++ /dev/null
@@ -1,82 +0,0 @@
-import React from 'react'; // eslint-disable-line no-unused-vars
-import PropTypes from 'prop-types';
-import Layer from './layer';
-
-/**
- * Wrapper around sigplot.Plot.overlay_href
- *
- * Typical use of this layer looks like
- *
- *
- *
- */
-class HrefLayer extends Layer {
- static propTypes = {
- /**
- * URI to BLUEFILE or MATFILE to plot
- *
- * This can either be local 'file:///path/to/file' or
- * remote 'http://myfile.com/file.tmp'
- *
- * Keep in mind that if the file is on a different domain,
- * most browsers/web-servers will block cross origin requests.
- *
- * Since this layer doesn't take any numeric data,
- * we are omitting the use of the `data` prop here.
- */
- href: PropTypes.string,
-
- /** Callback that executes once the file loads */
- onload: PropTypes.func,
-
- /** Layer options */
- options: PropTypes.object,
- };
-
- static defaultProps = {
- href: '',
- onload: null,
- };
-
- /**
- * On mount, all we need to do is call overlay_href
- */
- componentDidMount() {
- const { href, onload, options } = this.props;
- this.layer = this.context.overlay_href(href, onload, options);
- }
-
- /**
- * Handles new properties being passed into
- *
- * UNSAFE_componentWillReceiveProps() replaced with
- * shouldComponentUpdate() as they have similar calling patterns.
- * We are using this method for a side-effect, and therefore
- * returning True. getDerivedStateFromProps() had an additional
- * call at mount which UNSAFE_componentWillReceiveProps() lacked.
- * Thus the usage of shouldComponentUpdate().
- *
- * This sits in the lifecycle right before `componentWillUpdate`,
- * and most importantly `render`, so this is where we will call
- * the plot's `reload` and `headermod` methods.
- *
- * @param nextProps the newly received properties
- */
- shouldComponentUpdate(nextProps, _nextState) {
- const { href: oldHref, options: oldOptions } = this.props;
-
- const { href: newHref, onload: newOnload, options: newOptions } = nextProps;
-
- // we only care if `href` or `options` changes
- if (newHref !== oldHref) {
- this.context.deoverlay(this.layer);
- this.layer = this.context.overlay_href(newHref, newOnload, newOptions);
- } else if (this.layer !== undefined && newOptions !== oldOptions) {
- this.context.get_layer(this.layer).change_settings(newOptions);
- }
-
- return true;
- }
-}
-
-export default HrefLayer;
diff --git a/src/hreflayer.tsx b/src/hreflayer.tsx
new file mode 100644
index 0000000..71de07b
--- /dev/null
+++ b/src/hreflayer.tsx
@@ -0,0 +1,88 @@
+import React, { useEffect, useState } from "react";
+import PropTypes from "prop-types";
+import { Plot } from "sigplot";
+import { layerOptions } from "./typing";
+
+/**
+ * Wrapper around sigplot.Plot.overlay_href
+ *
+ * Typical use of this layer looks like
+ *
+ *
+ *
+ */
+
+const propTypes = {
+ /**
+ * URI to BLUEFILE or MATFILE to plot
+ *
+ * This can either be local 'file:///path/to/file' or
+ * remote 'http://myfile.com/file.tmp'
+ *
+ * Keep in mind that if the file is on a different domain,
+ * most browsers/web-servers will block cross origin requests.
+ *
+ * Since this layer doesn't take any numeric data,
+ * we are omitting the use of the `data` prop here.
+ */
+ href: PropTypes.string,
+
+ /** Callback that executes once the file loads */
+ onload: PropTypes.func,
+
+ /** Layer options */
+ options: PropTypes.object,
+};
+
+const defaultProps = {
+ href: "",
+ onload: null,
+};
+
+interface HrefProps {
+ /** href or |-delimited hrefs the url to the bluefile or matfile */
+ href?: string;
+ onload?: CallableFunction;
+ layerOptions?: layerOptions;
+ plot?: Plot;
+}
+
+function HrefLayer({ plot, href, onload, layerOptions }: HrefProps) {
+ const [layer, setLayer] = useState(undefined);
+
+ useEffect(() => {
+ // Called on Mount
+ const curLayer = plot.overlay_href(href, onload, layerOptions);
+ setLayer(curLayer);
+
+ // This will be called on unmount
+ return () => {
+ plot.remove_layer(curLayer);
+ };
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ if (layer) {
+ plot.deoverlay(layer);
+ setLayer(plot.overlay_href(href, onload, layerOptions));
+ }
+
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [href]);
+
+ useEffect(() => {
+ if (layer) {
+ plot.get_layer(layer).change_settings(layerOptions);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [layerOptions]);
+
+ return ;
+}
+
+HrefLayer.propTypes = propTypes;
+HrefLayer.defaultProps = defaultProps;
+
+export default HrefLayer;
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index 1b0e7ad..0000000
--- a/src/index.js
+++ /dev/null
@@ -1,8 +0,0 @@
-export { default as SigPlot } from './sigplot';
-export { default as ArrayLayer } from './arraylayer';
-export { default as PipeLayer } from './pipelayer';
-export { default as HrefLayer } from './hreflayer';
-export { default as BlueLayer } from './bluelayer';
-export { default as WebsocketLayer } from './websocketlayer';
-export { default as Layer } from './layer';
-export { default as Plugin } from './plugin';
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 0000000..e8723c2
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,4 @@
+export { default as SigPlot } from './sigplot';
+export { default as DataLayer } from './datalayer';
+export { default as HrefLayer } from './hreflayer';
+export { default as BoxesPlugin } from './boxesplugin';
diff --git a/src/layer.js b/src/layer.js
deleted file mode 100644
index f8bea4e..0000000
--- a/src/layer.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import React, { Component } from 'react'; // eslint-disable-line no-unused-vars
-import PropTypes from 'prop-types';
-import { PlotContext } from './sigplot';
-
-/**
- * Abstract base class for all Layers
- */
-class Layer extends Component {
- static propTypes = {
- /** Array of `Number` types */
- data: PropTypes.arrayOf(PropTypes.number), // eslint-disable-line react/no-unused-prop-types
-
- /** Header options for `data` */
- options: PropTypes.object, // eslint-disable-line react/no-unused-prop-types
-
- /**
- * Options about the layer
- *
- * @see See [sigplot.layer1d](https://github.com/LGSInnovations/sigplot/blob/master/js/sigplot.layer1d.js)
- * @see See [sigplot.layer2d](https://github.com/LGSInnovations/sigplot/blob/master/js/sigplot.layer2d.js)
- */
- layerOptions: PropTypes.object, // eslint-disable-line react/no-unused-prop-types
- };
-
- static contextType = PlotContext;
-
- /**
- * On unmount, all we need to do is remove the layer
- * from the plot.
- */
- componentWillUnmount() {
- this.context.remove_layer(this.layer);
- }
-
- /**
- * The layer components don't _actually_ render to the DOM.
- *
- * They are merely abstractions of canvas-manipulations.
- */
- render() {
- return false;
- }
-}
-
-export default Layer;
diff --git a/src/pipelayer.js b/src/pipelayer.js
deleted file mode 100644
index 9c84073..0000000
--- a/src/pipelayer.js
+++ /dev/null
@@ -1,81 +0,0 @@
-import React from 'react'; // eslint-disable-line no-unused-vars
-import Layer from './layer';
-
-/**
- * Wrapper around sigplot.Plot.overlay_pipe
- *
- * This wrapper is for streaming 1-D plots or
- * 2-D raster waterfall plots.
- *
- * Typical use of this would look like
- *
- *
- *
- *
- *
- * where options is populated before data begins flowing
- */
-class PipeLayer extends Layer {
- /**
- * On mount, the only action we can take is to overlay the
- * pipe with the specified header (`options`) information
- *
- * It isn't until data begins coming that we can begin to
- */
- componentDidMount() {
- const { options, data, layerOptions } = this.props;
-
- // start by setting the header of the pipe
- this.layer = this.context.overlay_pipe(options, layerOptions);
-
- // if data is provided and non-empty, go ahead and
- // begin plotting data
- if (data !== undefined && data.length > 0) {
- this.context.push(this.layer, data);
- }
- }
-
- /**
- * Handles new properties being passed into
- *
- * UNSAFE_componentWillReceiveProps() replaced with
- * shouldComponentUpdate() as they have similar calling patterns.
- * We are using this method for a side-effect, and therefore
- * returning True. getDerivedStateFromProps() had an additional
- * call at mount which UNSAFE_componentWillReceiveProps() lacked.
- * Thus the usage of shouldComponentUpdate().
- *
- * This sits in the lifecycle right before `componentWillUpdate`,
- * and most importantly `render`, so this is where we will call
- * the plot's `reload` and `headermod` methods.
- *
- * @param nextProps the newly received properties
- *
- * @TODO Handle headermod updates
- */
- shouldComponentUpdate(nextProps, _nextState) {
- const {
- data: currentData,
- options: currentOptions,
- layerOptions: currentLayerOptions,
- } = this.props;
- const {
- data: nextData,
- options: nextOptions,
- layerOptions: nextLayerOptions,
- } = nextProps;
-
- // if new data has come in, plot that
- if (nextData && nextData !== currentData) {
- this.context.push(this.layer, nextData, nextOptions);
- } else if (nextOptions !== currentOptions) {
- this.context.headermod(this.layer, nextOptions);
- } else if (nextLayerOptions !== currentLayerOptions) {
- this.context.get_layer(this.layer).change_settings(nextLayerOptions);
- }
-
- return true;
- }
-}
-
-export default PipeLayer;
diff --git a/src/plugin.js b/src/plugin.js
deleted file mode 100644
index 54abe82..0000000
--- a/src/plugin.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import React, { Component } from 'react'; // eslint-disable-line no-unused-vars
-import PropTypes from 'prop-types';
-import { PlotContext } from './sigplot';
-
-/**
- * Abstract base class for all Plugins
- */
-class Plugin extends Component {
- static propTypes = {
- /**
- * Options about the plugin
- *
- * @see See [plugins](https://github.com/LGSInnovations/sigplot/blob/master/js/plugins.js)
- */
- pluginOptions: PropTypes.object, // eslint-disable-line react/no-unused-prop-types
- };
-
- static contextType = PlotContext;
-
- /**
- * On unmount, all we need to do is remove the plugin
- * from the plot.
- */
- componentWillUnmount() {
- this.context.remove_plugin(this.plugin);
- }
-
- /**
- * Getter for the sigplot.Plot object
- *
- * The `plot` is 'given' to the plugin-children
- * from the parent component, so we receive
- * it from the context.
- */
- get plot() {
- const { plot } = this.context;
- return plot;
- }
-
- /**
- * The plugin components don't _actually_ render to the DOM.
- *
- * They are merely abstractions of canvas-manipulations.
- */
- render() {
- return false;
- }
-}
-
-export default Plugin;
diff --git a/src/sigplot.js b/src/sigplot.js
deleted file mode 100644
index 660940c..0000000
--- a/src/sigplot.js
+++ /dev/null
@@ -1,148 +0,0 @@
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import { Plot } from 'sigplot';
-
-export const PlotContext = React.createContext(undefined);
-
-/**
- * SigPlot.js React wrapper class
- *
- * @version 0.1.15
- * @visibleName SigPlot.js React Wrapper
- */
-class SigPlot extends Component {
- static propTypes = {
- /**
- * Different Layer nodes (e.g., ArrayLayer, PipeLayer, etc.)
- *
- * @ignore
- */
- children: PropTypes.node,
-
- /** Height of the wrapper div */
- height: PropTypes.number,
-
- /** Width of the wrapper div */
- width: PropTypes.number,
-
- /** CSS 'display' property */
- display: PropTypes.string,
-
- /** Styles object for any other CSS styles on the wrapper div */
- styles: PropTypes.object,
-
- /**
- * SigPlot plot-level options
- *
- * @see See [sigplot.Plot Docs](http://sigplot.lgsinnovations.com/html/doc/sigplot.Plot.html)
- */
- options: PropTypes.object,
- };
-
- static defaultProps = {
- height: 300,
- width: 300,
- display: 'inline-block',
- options: {
- all: true,
- expand: true,
- autol: 100,
- autohide_panbars: true,
- },
- };
-
- constructor(props) {
- super(props);
- this.state = {};
- }
-
- componentDidMount() {
- const { options } = this.props;
- this.plot = new Plot(this.element, options);
-
- // Have to trigger context tree, setting state does that.
- // eslint-disable-next-line react/no-did-mount-set-state
- // eslint-disable-next-line react/no-unused-state
- this.setState({ plot: this.plot });
- }
-
- shouldComponentUpdate(nextProps, _nextState) {
- const { height, width, options } = this.props;
- const {
- height: newHeight,
- width: newWidth,
- options: newOptions,
- } = nextProps;
-
- // When the outer div height/width changes,
- // we need to explicitly tell SigPlot to resize;
- // otherwise, it won't resize automatically.
- if (newHeight !== height || newWidth !== width) {
- this.plot.checkresize();
- }
-
- // If the options change at the plot level,
- // we need to handle that
- if (newOptions !== options) {
- this.plot.change_settings(newOptions);
- }
-
- return true;
- }
-
- render() {
- const {
- height,
- width,
- display,
- styles,
- children: propChildren,
- } = this.props;
- const { plot } = this;
-
- /**
- * Recall we're treating the `sigplot.layer1d` and
- * `sigplot.layer2d` as (virtual) children nodes since
- * they are simply manipulations/API calls that modify
- * the underlying