expand-scale
Description
Fires when the scale does not fill all free space in the chart and it's required to expand scale boundariesUsage
"expand-scale": ({
minWidth: number,
date?:Date,
offset: number
}) => boolean|void;
Parameters
The callback of the action takes an object with the following parameters:
minWidth
- (required) the minimum width of the scale in pixelsdate
- (optional) the date applied as the center of the zoomed area. The date format should be of the one supported by date-fnsoffset
- (optional) the cursor location in the x-axis on a page in pixels
info
For handling the actions you can use the Event Bus methods
Example
If the scale is less than than the viewport, the example below will output the minWidth value.
<script>
import { getData } from "../data";
import { Gantt } from "wx-svelte-gantt";
const data = getData();
let api;
$: if (api) {
api.on("expand-scale", (ev) => {
console.log("Current scale minWidth", ev.minWidth);
});
}
</script>
<Gantt bind:api tasks={data.tasks} links={data.links} scales={data.scales} />
Related articles: How to access Gantt API