58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
/**
|
|
* @fileOverview X Axis
|
|
*/
|
|
|
|
import React from 'react';
|
|
import clsx from 'clsx';
|
|
import { useChartHeight, useChartWidth, useXAxisOrThrow } from '../context/chartLayoutContext';
|
|
import { CartesianAxis } from './CartesianAxis';
|
|
import { getTicksOfAxis } from '../util/ChartUtils';
|
|
|
|
/** Define of XAxis props */
|
|
|
|
export var XAxis = function XAxis(_ref) {
|
|
var xAxisId = _ref.xAxisId;
|
|
var width = useChartWidth();
|
|
var height = useChartHeight();
|
|
var axisOptions = useXAxisOrThrow(xAxisId);
|
|
if (axisOptions == null) {
|
|
return null;
|
|
}
|
|
return (
|
|
/*#__PURE__*/
|
|
// @ts-expect-error the axisOptions type is not exactly what CartesianAxis is expecting.
|
|
React.createElement(CartesianAxis, _extends({}, axisOptions, {
|
|
className: clsx("recharts-".concat(axisOptions.axisType, " ").concat(axisOptions.axisType), axisOptions.className),
|
|
viewBox: {
|
|
x: 0,
|
|
y: 0,
|
|
width: width,
|
|
height: height
|
|
},
|
|
ticksGenerator: function ticksGenerator(axis) {
|
|
return getTicksOfAxis(axis, true);
|
|
}
|
|
}))
|
|
);
|
|
};
|
|
XAxis.displayName = 'XAxis';
|
|
XAxis.defaultProps = {
|
|
allowDecimals: true,
|
|
hide: false,
|
|
orientation: 'bottom',
|
|
width: 0,
|
|
height: 30,
|
|
mirror: false,
|
|
xAxisId: 0,
|
|
tickCount: 5,
|
|
type: 'category',
|
|
padding: {
|
|
left: 0,
|
|
right: 0
|
|
},
|
|
allowDataOverflow: false,
|
|
scale: 'auto',
|
|
reversed: false,
|
|
allowDuplicatedCategory: true
|
|
}; |