Skip to content

useChartAxes

Override the chart’s built-in X (time) and Y (value) axes — flip the price scale, draw labels inside the pane, lock zoom, or supply custom range / tick generators. Wraps klinecharts’ overrideXAxis / overrideYAxis, and manages standalone Y axes through the klinecharts 10.0.0 multi-YAxis API (createYAxis / removeYAxis / getYAxes).

import { useChartAxes } from "react-klinecharts-ui";
const { overrideXAxis, overrideYAxis, createYAxis, removeYAxis, getYAxes } = useChartAxes();
overrideYAxis({ reverse: true }); // flip the price scale
overrideYAxis({ inside: true }); // draw price labels inside the pane
overrideXAxis({ scrollZoomEnabled: false }); // lock time-axis zoom
// klinecharts 10.0.0 — add a standalone Y axis to a pane.
const axisId = createYAxis({ id: "rsi_axis", paneId: "pane_rsi", position: "left" });
getYAxes({ paneId: "pane_rsi" }); // → YAxis[] (filter by id/paneId/name)
removeYAxis({ id: axisId }); // → boolean
PropertyTypeDescription
overrideXAxis(override: XAxisOverride) => voidOverride the main X (time) axis (name, scrollZoomEnabled, createTicks)
overrideYAxis(override: YAxisOverride) => voidOverride a Y (value) axis (reverse, inside, position, scrollZoomEnabled, createRange, createTicks; pass id / paneId to target one)
createYAxis(yAxis: YAxisOverride) => string | nullCreate a standalone Y axis on a pane. Idempotent per axis id. Added in klinecharts 10.0.0.
removeYAxis(filter: YAxisFilter) => booleanRemove Y axes matching the filter (id / paneId / name). Added in klinecharts 10.0.0.
getYAxes(filter?: YAxisFilter) => YAxis[]Read the chart’s Y axes, optionally filtered by id / paneId / name. Added in klinecharts 10.0.0.