140 lines
4.5 KiB
JavaScript
140 lines
4.5 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
import { useXAxes } from "../hooks/useAxis.js";
|
|
import { ChartsXAxisImpl } from "./ChartsXAxisImpl.js";
|
|
|
|
/**
|
|
* Demos:
|
|
*
|
|
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
*
|
|
* API:
|
|
*
|
|
* - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
|
|
*/
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
function ChartsXAxis(inProps) {
|
|
const {
|
|
xAxis,
|
|
xAxisIds
|
|
} = useXAxes();
|
|
const axis = xAxis[inProps.axisId ?? xAxisIds[0]];
|
|
if (!axis) {
|
|
warnOnce(`MUI X Charts: No axis found. The axisId "${inProps.axisId}" is probably invalid.`);
|
|
return null;
|
|
}
|
|
return /*#__PURE__*/_jsx(ChartsXAxisImpl, _extends({}, inProps, {
|
|
axis: axis
|
|
}));
|
|
}
|
|
process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
axis: PropTypes.oneOf(['x']),
|
|
/**
|
|
* The id of the axis to render.
|
|
* If undefined, it will be the first defined axis.
|
|
*/
|
|
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
/**
|
|
* Override or extend the styles applied to the component.
|
|
*/
|
|
classes: PropTypes.object,
|
|
/**
|
|
* If true, the axis line is disabled.
|
|
* @default false
|
|
*/
|
|
disableLine: PropTypes.bool,
|
|
/**
|
|
* If true, the ticks are disabled.
|
|
* @default false
|
|
*/
|
|
disableTicks: PropTypes.bool,
|
|
/**
|
|
* The label of the axis.
|
|
*/
|
|
label: PropTypes.string,
|
|
/**
|
|
* The style applied to the axis label.
|
|
*/
|
|
labelStyle: PropTypes.object,
|
|
/**
|
|
* The props used for each component slot.
|
|
* @default {}
|
|
*/
|
|
slotProps: PropTypes.object,
|
|
/**
|
|
* Overridable component slots.
|
|
* @default {}
|
|
*/
|
|
slots: PropTypes.object,
|
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
/**
|
|
* Defines which ticks are displayed.
|
|
* Its value can be:
|
|
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale.
|
|
* - an array containing the values where ticks should be displayed.
|
|
* @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions}
|
|
* @default 'auto'
|
|
*/
|
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
/**
|
|
* Defines which ticks get its label displayed. Its value can be:
|
|
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
* @default 'auto'
|
|
*/
|
|
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
/**
|
|
* The minimum gap in pixels between two tick labels.
|
|
* If two tick labels are closer than this minimum gap, one of them will be hidden.
|
|
* @default 4
|
|
*/
|
|
tickLabelMinGap: PropTypes.number,
|
|
/**
|
|
* The placement of ticks label. Can be the middle of the band, or the tick position.
|
|
* Only used if scale is 'band'.
|
|
* @default 'middle'
|
|
*/
|
|
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
/**
|
|
* The style applied to ticks text.
|
|
*/
|
|
tickLabelStyle: PropTypes.object,
|
|
/**
|
|
* Maximal step between two ticks.
|
|
* When using time data, the value is assumed to be in ms.
|
|
* Not supported by categorical axis (band, points).
|
|
*/
|
|
tickMaxStep: PropTypes.number,
|
|
/**
|
|
* Minimal step between two ticks.
|
|
* When using time data, the value is assumed to be in ms.
|
|
* Not supported by categorical axis (band, points).
|
|
*/
|
|
tickMinStep: PropTypes.number,
|
|
/**
|
|
* The number of ticks. This number is not guaranteed.
|
|
* Not supported by categorical axis (band, points).
|
|
*/
|
|
tickNumber: PropTypes.number,
|
|
/**
|
|
* The placement of ticks in regard to the band interval.
|
|
* Only used if scale is 'band'.
|
|
* @default 'extremities'
|
|
*/
|
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
/**
|
|
* The size of the ticks.
|
|
* @default 6
|
|
*/
|
|
tickSize: PropTypes.number
|
|
} : void 0;
|
|
export { ChartsXAxis }; |