react-financial-charts
Version:
React charts specific to finance.
32 lines • 1.37 kB
JavaScript
import * as React from "react";
import GenericChartComponent from "../../GenericChartComponent";
import { getMouseCanvas } from "../../GenericComponent";
export class Text extends React.Component {
constructor() {
super(...arguments);
this.isHover = () => {
return false;
};
this.drawOnCanvas = (ctx, moreProps) => {
const { xyProvider, fontFamily, fontSize, fill, children, } = this.props;
const [x, y] = xyProvider(moreProps);
ctx.font = `${fontSize}px ${fontFamily}`;
ctx.fillStyle = fill;
ctx.beginPath();
ctx.fillText(children, x, y);
};
this.renderSVG = (moreProps) => {
const { xyProvider, fontFamily, fontSize, fill, children, } = this.props;
const [x, y] = xyProvider(moreProps);
return (React.createElement("text", { x: x, y: y, fontFamily: fontFamily, fontSize: fontSize, fill: fill }, children));
};
}
render() {
const { selected } = this.props;
return (React.createElement(GenericChartComponent, { isHover: this.isHover, selected: selected, svgDraw: this.renderSVG, canvasToDraw: getMouseCanvas, canvasDraw: this.drawOnCanvas, drawOn: ["mousemove", "pan", "drag"] }));
}
}
Text.defaultProps = {
selected: false,
};
//# sourceMappingURL=Text.js.map