react-financial-charts
Version:
React charts specific to finance.
32 lines • 1.4 kB
JavaScript
import * as React from "react";
import { isDefined } from "./utils";
export class CanvasContainer extends React.Component {
constructor() {
super(...arguments);
this.drawCanvas = {};
this.setDrawCanvas = (node) => {
if (isDefined(node)) {
this.drawCanvas[node.id] = node.getContext("2d");
}
else {
this.drawCanvas = {};
}
};
}
getCanvasContexts() {
if (isDefined(this.drawCanvas.axes)) {
return this.drawCanvas;
}
}
render() {
const { height, width, type, zIndex, ratio } = this.props;
if (type === "svg") {
return null;
}
return (React.createElement("div", { style: { position: "absolute", zIndex } },
React.createElement("canvas", { id: "bg", ref: this.setDrawCanvas, width: width * ratio, height: height * ratio, style: { position: "absolute", width, height } }),
React.createElement("canvas", { id: "axes", ref: this.setDrawCanvas, width: width * ratio, height: height * ratio, style: { position: "absolute", width, height } }),
React.createElement("canvas", { id: "mouseCoord", ref: this.setDrawCanvas, width: width * ratio, height: height * ratio, style: { position: "absolute", width, height } })));
}
}
//# sourceMappingURL=CanvasContainer.js.map