Files
ETB/ETB-FrontEnd/node_modules/@mui/x-charts/esm/hooks/useChartGradientId.js
Iliyan Angelov 306b20e24a Frontend start
2025-09-14 00:54:48 +03:00

47 lines
1.4 KiB
JavaScript

'use client';
import * as React from 'react';
import { useChartId } from "./useChartId.js";
/**
* Returns a function that generates a gradient id for the given axis id.
*/
export function useChartGradientIdBuilder() {
const chartId = useChartId();
return React.useCallback(axisId => `${chartId}-gradient-${axisId}`, [chartId]);
}
/**
* Returns a function that generates a gradient id for the given axis id.
*/
export function useChartGradientIdObjectBoundBuilder() {
const chartId = useChartId();
return React.useCallback(axisId => `${chartId}-gradient-${axisId}-object-bound`, [chartId]);
}
/**
* Returns a gradient id for the given axis id.
*
* Can be useful when reusing the same gradient on custom components.
*
* For a gradient that respects the coordinates of the object on which it is applied, use `useChartGradientIdObjectBound` instead.
*
* @param axisId the axis id
* @returns the gradient id
*/
export function useChartGradientId(axisId) {
return useChartGradientIdBuilder()(axisId);
}
/**
* Returns a gradient id for the given axis id.
*
* Can be useful when reusing the same gradient on custom components.
*
* This gradient differs from `useChartGradientId` in that it respects the coordinates of the object on which it is applied.
*
* @param axisId the axis id
* @returns the gradient id
*/
export function useChartGradientIdObjectBound(axisId) {
return useChartGradientIdObjectBoundBuilder()(axisId);
}