FunctionPlotter

An interactive 2D function plotter with pan, zoom, and support for multiple equations. Enter expressions like x^2 or 2*x+1 and see them graphed in real time.

Installation

npx @obi/ui add function-plotter

Preview

Usage

import { FunctionPlotter } from '@/src/components/FunctionPlotter/FunctionPlotter';

export default function Example() {
  return (
    <FunctionPlotter
      initialEquations={['x^2', '2*x + 1', 'Math.sin(x) * 5']}
    />
  );
}

Props

NameTypeDefaultDescription
initialEquationsstring[]['2*x + 1', 'x^2']Equations to plot on mount. Supports +, -, *, /, ^, and Math.* functions.
heightnumber400Canvas height in pixels. Width fills the container.
classNamestring''Additional classes on the root wrapper.