Skip to content

useYAxis

useYAxis(options) manages the lifecycle of a standalone Y axis. It’s the hook equivalent of <KLineChart.YAxis>.

import { useYAxis } from "react-klinecharts";
function MyYAxis() {
const id = useYAxis({ value: { paneId: "candle", position: "left" } });
return null;
}
function useYAxis(options: UseYAxisOptions): Nullable<string>

Returns the axis id (or null).

Option Type Description
value YAxisOverride Y axis config. createYAxis is idempotent, so changing value is safe.
  • Creates the axis on mount via createYAxis({ ...value, id }) with a stable id.
  • Overrides config when value changes (skips the first run).
  • Recreates the axis when paneId or name changes.
  • Removes the axis on unmount via removeYAxis({ id }).