Skip to main content

scroll-chart

Description​

Fires when a chart is scrolled

Usage​

"scroll-chart": ({
left?: number,
top?: number,
date?: Date
}) => boolean | void;

Parameters​

The callback of the scroll-chart action can take an object with the following parameters:

  • left - (optional) specifies the number of pixels the chart is scrolled to the left
  • top - (optional) specifies the number of pixels the chart is scrolled to the top
  • date - (optional) the date to scroll to. The chart scrolls horizontally so that this date is at the left edge of the visible area. If you pass both date and left, left is ignored.
note

The chart can scroll only within the timescale, and the timescale doesn't extend to include the date:

  • A date earlier than the start of the scale scrolls the chart to the beginning
  • A date later than the end of the scale scrolls the chart to the rightmost position
  • A date near the end of the scale is visible after scrolling, but not at the left edge, because the chart can't scroll past the end of the scale
info

For handling the actions you can use the Event Bus methods

Example​

import { getData } from "./common/data";
import { Gantt } from "@svar-ui/react-gantt";

const data = getData();

function init(api) {
api.on("scroll-chart", ev => {
console.log("The chart is scrolled");
});
}

export default function App() {
return <Gantt tasks={data.tasks} init={init} />;
}

Related articles: