How to use the @vx/event.localPoint function in @vx/event

To help you get started, we’ve selected a few @vx/event examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rohan-paul / stock-dashboard-react / src / Components / StockAnalytics / Alternative-working-codes-kept-for-backup / SandP500_PE-vx-WORKING.js View on Github external
handleTooltip({ event, data, xStock, xScale, yScale }) {
    const { showTooltip } = this.props;
    const { x } = localPoint(event);
    const x0 = xScale.invert(x);
    const index = bisectDate(data, x0, 1);
    const d0 = data[index - 1];
    const d1 = data[index];
    let d = d0;
    if (d1 && d1.date) {
      d = x0 - xStock(d0.date) > xStock(d1.date) - x0 ? d1 : d0;
    }
    showTooltip({
      tooltipData: d,
      tooltipLeft: x,
      tooltipTop: yScale(d.close)
    });
  }
  render() {
github williaster / data-ui / packages / network / src / enhancer / WithTooltip.jsx View on Github external
handleMouseMove({ event, datum, data, ...rest }) {
    if (this.tooltipTimeout) clearTimeout(this.tooltipTimeout);
    let coords = { x: 0, y: 0 };
    if (event && event.target && event.target.ownerSVGElement) {
      coords = localPoint(event.target.ownerSVGElement, event);
    }

    this.props.showTooltip({
      tooltipLeft: coords.x + 10,
      tooltipTop: coords.y + 10,
      tooltipData: {
        event,
        datum,
        data,
        ...rest,
      },
    });
  }
github williaster / data-ui / packages / xy-chart / src / utils / drag / Drag.jsx View on Github external
dragStart(event) {
    const { onDragStart, resetOnStart } = this.props;
    const { dx, dy } = this.state;
    const point = localPoint(event);
    const nextState = {
      ...this.state,
      isDragging: true,
      dx: resetOnStart ? 0 : dx,
      dy: resetOnStart ? 0 : dy,
      x: resetOnStart ? point.x : -dx + point.x,
      y: resetOnStart ? point.y : -dy + point.y,
    };
    if (onDragStart) onDragStart({ ...nextState, event });
    this.setState(() => nextState);
  }
github blockkeeper / blockkeeper-frontend-web / src / view / Lib.js View on Github external
handleTooltip ({ event, touchData, xStock, xScale, yScale, bisectDate }) {
    const { showTooltip } = this.props
    const { x } = localPoint(event)
    const x0 = xScale.invert(x)
    const index = bisectDate(touchData, x0, 1)
    const d0 = touchData[index - 1]
    const d1 = touchData[index]
    let d = d0
    if (d1 && d1[0]) {
      d = x0 - xStock(d0) > xStock(d1) - x0 ? d1 : d0
    }
    showTooltip({
      tooltipData: d,
      tooltipLeft: x,
      tooltipTop: yScale(d[1])
    })
  }
github hshoff / vx / packages / vx-demo / components / tiles / area.js View on Github external
handleTooltip({ event, xScale, yScale }) {
    const { showTooltip } = this.props;
    const { x } = localPoint(event);
    const x0 = xScale.invert(x);
    const index = bisectDate(stock, x0, 1);
    const d0 = stock[index - 1];
    const d1 = stock[index];
    let d = d0;
    if (d1 && d1.date) {
      d = x0 - xStock(d0.date) > xStock(d1.date) - x0 ? d1 : d0;
    }
    showTooltip({
      tooltipData: d,
      tooltipLeft: x,
      tooltipTop: yScale(d.close)
    });
  }
  render() {
github zooniverse / front-end-monorepo / packages / lib-classifier / src / components / Classifier / components / SubjectViewer / components / SVGComponents / VXZoom / VXZoom.js View on Github external
zoomToPoint (event, zoomDirection) {
    const { zoomInValue, zoomOutValue } = this.props.zoomConfiguration
    const zoomValue = (zoomDirection === 'in') ? zoomInValue : zoomOutValue
    const point = localPoint(event)
    this.zoom.scale({ scaleX: zoomValue, scaleY: zoomValue, point })
  }
github rohan-paul / stock-dashboard-react / src / Components / BitCoin / BitCoin.js View on Github external
handleTooltip({ event, data, xStock, xScale, yScale }) {
    const { showTooltip } = this.props;
    const { x } = localPoint(event);
    const x0 = xScale.invert(x);
    const index = bisectDate(data, x0, 1);
    const d0 = data[index - 1];
    const d1 = data[index];
    let d = d0;
    if (d1 && d1.date) {
      d = x0 - xStock(d0.date) > xStock(d1.date) - x0 ? d1 : d0;
    }
    showTooltip({
      tooltipData: d,
      tooltipLeft: x,
      tooltipTop: d && yScale(d.close)
    });
  }
  render() {
github hshoff / vx / packages / vx-drag / src / Drag.tsx View on Github external
({ x, y, isDragging }) => {
        const point = localPoint(event) || { x: 0, y: 0 };
        return isDragging
          ? {
              isDragging: true,
              dx: -((x || 0) - point.x),
              dy: -((y || 0) - point.y),
            }
          : null;
      },
      onDragMove &&
github hshoff / viewsource / components / ethereum / chart / Chart.js View on Github external
onMouseMove={data => event => {
              const { x: xPoint, y: yPoint } = localPoint(this.svg, event);
              const bandWidth = xScale.step();
              const index = Math.floor(xPoint / bandWidth);
              const val = buckets[index];
              const left = xScale(val.closeTime);
              this.setState({
                activeBucket: val,
                yPoint
              });
            }}
            onMouseLeave={data => event =>

@vx/event

vx event

MIT
Latest version published 4 years ago

Package Health Score

78 / 100
Full package analysis