UNPKG

react-financial-charts

Version:
32 lines 1.37 kB
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