@mui/x-charts-pro 8.5.2 → 8.6.0
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/CHANGELOG.md +203 -11
- package/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
- package/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +20 -31
- package/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
- package/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
- package/ChartZoomSlider/internals/zoom-utils.js +19 -8
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +77 -0
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
- package/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +75 -0
- package/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
- package/ChartsToolbarPro/ChartsToolbarPro.js +118 -8
- package/ChartsToolbarPro/index.d.ts +3 -1
- package/ChartsToolbarPro/index.js +22 -0
- package/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
- package/ChartsToolbarPro/internals/ChartsMenu.js +73 -0
- package/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
- package/ChartsToolbarPro/internals/ChartsToolbarDivider.js +47 -0
- package/FunnelChart/FunnelPlot.js +56 -40
- package/FunnelChart/FunnelSection.js +2 -0
- package/FunnelChart/curves/bump.d.ts +3 -3
- package/FunnelChart/curves/bump.js +3 -0
- package/FunnelChart/curves/curve.types.d.ts +14 -1
- package/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
- package/FunnelChart/curves/linear.d.ts +3 -3
- package/FunnelChart/curves/linear.js +23 -18
- package/FunnelChart/curves/pyramid.d.ts +3 -3
- package/FunnelChart/curves/pyramid.js +17 -12
- package/FunnelChart/curves/step-pyramid.d.ts +5 -5
- package/FunnelChart/curves/step-pyramid.js +20 -18
- package/FunnelChart/curves/step.d.ts +3 -3
- package/FunnelChart/curves/step.js +14 -12
- package/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
- package/FunnelChart/labelUtils.d.ts +4 -12
- package/FunnelChart/labelUtils.js +43 -44
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +1 -1
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSlider.js +1 -1
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderActiveTrack.js +21 -32
- package/esm/ChartZoomSlider/internals/ChartAxisZoomSliderTrack.js +1 -8
- package/esm/ChartZoomSlider/internals/zoom-utils.d.ts +3 -1
- package/esm/ChartZoomSlider/internals/zoom-utils.js +19 -9
- package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.d.ts +27 -0
- package/esm/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +70 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.d.ts +33 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPrintExportTrigger.js +68 -0
- package/esm/ChartsToolbarPro/ChartsToolbarPro.d.ts +16 -3
- package/esm/ChartsToolbarPro/ChartsToolbarPro.js +120 -8
- package/esm/ChartsToolbarPro/index.d.ts +3 -1
- package/esm/ChartsToolbarPro/index.js +3 -1
- package/esm/ChartsToolbarPro/internals/ChartsMenu.d.ts +14 -0
- package/esm/ChartsToolbarPro/internals/ChartsMenu.js +67 -0
- package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.d.ts +5 -0
- package/esm/ChartsToolbarPro/internals/ChartsToolbarDivider.js +40 -0
- package/esm/FunnelChart/FunnelPlot.js +56 -40
- package/esm/FunnelChart/FunnelSection.js +2 -0
- package/esm/FunnelChart/curves/bump.d.ts +3 -3
- package/esm/FunnelChart/curves/bump.js +3 -0
- package/esm/FunnelChart/curves/curve.types.d.ts +14 -1
- package/esm/FunnelChart/curves/getFunnelCurve.d.ts +7 -2
- package/esm/FunnelChart/curves/linear.d.ts +3 -3
- package/esm/FunnelChart/curves/linear.js +23 -18
- package/esm/FunnelChart/curves/pyramid.d.ts +3 -3
- package/esm/FunnelChart/curves/pyramid.js +17 -12
- package/esm/FunnelChart/curves/step-pyramid.d.ts +5 -5
- package/esm/FunnelChart/curves/step-pyramid.js +20 -18
- package/esm/FunnelChart/curves/step.d.ts +3 -3
- package/esm/FunnelChart/curves/step.js +14 -12
- package/esm/FunnelChart/funnelAxisPlugin/useChartFunnelAxisRendering.selectors.d.ts +18 -1444
- package/esm/FunnelChart/labelUtils.d.ts +4 -12
- package/esm/FunnelChart/labelUtils.js +43 -44
- package/esm/index.d.ts +2 -1
- package/esm/index.js +1 -1
- package/esm/internals/material/components/BaseMenuItem.d.ts +3 -0
- package/esm/internals/material/components/BaseMenuItem.js +27 -0
- package/esm/internals/material/components/BasePopper.d.ts +3 -0
- package/esm/internals/material/components/BasePopper.js +122 -0
- package/esm/internals/material/icons.d.ts +2 -1
- package/esm/internals/material/icons.js +4 -1
- package/esm/internals/material/index.d.ts +1 -0
- package/esm/internals/material/index.js +12 -3
- package/esm/internals/plugins/useChartProExport/print.js +1 -1
- package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
- package/esm/internals/slots/chartBaseSlotProps.d.ts +50 -3
- package/esm/internals/slots/chartsBaseSlots.d.ts +5 -1
- package/esm/internals/slots/chartsIconSlots.d.ts +5 -0
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/internals/material/components/BaseMenuItem.d.ts +3 -0
- package/internals/material/components/BaseMenuItem.js +35 -0
- package/internals/material/components/BasePopper.d.ts +3 -0
- package/internals/material/components/BasePopper.js +130 -0
- package/internals/material/icons.d.ts +2 -1
- package/internals/material/icons.js +5 -2
- package/internals/material/index.d.ts +1 -0
- package/internals/material/index.js +11 -2
- package/internals/plugins/useChartProExport/print.js +1 -1
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +7 -6
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +16 -595
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +2 -2
- package/internals/slots/chartBaseSlotProps.d.ts +50 -3
- package/internals/slots/chartsBaseSlots.d.ts +5 -1
- package/internals/slots/chartsIconSlots.d.ts +5 -0
- package/package.json +5 -5
- package/FunnelChart/positionGetter.d.ts +0 -1
- package/FunnelChart/positionGetter.js +0 -5
- package/esm/FunnelChart/positionGetter.d.ts +0 -1
- package/esm/FunnelChart/positionGetter.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { FunnelLabelOptions } from "./funnel.types.js";
|
|
2
|
+
import { Point } from "./curves/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* It tries to keep the label inside the bounds of the section based on the position.
|
|
5
5
|
*
|
|
@@ -24,19 +24,11 @@ export declare const alignLabel: ({
|
|
|
24
24
|
export declare const positionLabel: ({
|
|
25
25
|
position,
|
|
26
26
|
offset,
|
|
27
|
-
xPosition,
|
|
28
|
-
yPosition,
|
|
29
27
|
isHorizontal,
|
|
30
|
-
values
|
|
31
|
-
dataIndex,
|
|
32
|
-
baseScaleData
|
|
28
|
+
values
|
|
33
29
|
}: Omit<FunnelLabelOptions, "textAnchor" | "dominantBaseline"> & {
|
|
34
|
-
xPosition: PositionGetter;
|
|
35
|
-
yPosition: PositionGetter;
|
|
36
30
|
isHorizontal: boolean;
|
|
37
|
-
values: readonly
|
|
38
|
-
dataIndex: number;
|
|
39
|
-
baseScaleData: readonly number[];
|
|
31
|
+
values: readonly Point[];
|
|
40
32
|
}) => {
|
|
41
33
|
x: number;
|
|
42
34
|
y: number;
|
|
@@ -46,17 +46,21 @@ exports.alignLabel = alignLabel;
|
|
|
46
46
|
const positionLabel = ({
|
|
47
47
|
position,
|
|
48
48
|
offset,
|
|
49
|
-
xPosition,
|
|
50
|
-
yPosition,
|
|
51
49
|
isHorizontal,
|
|
52
|
-
values
|
|
53
|
-
dataIndex,
|
|
54
|
-
baseScaleData
|
|
50
|
+
values
|
|
55
51
|
}) => {
|
|
56
52
|
const vertical = position?.vertical ?? 'middle';
|
|
57
53
|
const horizontal = position?.horizontal ?? 'center';
|
|
58
54
|
let x = 0;
|
|
59
55
|
let y = 0;
|
|
56
|
+
|
|
57
|
+
// The min/max values are due to the sections possibly being sloped.
|
|
58
|
+
// Importance of values differs from the horizontal and vertical sections.
|
|
59
|
+
// Example (vertical):
|
|
60
|
+
// MaxL MaxT MaxR
|
|
61
|
+
// \ /
|
|
62
|
+
// \ /
|
|
63
|
+
// MinL MaxB MinR
|
|
60
64
|
let minTop = 0;
|
|
61
65
|
let maxTop = 0;
|
|
62
66
|
let minBottom = 0;
|
|
@@ -65,56 +69,51 @@ const positionLabel = ({
|
|
|
65
69
|
let maxLeft = 0;
|
|
66
70
|
let minRight = 0;
|
|
67
71
|
let maxRight = 0;
|
|
68
|
-
let center = 0;
|
|
69
|
-
let leftCenter = 0;
|
|
70
|
-
let rightCenter = 0;
|
|
71
72
|
let middle = 0;
|
|
72
|
-
let
|
|
73
|
-
let bottomMiddle = 0;
|
|
73
|
+
let center = 0;
|
|
74
74
|
const mv = typeof offset === 'number' ? offset : offset?.y ?? 0;
|
|
75
75
|
const mh = typeof offset === 'number' ? offset : offset?.x ?? 0;
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
// Min ... Max
|
|
78
|
+
const Ys = values.map(v => v.y).toSorted((a, b) => a - b);
|
|
79
|
+
const Xs = values.map(v => v.x).toSorted((a, b) => a - b);
|
|
80
|
+
|
|
81
|
+
// Visualization of the points in a hierarchical order:
|
|
82
|
+
// MaxT
|
|
83
|
+
// MinT
|
|
84
|
+
// MaxL MinL Cent/Mid MinR MaxR
|
|
85
|
+
// MinB
|
|
86
|
+
// MaxB
|
|
77
87
|
if (isHorizontal) {
|
|
78
|
-
maxTop =
|
|
79
|
-
minTop =
|
|
80
|
-
minBottom =
|
|
81
|
-
maxBottom =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
leftCenter = 0;
|
|
88
|
-
rightCenter = 0;
|
|
89
|
-
middle = yPosition(0, dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
|
|
90
|
-
topMiddle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) - mv;
|
|
91
|
-
bottomMiddle = yPosition(values[3].y - (values[3].y - values[2].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) + mv;
|
|
88
|
+
maxTop = Ys.at(0) - mv;
|
|
89
|
+
minTop = Ys.at(1) - mv;
|
|
90
|
+
minBottom = Ys.at(2) + mv;
|
|
91
|
+
maxBottom = (Ys.at(3) ?? Ys.at(2)) + mv;
|
|
92
|
+
maxRight = (Xs.at(3) ?? Xs.at(2)) + mh;
|
|
93
|
+
// We don't need (minRight/minLeft) for horizontal
|
|
94
|
+
maxLeft = Xs.at(0) + mh;
|
|
95
|
+
center = (maxRight + maxLeft) / 2;
|
|
96
|
+
middle = (maxBottom + maxTop) / 2;
|
|
92
97
|
} else {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
rightCenter = xPosition(values[0].x - (values[0].x - values[1].x) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) + mh;
|
|
103
|
-
leftCenter = xPosition(values[3].x - (values[3].x - values[2].x) / 2, dataIndex, baseScaleData[dataIndex], stackOffset) - mh;
|
|
104
|
-
middle = yPosition(values[0].y - (values[0].y - values[1].y) / 2, dataIndex, baseScaleData[dataIndex], stackOffset);
|
|
105
|
-
middle = maxTop - (maxTop - maxBottom) / 2;
|
|
106
|
-
topMiddle = 0;
|
|
107
|
-
bottomMiddle = 0;
|
|
98
|
+
maxTop = Ys.at(0) - mv;
|
|
99
|
+
// We don't need (minTop/minBottom) for vertical
|
|
100
|
+
maxBottom = (Ys.at(3) ?? Ys.at(2)) - mv;
|
|
101
|
+
maxRight = (Xs.at(3) ?? Xs.at(2)) + mh;
|
|
102
|
+
minRight = Xs.at(2) + mh;
|
|
103
|
+
minLeft = Xs.at(1) - mh;
|
|
104
|
+
maxLeft = Xs.at(0) - mh;
|
|
105
|
+
center = (maxRight + maxLeft) / 2;
|
|
106
|
+
middle = (maxBottom + maxTop) / 2;
|
|
108
107
|
}
|
|
109
108
|
if (isHorizontal) {
|
|
110
109
|
if (horizontal === 'center') {
|
|
111
110
|
x = center;
|
|
112
111
|
if (vertical === 'top') {
|
|
113
|
-
y =
|
|
112
|
+
y = (maxTop + minTop) / 2;
|
|
114
113
|
} else if (vertical === 'middle') {
|
|
115
114
|
y = middle;
|
|
116
115
|
} else if (vertical === 'bottom') {
|
|
117
|
-
y =
|
|
116
|
+
y = (maxBottom + minBottom) / 2;
|
|
118
117
|
}
|
|
119
118
|
} else if (horizontal === 'start') {
|
|
120
119
|
x = maxLeft;
|
|
@@ -140,11 +139,11 @@ const positionLabel = ({
|
|
|
140
139
|
if (vertical === 'middle') {
|
|
141
140
|
y = middle;
|
|
142
141
|
if (horizontal === 'start') {
|
|
143
|
-
x =
|
|
142
|
+
x = (maxLeft + minLeft) / 2;
|
|
144
143
|
} else if (horizontal === 'center') {
|
|
145
144
|
x = center;
|
|
146
145
|
} else if (horizontal === 'end') {
|
|
147
|
-
x =
|
|
146
|
+
x = (maxRight + minRight) / 2;
|
|
148
147
|
}
|
|
149
148
|
} else if (vertical === 'top') {
|
|
150
149
|
y = maxTop;
|
|
@@ -11,7 +11,7 @@ import { defaultSlotsMaterial } from "../internals/material/index.js";
|
|
|
11
11
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
12
12
|
import { useChartDataProviderProProps } from "./useChartDataProviderProProps.js";
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
const releaseInfo = "
|
|
14
|
+
const releaseInfo = "MTc1MDk3NTIwMDAwMA==";
|
|
15
15
|
const packageIdentifier = 'x-charts-pro';
|
|
16
16
|
/**
|
|
17
17
|
* Orchestrates the data providers for the chart components and hooks.
|
|
@@ -18,7 +18,7 @@ export function ChartAxisZoomSlider({
|
|
|
18
18
|
}) {
|
|
19
19
|
const store = useStore();
|
|
20
20
|
const drawingArea = useDrawingArea();
|
|
21
|
-
const zoomData = useSelector(store, selectorChartAxisZoomData, axisId);
|
|
21
|
+
const zoomData = useSelector(store, selectorChartAxisZoomData, [axisId]);
|
|
22
22
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
23
23
|
const {
|
|
24
24
|
xAxis
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
|
-
import { getSVGPoint, invertScale, selectorChartAxis, selectorChartAxisZoomOptionsLookup,
|
|
3
|
+
import { getSVGPoint, invertScale, selectorChartAxis, selectorChartAxisZoomOptionsLookup, useChartContext, useDrawingArea, useSelector, useStore } from '@mui/x-charts/internals';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
6
6
|
import { selectorChartAxisZoomData } from "../../internals/plugins/useChartProZoom/index.js";
|
|
@@ -32,7 +32,7 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
32
32
|
svgRef
|
|
33
33
|
} = useChartContext();
|
|
34
34
|
const store = useStore();
|
|
35
|
-
const axis = useSelector(store, selectorChartAxis, axisId);
|
|
35
|
+
const axis = useSelector(store, selectorChartAxis, [axisId]);
|
|
36
36
|
const drawingArea = useDrawingArea();
|
|
37
37
|
const activePreviewRectRef = React.useRef(null);
|
|
38
38
|
const [startThumbEl, setStartThumbEl] = React.useState(null);
|
|
@@ -48,10 +48,6 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
48
48
|
if (!activePreviewRect) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
/* min and max values of zoom to ensure the pointer anchor in the slider is maintained */
|
|
53
|
-
let pointerZoomMin;
|
|
54
|
-
let pointerZoomMax;
|
|
55
51
|
let prevPointerZoom = 0;
|
|
56
52
|
const onPointerMove = rafThrottle(event => {
|
|
57
53
|
const element = svgRef.current;
|
|
@@ -59,11 +55,10 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
59
55
|
return;
|
|
60
56
|
}
|
|
61
57
|
const point = getSVGPoint(element, event);
|
|
62
|
-
|
|
58
|
+
const pointerZoom = calculateZoomFromPoint(store.getSnapshot(), axisId, point);
|
|
63
59
|
if (pointerZoom === null) {
|
|
64
60
|
return;
|
|
65
61
|
}
|
|
66
|
-
pointerZoom = Math.max(pointerZoomMin, Math.min(pointerZoomMax, pointerZoom));
|
|
67
62
|
const deltaZoom = pointerZoom - prevPointerZoom;
|
|
68
63
|
prevPointerZoom = pointerZoom;
|
|
69
64
|
instance.moveZoomRange(axisId, deltaZoom);
|
|
@@ -87,8 +82,6 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
87
82
|
return;
|
|
88
83
|
}
|
|
89
84
|
prevPointerZoom = pointerDownZoom;
|
|
90
|
-
pointerZoomMin = pointerDownZoom - axisZoomData.start;
|
|
91
|
-
pointerZoomMax = 100 - (axisZoomData.end - pointerDownZoom);
|
|
92
85
|
document.addEventListener('pointerup', onPointerUp);
|
|
93
86
|
activePreviewRect.addEventListener('pointermove', onPointerMove);
|
|
94
87
|
};
|
|
@@ -129,23 +122,12 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
129
122
|
}
|
|
130
123
|
const point = getSVGPoint(element, event);
|
|
131
124
|
instance.setZoomData(prevZoomData => {
|
|
132
|
-
const {
|
|
133
|
-
left,
|
|
134
|
-
top,
|
|
135
|
-
width,
|
|
136
|
-
height
|
|
137
|
-
} = selectorChartDrawingArea(store.getSnapshot());
|
|
138
125
|
const zoomOptions = selectorChartAxisZoomOptionsLookup(store.getSnapshot(), axisId);
|
|
139
126
|
return prevZoomData.map(zoom => {
|
|
140
127
|
if (zoom.axisId === axisId) {
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
} else {
|
|
145
|
-
newEnd = (top + height - point.y) / height * 100;
|
|
146
|
-
}
|
|
147
|
-
if (reverse) {
|
|
148
|
-
newEnd = 100 - newEnd;
|
|
128
|
+
const newEnd = calculateZoomFromPoint(store.getSnapshot(), axisId, point);
|
|
129
|
+
if (newEnd === null) {
|
|
130
|
+
return zoom;
|
|
149
131
|
}
|
|
150
132
|
return _extends({}, zoom, {
|
|
151
133
|
end: calculateZoomEnd(newEnd, zoom, zoomOptions)
|
|
@@ -163,14 +145,21 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
163
145
|
let startThumbY;
|
|
164
146
|
let endThumbX;
|
|
165
147
|
let endThumbY;
|
|
148
|
+
const {
|
|
149
|
+
minStart,
|
|
150
|
+
maxEnd
|
|
151
|
+
} = selectorChartAxisZoomOptionsLookup(store.getSnapshot(), axisId);
|
|
152
|
+
const range = maxEnd - minStart;
|
|
153
|
+
const zoomStart = Math.max(minStart, zoomData.start);
|
|
154
|
+
const zoomEnd = Math.min(zoomData.end, maxEnd);
|
|
166
155
|
if (axisDirection === 'x') {
|
|
167
|
-
previewX =
|
|
156
|
+
previewX = (zoomStart - minStart) / range * drawingArea.width;
|
|
168
157
|
previewY = 0;
|
|
169
|
-
previewWidth = drawingArea.width * (
|
|
158
|
+
previewWidth = drawingArea.width * (zoomEnd - zoomStart) / range;
|
|
170
159
|
previewHeight = ZOOM_SLIDER_ACTIVE_TRACK_SIZE;
|
|
171
|
-
startThumbX =
|
|
160
|
+
startThumbX = (zoomStart - minStart) / range * drawingArea.width;
|
|
172
161
|
startThumbY = 0;
|
|
173
|
-
endThumbX =
|
|
162
|
+
endThumbX = (zoomEnd - minStart) / range * drawingArea.width;
|
|
174
163
|
endThumbY = 0;
|
|
175
164
|
if (reverse) {
|
|
176
165
|
previewX = drawingArea.width - previewX - previewWidth;
|
|
@@ -181,13 +170,13 @@ export function ChartAxisZoomSliderActiveTrack({
|
|
|
181
170
|
endThumbX -= previewThumbWidth / 2;
|
|
182
171
|
} else {
|
|
183
172
|
previewX = 0;
|
|
184
|
-
previewY = drawingArea.height -
|
|
173
|
+
previewY = drawingArea.height - (zoomEnd - minStart) / range * drawingArea.height;
|
|
185
174
|
previewWidth = ZOOM_SLIDER_ACTIVE_TRACK_SIZE;
|
|
186
|
-
previewHeight = drawingArea.height * (
|
|
175
|
+
previewHeight = drawingArea.height * (zoomEnd - zoomStart) / range;
|
|
187
176
|
startThumbX = 0;
|
|
188
|
-
startThumbY = drawingArea.height -
|
|
177
|
+
startThumbY = drawingArea.height - (zoomStart - minStart) / range * drawingArea.height;
|
|
189
178
|
endThumbX = 0;
|
|
190
|
-
endThumbY = drawingArea.height -
|
|
179
|
+
endThumbY = drawingArea.height - (zoomEnd - minStart) / range * drawingArea.height;
|
|
191
180
|
if (reverse) {
|
|
192
181
|
previewY = drawingArea.height - previewY - previewHeight;
|
|
193
182
|
startThumbY = drawingArea.height - startThumbY;
|
|
@@ -55,17 +55,10 @@ export function ChartAxisZoomSliderTrack(_ref) {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
const pointerDownPoint = getSVGPoint(element, event);
|
|
58
|
-
|
|
58
|
+
const zoomFromPointerDown = calculateZoomFromPoint(store.getSnapshot(), axisId, pointerDownPoint);
|
|
59
59
|
if (zoomFromPointerDown === null) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
const {
|
|
63
|
-
minStart,
|
|
64
|
-
maxEnd
|
|
65
|
-
} = selectorChartAxisZoomOptionsLookup(store.getSnapshot(), axisId);
|
|
66
|
-
|
|
67
|
-
// Ensure the zoomFromPointerDown is within the min and max range
|
|
68
|
-
zoomFromPointerDown = Math.max(Math.min(zoomFromPointerDown, maxEnd), minStart);
|
|
69
62
|
const onPointerMove = rafThrottle(function onPointerMove(pointerMoveEvent) {
|
|
70
63
|
const pointerMovePoint = getSVGPoint(element, pointerMoveEvent);
|
|
71
64
|
const zoomFromPointerMove = calculateZoomFromPoint(store.getSnapshot(), axisId, pointerMovePoint);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { AxisId, ChartState, DefaultizedZoomOptions, ZoomData } from '@mui/x-charts/internals';
|
|
1
|
+
import { AxisId, ChartState, DefaultedXAxis, DefaultedYAxis, DefaultizedZoomOptions, ZoomData } from '@mui/x-charts/internals';
|
|
2
|
+
import { ChartDrawingArea } from '@mui/x-charts/hooks';
|
|
2
3
|
export declare function calculateZoomFromPoint(state: ChartState<any>, axisId: AxisId, point: DOMPoint): number | null;
|
|
4
|
+
export declare function calculateZoomFromPointImpl(drawingArea: ChartDrawingArea, axis: Pick<DefaultedXAxis | DefaultedYAxis, 'position' | 'reverse'>, zoomOptions: Pick<DefaultizedZoomOptions, 'minStart' | 'maxEnd'>, point: Pick<DOMPoint, 'x' | 'y'>): number;
|
|
3
5
|
export declare function calculateZoomStart(newStart: number, currentZoom: ZoomData, options: Pick<DefaultizedZoomOptions, 'minStart' | 'minSpan' | 'maxSpan'>): number;
|
|
4
6
|
export declare function calculateZoomEnd(newEnd: number, currentZoom: ZoomData, options: Pick<DefaultizedZoomOptions, 'maxEnd' | 'minSpan' | 'maxSpan'>): number;
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { selectorChartDrawingArea, selectorChartRawAxis } from '@mui/x-charts/internals';
|
|
1
|
+
import { selectorChartAxisZoomOptionsLookup, selectorChartDrawingArea, selectorChartRawAxis } from '@mui/x-charts/internals';
|
|
2
2
|
export function calculateZoomFromPoint(state, axisId, point) {
|
|
3
|
+
const axis = selectorChartRawAxis(state, axisId);
|
|
4
|
+
if (!axis) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return calculateZoomFromPointImpl(selectorChartDrawingArea(state), axis, selectorChartAxisZoomOptionsLookup(state, axisId), point);
|
|
8
|
+
}
|
|
9
|
+
export function calculateZoomFromPointImpl(drawingArea, axis, zoomOptions, point) {
|
|
3
10
|
const {
|
|
4
11
|
left,
|
|
5
12
|
top,
|
|
6
13
|
height,
|
|
7
14
|
width
|
|
8
|
-
} =
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
15
|
+
} = drawingArea;
|
|
16
|
+
const {
|
|
17
|
+
minStart,
|
|
18
|
+
maxEnd
|
|
19
|
+
} = zoomOptions;
|
|
13
20
|
const axisDirection = axis.position === 'right' || axis.position === 'left' ? 'y' : 'x';
|
|
21
|
+
const range = maxEnd - minStart;
|
|
14
22
|
let pointerZoom;
|
|
15
23
|
if (axisDirection === 'x') {
|
|
16
|
-
pointerZoom = (point.x - left) / width *
|
|
24
|
+
pointerZoom = (point.x - left) / width * range;
|
|
17
25
|
} else {
|
|
18
|
-
pointerZoom = (top + height - point.y) / height *
|
|
26
|
+
pointerZoom = (top + height - point.y) / height * range;
|
|
19
27
|
}
|
|
20
28
|
if (axis.reverse) {
|
|
21
|
-
pointerZoom =
|
|
29
|
+
pointerZoom = maxEnd - pointerZoom;
|
|
30
|
+
} else {
|
|
31
|
+
pointerZoom += minStart;
|
|
22
32
|
}
|
|
23
33
|
return pointerZoom;
|
|
24
34
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderProp } from '@mui/x-internals/useComponentRenderer';
|
|
3
|
+
import { ChartImageExportOptions } from "../internals/plugins/useChartProExport/index.js";
|
|
4
|
+
import { ChartsSlotPropsPro } from "../internals/material/index.js";
|
|
5
|
+
export interface ChartsToolbarImageExportOptions extends Omit<ChartImageExportOptions, 'type'>, Required<Pick<ChartImageExportOptions, 'type'>> {}
|
|
6
|
+
export type ChartsToolbarImageExportTriggerProps = ChartsSlotPropsPro['baseButton'] & {
|
|
7
|
+
/**
|
|
8
|
+
* A function to customize the rendering of the component.
|
|
9
|
+
*/
|
|
10
|
+
render?: RenderProp<ChartsSlotPropsPro['baseButton']>;
|
|
11
|
+
/**
|
|
12
|
+
* The options to apply on the image export.
|
|
13
|
+
* @demos
|
|
14
|
+
* - [Export as Image](https://mui.com/x/react-charts/export/#export-as-image)
|
|
15
|
+
*/
|
|
16
|
+
options?: ChartsToolbarImageExportOptions;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A button that triggers an image export.
|
|
20
|
+
* It renders the `baseButton` slot.
|
|
21
|
+
*
|
|
22
|
+
* Demos:
|
|
23
|
+
*
|
|
24
|
+
* - [Export](https://mui.com/x/react-charts/export/)
|
|
25
|
+
*/
|
|
26
|
+
declare const ChartsToolbarImageExportTrigger: React.ForwardRefExoticComponent<ChartsToolbarImageExportTriggerProps> | React.ForwardRefExoticComponent<Omit<ChartsToolbarImageExportTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
export { ChartsToolbarImageExportTrigger };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["render", "options", "onClick"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
7
|
+
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
|
|
8
|
+
import { useChartsSlots } from '@mui/x-charts/internals';
|
|
9
|
+
import { useChartApiContext } from "../context/index.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* A button that triggers an image export.
|
|
13
|
+
* It renders the `baseButton` slot.
|
|
14
|
+
*
|
|
15
|
+
* Demos:
|
|
16
|
+
*
|
|
17
|
+
* - [Export](https://mui.com/x/react-charts/export/)
|
|
18
|
+
*/
|
|
19
|
+
const ChartsToolbarImageExportTrigger = forwardRef(function ChartsToolbarImageExportTrigger(props, ref) {
|
|
20
|
+
const {
|
|
21
|
+
render,
|
|
22
|
+
options,
|
|
23
|
+
onClick
|
|
24
|
+
} = props,
|
|
25
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
26
|
+
const {
|
|
27
|
+
slots,
|
|
28
|
+
slotProps
|
|
29
|
+
} = useChartsSlots();
|
|
30
|
+
const apiRef = useChartApiContext();
|
|
31
|
+
const handleClick = event => {
|
|
32
|
+
apiRef.current.exportAsImage(options);
|
|
33
|
+
onClick?.(event);
|
|
34
|
+
};
|
|
35
|
+
const element = useComponentRenderer(slots.baseButton, render, _extends({}, slotProps?.baseButton, {
|
|
36
|
+
onClick: handleClick
|
|
37
|
+
}, other, {
|
|
38
|
+
ref
|
|
39
|
+
}));
|
|
40
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
41
|
+
children: element
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
if (process.env.NODE_ENV !== "production") ChartsToolbarImageExportTrigger.displayName = "ChartsToolbarImageExportTrigger";
|
|
45
|
+
process.env.NODE_ENV !== "production" ? ChartsToolbarImageExportTrigger.propTypes = {
|
|
46
|
+
// ----------------------------- Warning --------------------------------
|
|
47
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
49
|
+
// ----------------------------------------------------------------------
|
|
50
|
+
className: PropTypes.string,
|
|
51
|
+
disabled: PropTypes.bool,
|
|
52
|
+
id: PropTypes.string,
|
|
53
|
+
/**
|
|
54
|
+
* The options to apply on the image export.
|
|
55
|
+
* @demos
|
|
56
|
+
* - [Export as Image](https://mui.com/x/react-charts/export/#export-as-image)
|
|
57
|
+
*/
|
|
58
|
+
options: PropTypes.shape({
|
|
59
|
+
fileName: PropTypes.string,
|
|
60
|
+
quality: PropTypes.number,
|
|
61
|
+
type: PropTypes.string.isRequired
|
|
62
|
+
}),
|
|
63
|
+
/**
|
|
64
|
+
* A function to customize the rendering of the component.
|
|
65
|
+
*/
|
|
66
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
67
|
+
style: PropTypes.object,
|
|
68
|
+
tabIndex: PropTypes.number
|
|
69
|
+
} : void 0;
|
|
70
|
+
export { ChartsToolbarImageExportTrigger };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderProp } from '@mui/x-internals/useComponentRenderer';
|
|
3
|
+
import { ChartPrintExportOptions } from "../internals/plugins/useChartProExport/index.js";
|
|
4
|
+
import { ChartsSlotPropsPro } from "../internals/material/index.js";
|
|
5
|
+
export interface ChartsToolbarPrintExportOptions extends ChartPrintExportOptions {
|
|
6
|
+
/**
|
|
7
|
+
* If `true`, this export option will be removed from the ChartsToolbarExport menu.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
disableToolbarButton?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type ChartsToolbarPrintExportTriggerProps = ChartsSlotPropsPro['baseButton'] & {
|
|
13
|
+
/**
|
|
14
|
+
* A function to customize the rendering of the component.
|
|
15
|
+
*/
|
|
16
|
+
render?: RenderProp<ChartsSlotPropsPro['baseButton']>;
|
|
17
|
+
/**
|
|
18
|
+
* The options to apply on the Print export.
|
|
19
|
+
* @demos
|
|
20
|
+
* - [Print/Export as PDF](https://mui.com/x/react-charts/export/#print-export-as-pdf)
|
|
21
|
+
*/
|
|
22
|
+
options?: ChartPrintExportOptions;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A button that triggers a print export.
|
|
26
|
+
* It renders the `baseButton` slot.
|
|
27
|
+
*
|
|
28
|
+
* Demos:
|
|
29
|
+
*
|
|
30
|
+
* - [Export](https://mui.com/x/react-charts/export/)
|
|
31
|
+
*/
|
|
32
|
+
declare const ChartsToolbarPrintExportTrigger: React.ForwardRefExoticComponent<ChartsToolbarPrintExportTriggerProps> | React.ForwardRefExoticComponent<Omit<ChartsToolbarPrintExportTriggerProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
export { ChartsToolbarPrintExportTrigger };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["render", "options", "onClick"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
7
|
+
import { useComponentRenderer } from '@mui/x-internals/useComponentRenderer';
|
|
8
|
+
import { useChartsSlots } from '@mui/x-charts/internals';
|
|
9
|
+
import { useChartApiContext } from "../context/index.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* A button that triggers a print export.
|
|
13
|
+
* It renders the `baseButton` slot.
|
|
14
|
+
*
|
|
15
|
+
* Demos:
|
|
16
|
+
*
|
|
17
|
+
* - [Export](https://mui.com/x/react-charts/export/)
|
|
18
|
+
*/
|
|
19
|
+
const ChartsToolbarPrintExportTrigger = forwardRef(function ChartsToolbarPrintExportTrigger(props, ref) {
|
|
20
|
+
const {
|
|
21
|
+
render,
|
|
22
|
+
options,
|
|
23
|
+
onClick
|
|
24
|
+
} = props,
|
|
25
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
26
|
+
const {
|
|
27
|
+
slots,
|
|
28
|
+
slotProps
|
|
29
|
+
} = useChartsSlots();
|
|
30
|
+
const apiRef = useChartApiContext();
|
|
31
|
+
const handleClick = event => {
|
|
32
|
+
apiRef.current.exportAsPrint(options);
|
|
33
|
+
onClick?.(event);
|
|
34
|
+
};
|
|
35
|
+
const element = useComponentRenderer(slots.baseButton, render, _extends({}, slotProps?.baseButton, {
|
|
36
|
+
onClick: handleClick
|
|
37
|
+
}, other, {
|
|
38
|
+
ref
|
|
39
|
+
}));
|
|
40
|
+
return /*#__PURE__*/_jsx(React.Fragment, {
|
|
41
|
+
children: element
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
if (process.env.NODE_ENV !== "production") ChartsToolbarPrintExportTrigger.displayName = "ChartsToolbarPrintExportTrigger";
|
|
45
|
+
process.env.NODE_ENV !== "production" ? ChartsToolbarPrintExportTrigger.propTypes = {
|
|
46
|
+
// ----------------------------- Warning --------------------------------
|
|
47
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
49
|
+
// ----------------------------------------------------------------------
|
|
50
|
+
className: PropTypes.string,
|
|
51
|
+
disabled: PropTypes.bool,
|
|
52
|
+
id: PropTypes.string,
|
|
53
|
+
/**
|
|
54
|
+
* The options to apply on the Print export.
|
|
55
|
+
* @demos
|
|
56
|
+
* - [Print/Export as PDF](https://mui.com/x/react-charts/export/#print-export-as-pdf)
|
|
57
|
+
*/
|
|
58
|
+
options: PropTypes.shape({
|
|
59
|
+
fileName: PropTypes.string
|
|
60
|
+
}),
|
|
61
|
+
/**
|
|
62
|
+
* A function to customize the rendering of the component.
|
|
63
|
+
*/
|
|
64
|
+
render: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
65
|
+
style: PropTypes.object,
|
|
66
|
+
tabIndex: PropTypes.number
|
|
67
|
+
} : void 0;
|
|
68
|
+
export { ChartsToolbarPrintExportTrigger };
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import { ChartsToolbarProps } from '@mui/x-charts/Toolbar';
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
|
|
2
|
+
import { ChartsToolbarProps } from '@mui/x-charts/Toolbar';
|
|
3
|
+
import { ChartsToolbarPrintExportOptions } from "./ChartsToolbarPrintExportTrigger.js";
|
|
4
|
+
import { ChartsToolbarImageExportOptions } from "./ChartsToolbarImageExportTrigger.js";
|
|
5
|
+
export interface ChartsToolbarProProps extends ChartsToolbarProps {
|
|
6
|
+
printOptions?: ChartsToolbarPrintExportOptions;
|
|
7
|
+
imageExportOptions?: ChartsToolbarImageExportOptions[];
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* The chart toolbar component for the pro package.
|
|
6
11
|
*/
|
|
7
|
-
|
|
12
|
+
declare function ChartsToolbarPro({
|
|
13
|
+
printOptions,
|
|
14
|
+
imageExportOptions: rawImageExportOptions,
|
|
15
|
+
...other
|
|
16
|
+
}: ChartsToolbarProProps): React.JSX.Element | null;
|
|
17
|
+
declare namespace ChartsToolbarPro {
|
|
18
|
+
var propTypes: any;
|
|
19
|
+
}
|
|
20
|
+
export { ChartsToolbarPro };
|