@mui/x-charts-pro 9.0.0 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChartPro/BarChartPro.js +20 -1
- package/BarChartPro/BarChartPro.mjs +20 -1
- package/CHANGELOG.md +215 -6891
- package/ChartsDataProviderPro/ChartsDataProviderPro.js +2 -2
- package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +2 -2
- package/ChartsRadialDataProvider/index.d.mts +1 -0
- package/ChartsRadialDataProvider/index.d.ts +1 -0
- package/ChartsRadialDataProvider/index.js +16 -0
- package/ChartsRadialDataProvider/index.mjs +2 -0
- package/ChartsRadialGrid/index.d.mts +1 -0
- package/ChartsRadialGrid/index.d.ts +1 -0
- package/ChartsRadialGrid/index.js +16 -0
- package/ChartsRadialGrid/index.mjs +2 -0
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +1 -0
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.mjs +1 -0
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +1 -0
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.mjs +1 -0
- package/ChartsToolbarPro/ChartsToolbarPro.d.mts +30 -0
- package/ChartsToolbarPro/ChartsToolbarPro.d.ts +30 -0
- package/ChartsToolbarPro/ChartsToolbarPro.js +66 -17
- package/ChartsToolbarPro/ChartsToolbarPro.mjs +66 -17
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.d.mts +41 -0
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.d.ts +41 -0
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.js +156 -0
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.mjs +150 -0
- package/ChartsToolbarPro/ChartsToolbarZoomInTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomInTrigger.mjs +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.js +1 -1
- package/ChartsToolbarPro/ChartsToolbarZoomOutTrigger.mjs +1 -1
- package/ChartsToolbarPro/index.d.mts +1 -0
- package/ChartsToolbarPro/index.d.ts +1 -0
- package/ChartsToolbarPro/index.js +11 -0
- package/ChartsToolbarPro/index.mjs +1 -0
- package/ChartsToolbarPro/rangeButtonValueToZoom.d.mts +66 -0
- package/ChartsToolbarPro/rangeButtonValueToZoom.d.ts +66 -0
- package/ChartsToolbarPro/rangeButtonValueToZoom.js +217 -0
- package/ChartsToolbarPro/rangeButtonValueToZoom.mjs +212 -0
- package/Heatmap/Heatmap.js +4 -1
- package/Heatmap/Heatmap.mjs +4 -1
- package/LineChartPro/LineChartPro.js +20 -1
- package/LineChartPro/LineChartPro.mjs +20 -1
- package/ScatterChartPro/ScatterChartPro.js +20 -1
- package/ScatterChartPro/ScatterChartPro.mjs +20 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.js +1 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnWheel.mjs +1 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +1 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.mjs +1 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.js +13 -4
- package/internals/plugins/useChartProZoom/useChartProZoom.mjs +13 -4
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.mts +3 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +3 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +4 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.mjs +3 -2
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.mts +10 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +10 -0
- package/models/seriesType/heatmap.d.mts +9 -1
- package/models/seriesType/heatmap.d.ts +9 -1
- package/package.json +45 -17
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.ChartsToolbarRangeButtonTrigger = void 0;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _internals = require("@mui/x-charts/internals");
|
|
15
|
+
var _useComponentRenderer = require("@mui/x-internals/useComponentRenderer");
|
|
16
|
+
var _useChartProZoom = require("../internals/plugins/useChartProZoom");
|
|
17
|
+
var _rangeButtonValueToZoom = require("./rangeButtonValueToZoom");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
const _excluded = ["render", "value", "axisId", "label", "size"];
|
|
20
|
+
/**
|
|
21
|
+
* A button that sets the chart zoom to a predefined range.
|
|
22
|
+
* It renders the `baseToggleButton` slot.
|
|
23
|
+
*/
|
|
24
|
+
const ChartsToolbarRangeButtonTrigger = exports.ChartsToolbarRangeButtonTrigger = /*#__PURE__*/React.forwardRef(function ChartsToolbarRangeButtonTrigger(_ref, ref) {
|
|
25
|
+
let {
|
|
26
|
+
render,
|
|
27
|
+
value,
|
|
28
|
+
axisId: axisIdProp,
|
|
29
|
+
label,
|
|
30
|
+
size = 'small'
|
|
31
|
+
} = _ref,
|
|
32
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
33
|
+
const {
|
|
34
|
+
slots,
|
|
35
|
+
slotProps
|
|
36
|
+
} = (0, _internals.useChartsSlots)();
|
|
37
|
+
const {
|
|
38
|
+
instance,
|
|
39
|
+
store
|
|
40
|
+
} = (0, _internals.useChartsContext)();
|
|
41
|
+
const activeRangeButtonKey = store.use(_useChartProZoom.selectorChartActiveRangeButtonKey);
|
|
42
|
+
const canZoomOut = store.use(_useChartProZoom.selectorChartCanZoomOut);
|
|
43
|
+
const zoomOptionsLookup = store.use(_internals.selectorChartZoomOptionsLookup);
|
|
44
|
+
const rawXAxes = store.use(_internals.selectorChartRawXAxis);
|
|
45
|
+
const {
|
|
46
|
+
domains
|
|
47
|
+
} = store.use(_internals.selectorChartXAxisWithDomains);
|
|
48
|
+
|
|
49
|
+
// Resolve the target axis ID: use the prop, or find the first zoomable x-axis.
|
|
50
|
+
const resolvedAxisId = React.useMemo(() => {
|
|
51
|
+
if (axisIdProp !== undefined) {
|
|
52
|
+
return axisIdProp;
|
|
53
|
+
}
|
|
54
|
+
if (!rawXAxes) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
return rawXAxes.find(axis => zoomOptionsLookup[axis.id] !== undefined)?.id;
|
|
58
|
+
}, [axisIdProp, rawXAxes, zoomOptionsLookup]);
|
|
59
|
+
|
|
60
|
+
// Determine if the resolved axis is ordinal (band/point) to use index-based domain.
|
|
61
|
+
const resolvedAxis = React.useMemo(() => rawXAxes?.find(axis => axis.id === resolvedAxisId), [rawXAxes, resolvedAxisId]);
|
|
62
|
+
const isOrdinal = resolvedAxis?.scaleType === 'band' || resolvedAxis?.scaleType === 'point';
|
|
63
|
+
|
|
64
|
+
// Get the full domain for the target axis, ignoring the current zoom.
|
|
65
|
+
// For ordinal axes (band/point), use index-based range since domain values are categories.
|
|
66
|
+
const axisDomain = React.useMemo(() => {
|
|
67
|
+
if (resolvedAxisId === undefined) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const domainDef = domains[resolvedAxisId];
|
|
71
|
+
if (!domainDef || domainDef.domain.length < 2) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
if (isOrdinal) {
|
|
75
|
+
return {
|
|
76
|
+
min: 0,
|
|
77
|
+
max: domainDef.domain.length - 1
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const min = domainDef.domain[0];
|
|
81
|
+
const max = domainDef.domain[domainDef.domain.length - 1];
|
|
82
|
+
return {
|
|
83
|
+
min: Number(min),
|
|
84
|
+
max: Number(max)
|
|
85
|
+
};
|
|
86
|
+
}, [resolvedAxisId, domains, isOrdinal]);
|
|
87
|
+
const handleClick = React.useCallback(() => {
|
|
88
|
+
if (resolvedAxisId === undefined || !axisDomain) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const zoom = (0, _rangeButtonValueToZoom.rangeButtonValueToZoom)(value, {
|
|
92
|
+
scaleType: resolvedAxis?.scaleType ?? 'linear',
|
|
93
|
+
data: resolvedAxis?.data,
|
|
94
|
+
domain: axisDomain
|
|
95
|
+
});
|
|
96
|
+
instance.setAxisZoomData(resolvedAxisId, {
|
|
97
|
+
axisId: resolvedAxisId,
|
|
98
|
+
start: zoom.start,
|
|
99
|
+
end: zoom.end
|
|
100
|
+
});
|
|
101
|
+
instance.setActiveRangeButtonKey(label);
|
|
102
|
+
}, [resolvedAxisId, resolvedAxis, axisDomain, value, instance, label]);
|
|
103
|
+
|
|
104
|
+
// Determine if this button is selected.
|
|
105
|
+
// When explicitly clicked, activeRangeButtonKey matches the label.
|
|
106
|
+
// When no button has been clicked and zoom is at full range, the null-value button is active.
|
|
107
|
+
const isActive = activeRangeButtonKey === label || activeRangeButtonKey === null && value === null && !canZoomOut;
|
|
108
|
+
const element = (0, _useComponentRenderer.useComponentRenderer)(slots.baseToggleButton, render, (0, _extends2.default)({}, slotProps.baseToggleButton, {
|
|
109
|
+
onClick: handleClick,
|
|
110
|
+
selected: isActive,
|
|
111
|
+
value: label,
|
|
112
|
+
size
|
|
113
|
+
}, other, {
|
|
114
|
+
ref
|
|
115
|
+
}));
|
|
116
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
|
|
117
|
+
children: element
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
if (process.env.NODE_ENV !== "production") ChartsToolbarRangeButtonTrigger.displayName = "ChartsToolbarRangeButtonTrigger";
|
|
121
|
+
process.env.NODE_ENV !== "production" ? ChartsToolbarRangeButtonTrigger.propTypes = {
|
|
122
|
+
// ----------------------------- Warning --------------------------------
|
|
123
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
124
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
125
|
+
// ----------------------------------------------------------------------
|
|
126
|
+
/**
|
|
127
|
+
* The axis ID to apply the range to.
|
|
128
|
+
* Defaults to the first x-axis with zoom enabled.
|
|
129
|
+
*/
|
|
130
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
131
|
+
/**
|
|
132
|
+
* The label used to identify the button for active-state tracking.
|
|
133
|
+
*/
|
|
134
|
+
label: _propTypes.default.string.isRequired,
|
|
135
|
+
/**
|
|
136
|
+
* A function to customize the rendering of the component.
|
|
137
|
+
*/
|
|
138
|
+
render: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.func]),
|
|
139
|
+
/**
|
|
140
|
+
* The size of the button.
|
|
141
|
+
* @default 'small'
|
|
142
|
+
*/
|
|
143
|
+
size: _propTypes.default.oneOf(['large', 'medium', 'small']),
|
|
144
|
+
/**
|
|
145
|
+
* The range value. Specifies how far back from the end of the data to zoom.
|
|
146
|
+
*
|
|
147
|
+
* - `{ unit, step }` — A calendar interval from the end of the data (e.g., `{ unit: 'month', step: 3 }` for 3 months).
|
|
148
|
+
* - `[start, end]` — An absolute date range.
|
|
149
|
+
* - `(params) => { start, end }` — A function that receives axis context (`scaleType`, `data`, `domain`) and returns zoom percentages (0-100).
|
|
150
|
+
* - `null` — Resets zoom to show all data.
|
|
151
|
+
*/
|
|
152
|
+
value: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.instanceOf(Date).isRequired), _propTypes.default.func, _propTypes.default.shape({
|
|
153
|
+
step: _propTypes.default.number,
|
|
154
|
+
unit: _propTypes.default.oneOf(['day', 'hour', 'microsecond', 'millisecond', 'minute', 'month', 'second', 'week', 'year']).isRequired
|
|
155
|
+
})])
|
|
156
|
+
} : void 0;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["render", "value", "axisId", "label", "size"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { useChartsContext, useChartsSlots, selectorChartRawXAxis, selectorChartXAxisWithDomains, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
9
|
+
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
|
|
10
|
+
import { selectorChartActiveRangeButtonKey, selectorChartCanZoomOut } from "../internals/plugins/useChartProZoom/index.mjs";
|
|
11
|
+
import { rangeButtonValueToZoom } from "./rangeButtonValueToZoom.mjs";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* A button that sets the chart zoom to a predefined range.
|
|
15
|
+
* It renders the `baseToggleButton` slot.
|
|
16
|
+
*/
|
|
17
|
+
const ChartsToolbarRangeButtonTrigger = /*#__PURE__*/React.forwardRef(function ChartsToolbarRangeButtonTrigger(_ref, ref) {
|
|
18
|
+
let {
|
|
19
|
+
render,
|
|
20
|
+
value,
|
|
21
|
+
axisId: axisIdProp,
|
|
22
|
+
label,
|
|
23
|
+
size = 'small'
|
|
24
|
+
} = _ref,
|
|
25
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
26
|
+
const {
|
|
27
|
+
slots,
|
|
28
|
+
slotProps
|
|
29
|
+
} = useChartsSlots();
|
|
30
|
+
const {
|
|
31
|
+
instance,
|
|
32
|
+
store
|
|
33
|
+
} = useChartsContext();
|
|
34
|
+
const activeRangeButtonKey = store.use(selectorChartActiveRangeButtonKey);
|
|
35
|
+
const canZoomOut = store.use(selectorChartCanZoomOut);
|
|
36
|
+
const zoomOptionsLookup = store.use(selectorChartZoomOptionsLookup);
|
|
37
|
+
const rawXAxes = store.use(selectorChartRawXAxis);
|
|
38
|
+
const {
|
|
39
|
+
domains
|
|
40
|
+
} = store.use(selectorChartXAxisWithDomains);
|
|
41
|
+
|
|
42
|
+
// Resolve the target axis ID: use the prop, or find the first zoomable x-axis.
|
|
43
|
+
const resolvedAxisId = React.useMemo(() => {
|
|
44
|
+
if (axisIdProp !== undefined) {
|
|
45
|
+
return axisIdProp;
|
|
46
|
+
}
|
|
47
|
+
if (!rawXAxes) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return rawXAxes.find(axis => zoomOptionsLookup[axis.id] !== undefined)?.id;
|
|
51
|
+
}, [axisIdProp, rawXAxes, zoomOptionsLookup]);
|
|
52
|
+
|
|
53
|
+
// Determine if the resolved axis is ordinal (band/point) to use index-based domain.
|
|
54
|
+
const resolvedAxis = React.useMemo(() => rawXAxes?.find(axis => axis.id === resolvedAxisId), [rawXAxes, resolvedAxisId]);
|
|
55
|
+
const isOrdinal = resolvedAxis?.scaleType === 'band' || resolvedAxis?.scaleType === 'point';
|
|
56
|
+
|
|
57
|
+
// Get the full domain for the target axis, ignoring the current zoom.
|
|
58
|
+
// For ordinal axes (band/point), use index-based range since domain values are categories.
|
|
59
|
+
const axisDomain = React.useMemo(() => {
|
|
60
|
+
if (resolvedAxisId === undefined) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const domainDef = domains[resolvedAxisId];
|
|
64
|
+
if (!domainDef || domainDef.domain.length < 2) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
if (isOrdinal) {
|
|
68
|
+
return {
|
|
69
|
+
min: 0,
|
|
70
|
+
max: domainDef.domain.length - 1
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
const min = domainDef.domain[0];
|
|
74
|
+
const max = domainDef.domain[domainDef.domain.length - 1];
|
|
75
|
+
return {
|
|
76
|
+
min: Number(min),
|
|
77
|
+
max: Number(max)
|
|
78
|
+
};
|
|
79
|
+
}, [resolvedAxisId, domains, isOrdinal]);
|
|
80
|
+
const handleClick = React.useCallback(() => {
|
|
81
|
+
if (resolvedAxisId === undefined || !axisDomain) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const zoom = rangeButtonValueToZoom(value, {
|
|
85
|
+
scaleType: resolvedAxis?.scaleType ?? 'linear',
|
|
86
|
+
data: resolvedAxis?.data,
|
|
87
|
+
domain: axisDomain
|
|
88
|
+
});
|
|
89
|
+
instance.setAxisZoomData(resolvedAxisId, {
|
|
90
|
+
axisId: resolvedAxisId,
|
|
91
|
+
start: zoom.start,
|
|
92
|
+
end: zoom.end
|
|
93
|
+
});
|
|
94
|
+
instance.setActiveRangeButtonKey(label);
|
|
95
|
+
}, [resolvedAxisId, resolvedAxis, axisDomain, value, instance, label]);
|
|
96
|
+
|
|
97
|
+
// Determine if this button is selected.
|
|
98
|
+
// When explicitly clicked, activeRangeButtonKey matches the label.
|
|
99
|
+
// When no button has been clicked and zoom is at full range, the null-value button is active.
|
|
100
|
+
const isActive = activeRangeButtonKey === label || activeRangeButtonKey === null && value === null && !canZoomOut;
|
|
101
|
+
const element = useComponentRenderer(slots.baseToggleButton, render, _extends({}, slotProps.baseToggleButton, {
|
|
102
|
+
onClick: handleClick,
|
|
103
|
+
selected: isActive,
|
|
104
|
+
value: label,
|
|
105
|
+
size
|
|
106
|
+
}, other, {
|
|
107
|
+
ref
|
|
108
|
+
}));
|
|
109
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
110
|
+
children: element
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
if (process.env.NODE_ENV !== "production") ChartsToolbarRangeButtonTrigger.displayName = "ChartsToolbarRangeButtonTrigger";
|
|
114
|
+
process.env.NODE_ENV !== "production" ? ChartsToolbarRangeButtonTrigger.propTypes = {
|
|
115
|
+
// ----------------------------- Warning --------------------------------
|
|
116
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
117
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
118
|
+
// ----------------------------------------------------------------------
|
|
119
|
+
/**
|
|
120
|
+
* The axis ID to apply the range to.
|
|
121
|
+
* Defaults to the first x-axis with zoom enabled.
|
|
122
|
+
*/
|
|
123
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
124
|
+
/**
|
|
125
|
+
* The label used to identify the button for active-state tracking.
|
|
126
|
+
*/
|
|
127
|
+
label: PropTypes.string.isRequired,
|
|
128
|
+
/**
|
|
129
|
+
* A function to customize the rendering of the component.
|
|
130
|
+
*/
|
|
131
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
132
|
+
/**
|
|
133
|
+
* The size of the button.
|
|
134
|
+
* @default 'small'
|
|
135
|
+
*/
|
|
136
|
+
size: PropTypes.oneOf(['large', 'medium', 'small']),
|
|
137
|
+
/**
|
|
138
|
+
* The range value. Specifies how far back from the end of the data to zoom.
|
|
139
|
+
*
|
|
140
|
+
* - `{ unit, step }` — A calendar interval from the end of the data (e.g., `{ unit: 'month', step: 3 }` for 3 months).
|
|
141
|
+
* - `[start, end]` — An absolute date range.
|
|
142
|
+
* - `(params) => { start, end }` — A function that receives axis context (`scaleType`, `data`, `domain`) and returns zoom percentages (0-100).
|
|
143
|
+
* - `null` — Resets zoom to show all data.
|
|
144
|
+
*/
|
|
145
|
+
value: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.instanceOf(Date).isRequired), PropTypes.func, PropTypes.shape({
|
|
146
|
+
step: PropTypes.number,
|
|
147
|
+
unit: PropTypes.oneOf(['day', 'hour', 'microsecond', 'millisecond', 'minute', 'month', 'second', 'week', 'year']).isRequired
|
|
148
|
+
})])
|
|
149
|
+
} : void 0;
|
|
150
|
+
export { ChartsToolbarRangeButtonTrigger };
|
|
@@ -33,7 +33,7 @@ const ChartsToolbarZoomInTrigger = exports.ChartsToolbarZoomInTrigger = /*#__PUR
|
|
|
33
33
|
instance,
|
|
34
34
|
store
|
|
35
35
|
} = (0, _internals.useChartsContext)();
|
|
36
|
-
const disabled = store.use(_useChartProZoom.selectorChartCanZoomIn);
|
|
36
|
+
const disabled = !store.use(_useChartProZoom.selectorChartCanZoomIn);
|
|
37
37
|
const element = (0, _useComponentRenderer.useComponentRenderer)(slots.baseButton, render, (0, _extends2.default)({}, slotProps.baseButton, {
|
|
38
38
|
onClick: () => instance.zoomIn(),
|
|
39
39
|
disabled
|
|
@@ -26,7 +26,7 @@ const ChartsToolbarZoomInTrigger = /*#__PURE__*/React.forwardRef(function Charts
|
|
|
26
26
|
instance,
|
|
27
27
|
store
|
|
28
28
|
} = useChartsContext();
|
|
29
|
-
const disabled = store.use(selectorChartCanZoomIn);
|
|
29
|
+
const disabled = !store.use(selectorChartCanZoomIn);
|
|
30
30
|
const element = useComponentRenderer(slots.baseButton, render, _extends({}, slotProps.baseButton, {
|
|
31
31
|
onClick: () => instance.zoomIn(),
|
|
32
32
|
disabled
|
|
@@ -33,7 +33,7 @@ const ChartsToolbarZoomOutTrigger = exports.ChartsToolbarZoomOutTrigger = /*#__P
|
|
|
33
33
|
instance,
|
|
34
34
|
store
|
|
35
35
|
} = (0, _internals.useChartsContext)();
|
|
36
|
-
const disabled = store.use(_useChartProZoom.selectorChartCanZoomOut);
|
|
36
|
+
const disabled = !store.use(_useChartProZoom.selectorChartCanZoomOut);
|
|
37
37
|
const element = (0, _useComponentRenderer.useComponentRenderer)(slots.baseButton, render, (0, _extends2.default)({}, slotProps.baseButton, {
|
|
38
38
|
onClick: () => instance.zoomOut(),
|
|
39
39
|
disabled
|
|
@@ -26,7 +26,7 @@ const ChartsToolbarZoomOutTrigger = /*#__PURE__*/React.forwardRef(function Chart
|
|
|
26
26
|
instance,
|
|
27
27
|
store
|
|
28
28
|
} = useChartsContext();
|
|
29
|
-
const disabled = store.use(selectorChartCanZoomOut);
|
|
29
|
+
const disabled = !store.use(selectorChartCanZoomOut);
|
|
30
30
|
const element = useComponentRenderer(slots.baseButton, render, _extends({}, slotProps.baseButton, {
|
|
31
31
|
onClick: () => instance.zoomOut(),
|
|
32
32
|
disabled
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./ChartsToolbarPro.mjs";
|
|
2
2
|
export * from "./ChartsToolbarZoomInTrigger.mjs";
|
|
3
3
|
export * from "./ChartsToolbarZoomOutTrigger.mjs";
|
|
4
|
+
export * from "./ChartsToolbarRangeButtonTrigger.mjs";
|
|
4
5
|
export * from "./ChartsToolbarPrintExportTrigger.mjs";
|
|
5
6
|
export * from "./ChartsToolbarImageExportTrigger.mjs";
|
|
6
7
|
export type { ChartsToolbarProSlots, ChartsToolbarProSlotProps } from "./Toolbar.types.mjs";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./ChartsToolbarPro.js";
|
|
2
2
|
export * from "./ChartsToolbarZoomInTrigger.js";
|
|
3
3
|
export * from "./ChartsToolbarZoomOutTrigger.js";
|
|
4
|
+
export * from "./ChartsToolbarRangeButtonTrigger.js";
|
|
4
5
|
export * from "./ChartsToolbarPrintExportTrigger.js";
|
|
5
6
|
export * from "./ChartsToolbarImageExportTrigger.js";
|
|
6
7
|
export type { ChartsToolbarProSlots, ChartsToolbarProSlotProps } from "./Toolbar.types.js";
|
|
@@ -36,6 +36,17 @@ Object.keys(_ChartsToolbarZoomOutTrigger).forEach(function (key) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
var _ChartsToolbarRangeButtonTrigger = require("./ChartsToolbarRangeButtonTrigger");
|
|
40
|
+
Object.keys(_ChartsToolbarRangeButtonTrigger).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _ChartsToolbarRangeButtonTrigger[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _ChartsToolbarRangeButtonTrigger[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
39
50
|
var _ChartsToolbarPrintExportTrigger = require("./ChartsToolbarPrintExportTrigger");
|
|
40
51
|
Object.keys(_ChartsToolbarPrintExportTrigger).forEach(function (key) {
|
|
41
52
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./ChartsToolbarPro.mjs";
|
|
2
2
|
export * from "./ChartsToolbarZoomInTrigger.mjs";
|
|
3
3
|
export * from "./ChartsToolbarZoomOutTrigger.mjs";
|
|
4
|
+
export * from "./ChartsToolbarRangeButtonTrigger.mjs";
|
|
4
5
|
export * from "./ChartsToolbarPrintExportTrigger.mjs";
|
|
5
6
|
export * from "./ChartsToolbarImageExportTrigger.mjs";
|
|
6
7
|
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar interval unit for range buttons.
|
|
3
|
+
*/
|
|
4
|
+
export type RangeButtonIntervalUnit = 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
5
|
+
/**
|
|
6
|
+
* Parameters passed to a range button function value.
|
|
7
|
+
*/
|
|
8
|
+
export interface RangeButtonFunctionParams {
|
|
9
|
+
/**
|
|
10
|
+
* The scale type of the axis (e.g., `'time'`, `'band'`, `'linear'`).
|
|
11
|
+
*/
|
|
12
|
+
scaleType: string;
|
|
13
|
+
/**
|
|
14
|
+
* The axis data values. Available for ordinal (band/point) axes.
|
|
15
|
+
*/
|
|
16
|
+
data: readonly unknown[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The full domain bounds, ignoring any current zoom.
|
|
19
|
+
* For time axes, these are timestamps. For ordinal axes, these are indices.
|
|
20
|
+
*/
|
|
21
|
+
domain: {
|
|
22
|
+
min: number;
|
|
23
|
+
max: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Defines the value of a range button.
|
|
28
|
+
*
|
|
29
|
+
* - `{ unit, step }` — A calendar interval from the end of the data.
|
|
30
|
+
* @example { unit: 'month', step: 3 } // Last 3 months
|
|
31
|
+
* @example { unit: 'year' } // Last year (step defaults to 1)
|
|
32
|
+
* - `[start, end]` — An absolute date range.
|
|
33
|
+
* @example [new Date(2024, 0, 1), new Date(2024, 6, 1)] // Jan–Jul 2024
|
|
34
|
+
* - `(params) => { start, end }` — A function that receives axis context (`scaleType`, `data`, `domain`) and returns zoom percentages (0-100).
|
|
35
|
+
* @example ({ domain }) => ({ start: 0, end: 50 }) // First half of data
|
|
36
|
+
* @example ({ data }) => {
|
|
37
|
+
* const lastFive = Math.max(0, data.length - 5);
|
|
38
|
+
* return { start: (lastFive / (data.length - 1)) * 100, end: 100 };
|
|
39
|
+
* } // Last 5 items on an ordinal axis
|
|
40
|
+
* - `null` — Resets zoom to show all data.
|
|
41
|
+
* @example null // Show all data
|
|
42
|
+
*/
|
|
43
|
+
export type RangeButtonValue = {
|
|
44
|
+
unit: RangeButtonIntervalUnit;
|
|
45
|
+
step?: number;
|
|
46
|
+
} | [Date, Date] | ((params: RangeButtonFunctionParams) => {
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
}) | null;
|
|
50
|
+
/**
|
|
51
|
+
* Converts a range button value to zoom start/end percentages.
|
|
52
|
+
*
|
|
53
|
+
* The range is calculated from the end of the axis domain.
|
|
54
|
+
* For example, `{ unit: 'month', step: 3 }` will zoom to show the last 3 months of data.
|
|
55
|
+
*
|
|
56
|
+
* @param value The range button value.
|
|
57
|
+
* @param params The axis context passed to function values.
|
|
58
|
+
* @param params.scaleType The scale type of the axis.
|
|
59
|
+
* @param params.data The axis data values (for ordinal axes).
|
|
60
|
+
* @param params.domain The full domain bounds.
|
|
61
|
+
* @returns The zoom start and end percentages (0-100).
|
|
62
|
+
*/
|
|
63
|
+
export declare function rangeButtonValueToZoom(value: RangeButtonValue, params: RangeButtonFunctionParams): {
|
|
64
|
+
start: number;
|
|
65
|
+
end: number;
|
|
66
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar interval unit for range buttons.
|
|
3
|
+
*/
|
|
4
|
+
export type RangeButtonIntervalUnit = 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
5
|
+
/**
|
|
6
|
+
* Parameters passed to a range button function value.
|
|
7
|
+
*/
|
|
8
|
+
export interface RangeButtonFunctionParams {
|
|
9
|
+
/**
|
|
10
|
+
* The scale type of the axis (e.g., `'time'`, `'band'`, `'linear'`).
|
|
11
|
+
*/
|
|
12
|
+
scaleType: string;
|
|
13
|
+
/**
|
|
14
|
+
* The axis data values. Available for ordinal (band/point) axes.
|
|
15
|
+
*/
|
|
16
|
+
data: readonly unknown[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The full domain bounds, ignoring any current zoom.
|
|
19
|
+
* For time axes, these are timestamps. For ordinal axes, these are indices.
|
|
20
|
+
*/
|
|
21
|
+
domain: {
|
|
22
|
+
min: number;
|
|
23
|
+
max: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Defines the value of a range button.
|
|
28
|
+
*
|
|
29
|
+
* - `{ unit, step }` — A calendar interval from the end of the data.
|
|
30
|
+
* @example { unit: 'month', step: 3 } // Last 3 months
|
|
31
|
+
* @example { unit: 'year' } // Last year (step defaults to 1)
|
|
32
|
+
* - `[start, end]` — An absolute date range.
|
|
33
|
+
* @example [new Date(2024, 0, 1), new Date(2024, 6, 1)] // Jan–Jul 2024
|
|
34
|
+
* - `(params) => { start, end }` — A function that receives axis context (`scaleType`, `data`, `domain`) and returns zoom percentages (0-100).
|
|
35
|
+
* @example ({ domain }) => ({ start: 0, end: 50 }) // First half of data
|
|
36
|
+
* @example ({ data }) => {
|
|
37
|
+
* const lastFive = Math.max(0, data.length - 5);
|
|
38
|
+
* return { start: (lastFive / (data.length - 1)) * 100, end: 100 };
|
|
39
|
+
* } // Last 5 items on an ordinal axis
|
|
40
|
+
* - `null` — Resets zoom to show all data.
|
|
41
|
+
* @example null // Show all data
|
|
42
|
+
*/
|
|
43
|
+
export type RangeButtonValue = {
|
|
44
|
+
unit: RangeButtonIntervalUnit;
|
|
45
|
+
step?: number;
|
|
46
|
+
} | [Date, Date] | ((params: RangeButtonFunctionParams) => {
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
}) | null;
|
|
50
|
+
/**
|
|
51
|
+
* Converts a range button value to zoom start/end percentages.
|
|
52
|
+
*
|
|
53
|
+
* The range is calculated from the end of the axis domain.
|
|
54
|
+
* For example, `{ unit: 'month', step: 3 }` will zoom to show the last 3 months of data.
|
|
55
|
+
*
|
|
56
|
+
* @param value The range button value.
|
|
57
|
+
* @param params The axis context passed to function values.
|
|
58
|
+
* @param params.scaleType The scale type of the axis.
|
|
59
|
+
* @param params.data The axis data values (for ordinal axes).
|
|
60
|
+
* @param params.domain The full domain bounds.
|
|
61
|
+
* @returns The zoom start and end percentages (0-100).
|
|
62
|
+
*/
|
|
63
|
+
export declare function rangeButtonValueToZoom(value: RangeButtonValue, params: RangeButtonFunctionParams): {
|
|
64
|
+
start: number;
|
|
65
|
+
end: number;
|
|
66
|
+
};
|