@mui/x-charts 9.0.0-alpha.4 → 9.0.0-beta.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/BarChart/BarChart.js +19 -28
- package/BarChart/BarChart.mjs +19 -28
- package/BarChart/BarElement.js +3 -5
- package/BarChart/BarElement.mjs +3 -5
- package/BarChart/BarLabel/BarLabelPlot.d.mts +0 -2
- package/BarChart/BarLabel/BarLabelPlot.d.ts +0 -2
- package/BarChart/BarLabel/BarLabelPlot.js +2 -3
- package/BarChart/BarLabel/BarLabelPlot.mjs +2 -3
- package/BarChart/BarPlot.d.mts +2 -12
- package/BarChart/BarPlot.d.ts +2 -12
- package/BarChart/BarPlot.js +4 -18
- package/BarChart/BarPlot.mjs +4 -18
- package/BarChart/BatchBarPlot/BatchBarPlot.js +0 -27
- package/BarChart/BatchBarPlot/BatchBarPlot.mjs +0 -27
- package/BarChart/IndividualBarPlot.d.mts +1 -2
- package/BarChart/IndividualBarPlot.d.ts +1 -2
- package/BarChart/IndividualBarPlot.js +5 -10
- package/BarChart/IndividualBarPlot.mjs +5 -10
- package/BarChart/seriesConfig/bar/descriptionGetter.d.mts +3 -0
- package/BarChart/seriesConfig/bar/descriptionGetter.d.ts +3 -0
- package/BarChart/seriesConfig/bar/descriptionGetter.js +36 -0
- package/BarChart/seriesConfig/bar/descriptionGetter.mjs +30 -0
- package/BarChart/seriesConfig/index.js +5 -1
- package/BarChart/seriesConfig/index.mjs +5 -1
- package/BarChart/useBarChartProps.js +2 -4
- package/BarChart/useBarChartProps.mjs +2 -4
- package/CHANGELOG.md +107 -1
- package/ChartsContainer/ChartsContainer.js +29 -29
- package/ChartsContainer/ChartsContainer.mjs +29 -29
- package/ChartsLayerContainer/ChartsLayerContainer.js +6 -2
- package/ChartsLayerContainer/ChartsLayerContainer.mjs +7 -2
- package/ChartsSvgLayer/ChartsSvgLayer.js +2 -2
- package/ChartsSvgLayer/ChartsSvgLayer.mjs +2 -2
- package/ChartsXAxis/ChartsGroupedXAxisTicks.js +12 -3
- package/ChartsXAxis/ChartsGroupedXAxisTicks.mjs +12 -3
- package/ChartsXAxis/useAxisTicksProps.d.mts +89 -89
- package/ChartsXAxis/useAxisTicksProps.d.ts +89 -89
- package/ChartsYAxis/ChartsGroupedYAxisTicks.js +12 -3
- package/ChartsYAxis/ChartsGroupedYAxisTicks.mjs +12 -3
- package/ChartsYAxis/useAxisTicksProps.d.mts +89 -89
- package/ChartsYAxis/useAxisTicksProps.d.ts +89 -89
- package/Gauge/Gauge.js +0 -4
- package/Gauge/Gauge.mjs +0 -4
- package/Gauge/GaugeContainer.d.mts +1 -1
- package/Gauge/GaugeContainer.d.ts +1 -1
- package/Gauge/GaugeContainer.js +0 -4
- package/Gauge/GaugeContainer.mjs +0 -4
- package/LineChart/AreaElement.js +5 -1
- package/LineChart/AreaElement.mjs +5 -1
- package/LineChart/CircleMarkElement.js +8 -5
- package/LineChart/CircleMarkElement.mjs +8 -5
- package/LineChart/LineChart.js +21 -19
- package/LineChart/LineChart.mjs +21 -19
- package/LineChart/LineElement.js +5 -1
- package/LineChart/LineElement.mjs +5 -1
- package/LineChart/MarkElement.js +7 -4
- package/LineChart/MarkElement.mjs +7 -4
- package/LineChart/seriesConfig/curveEvaluation.d.mts +11 -0
- package/LineChart/seriesConfig/curveEvaluation.d.ts +11 -0
- package/LineChart/seriesConfig/curveEvaluation.js +134 -0
- package/LineChart/seriesConfig/curveEvaluation.mjs +129 -0
- package/LineChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/LineChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/LineChart/seriesConfig/descriptionGetter.js +37 -0
- package/LineChart/seriesConfig/descriptionGetter.mjs +31 -0
- package/LineChart/seriesConfig/getItemAtPosition.d.mts +7 -0
- package/LineChart/seriesConfig/getItemAtPosition.d.ts +7 -0
- package/LineChart/seriesConfig/getItemAtPosition.js +356 -0
- package/LineChart/seriesConfig/getItemAtPosition.mjs +351 -0
- package/LineChart/seriesConfig/index.js +4 -0
- package/LineChart/seriesConfig/index.mjs +4 -0
- package/PieChart/PieArc.js +2 -3
- package/PieChart/PieArc.mjs +2 -3
- package/PieChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/PieChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/PieChart/seriesConfig/descriptionGetter.js +26 -0
- package/PieChart/seriesConfig/descriptionGetter.mjs +20 -0
- package/PieChart/seriesConfig/index.js +2 -0
- package/PieChart/seriesConfig/index.mjs +2 -0
- package/RadarChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/RadarChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/RadarChart/seriesConfig/descriptionGetter.js +37 -0
- package/RadarChart/seriesConfig/descriptionGetter.mjs +31 -0
- package/RadarChart/seriesConfig/index.js +2 -0
- package/RadarChart/seriesConfig/index.mjs +2 -0
- package/ScatterChart/ScatterChart.js +18 -18
- package/ScatterChart/ScatterChart.mjs +18 -18
- package/ScatterChart/seriesConfig/descriptionGetter.d.mts +3 -0
- package/ScatterChart/seriesConfig/descriptionGetter.d.ts +3 -0
- package/ScatterChart/seriesConfig/descriptionGetter.js +34 -0
- package/ScatterChart/seriesConfig/descriptionGetter.mjs +28 -0
- package/ScatterChart/seriesConfig/index.js +2 -0
- package/ScatterChart/seriesConfig/index.mjs +2 -0
- package/SparkLineChart/SparkLineChart.js +21 -19
- package/SparkLineChart/SparkLineChart.mjs +21 -19
- package/constants/index.js +0 -2
- package/constants/index.mjs +0 -2
- package/hooks/useInteractionItemProps.d.mts +1 -1
- package/hooks/useInteractionItemProps.d.ts +1 -1
- package/hooks/useInteractionItemProps.js +3 -3
- package/hooks/useInteractionItemProps.mjs +3 -3
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.d.mts +5 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.d.ts +5 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.js +100 -0
- package/internals/components/ChartsAccessibilityProxy/ChartsAccessibilityProxy.mjs +96 -0
- package/internals/components/ChartsAccessibilityProxy/index.d.mts +1 -0
- package/internals/components/ChartsAccessibilityProxy/index.d.ts +1 -0
- package/internals/components/ChartsAccessibilityProxy/index.js +16 -0
- package/internals/components/ChartsAccessibilityProxy/index.mjs +1 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.d.mts +5 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.d.ts +5 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.js +71 -0
- package/internals/components/ChartsAccessibilityProxy/useDescription.mjs +66 -0
- package/internals/getChartPoint.js +18 -1
- package/internals/getChartPoint.mjs +18 -1
- package/internals/plugins/corePlugins/corePlugins.d.mts +2 -2
- package/internals/plugins/corePlugins/corePlugins.d.ts +2 -2
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.mts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.mts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +2 -1
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.mts +22 -7
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +22 -7
- package/internals/plugins/corePlugins/useChartSeries/index.d.mts +2 -1
- package/internals/plugins/corePlugins/useChartSeries/index.d.ts +2 -1
- package/internals/plugins/corePlugins/useChartSeries/index.js +12 -0
- package/internals/plugins/corePlugins/useChartSeries/index.mjs +2 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +1 -8
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -8
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +1 -11
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.mjs +1 -11
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.d.mts +8 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.d.ts +8 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.js +19 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeriesLayout.selectors.mjs +14 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.d.mts +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.d.ts +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.js +5 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/descriptionGetter.types.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.mts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.js +11 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.mjs +1 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.mts +2 -0
- package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.ts +2 -0
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.mts +4 -10
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +4 -10
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +28 -19
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.mjs +28 -18
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.d.mts +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.js +11 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/autoSizeConstants.mjs +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.mts +33 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.d.ts +33 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.js +318 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisAutoSize.mjs +311 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.mts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +63 -8
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.mjs +62 -8
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +12 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.mjs +12 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.mts +12 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.d.ts +12 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.js +28 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/domain.mjs +27 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.mts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +22 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.d.mts +30 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.d.ts +30 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.js +96 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisAutoSize.selectors.mjs +91 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.d.mts +16 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.d.ts +16 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.js +36 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisDomains.selectors.mjs +31 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.d.mts +15 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.d.ts +15 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.js +45 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisExtrema.selectors.mjs +39 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.mts +11 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +11 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +53 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.mjs +52 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +4 -9
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +4 -9
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +16 -40
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.mjs +19 -43
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianTooltip.selectors.js +20 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianTooltip.selectors.mjs +20 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +36 -30
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +36 -30
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +8 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +8 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +9 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +6 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -0
- package/internals/store/useCharts.d.mts +1 -1
- package/internals/store/useCharts.d.ts +1 -1
- package/locales/elGR.d.mts +76 -0
- package/locales/elGR.d.ts +76 -0
- package/locales/elGR.js +89 -0
- package/locales/elGR.mjs +89 -0
- package/locales/enUS.d.mts +76 -0
- package/locales/enUS.d.ts +76 -0
- package/locales/enUS.js +89 -1
- package/locales/enUS.mjs +89 -1
- package/locales/frFR.d.mts +76 -0
- package/locales/frFR.d.ts +76 -0
- package/locales/frFR.js +89 -0
- package/locales/frFR.mjs +89 -0
- package/locales/nbNO.d.mts +76 -0
- package/locales/nbNO.d.ts +76 -0
- package/locales/nbNO.js +89 -0
- package/locales/nbNO.mjs +89 -0
- package/locales/ptBR.d.mts +76 -0
- package/locales/ptBR.d.ts +76 -0
- package/locales/ptBR.js +89 -0
- package/locales/ptBR.mjs +89 -0
- package/locales/ptPT.d.mts +76 -0
- package/locales/ptPT.d.ts +76 -0
- package/locales/ptPT.js +89 -0
- package/locales/ptPT.mjs +89 -0
- package/locales/svSE.d.mts +76 -0
- package/locales/svSE.d.ts +76 -0
- package/locales/svSE.js +89 -0
- package/locales/svSE.mjs +89 -0
- package/locales/utils/chartsLocaleTextApi.d.mts +189 -0
- package/locales/utils/chartsLocaleTextApi.d.ts +189 -0
- package/locales/utils/getChartsLocalization.d.mts +76 -0
- package/locales/utils/getChartsLocalization.d.ts +76 -0
- package/models/axis.d.mts +11 -5
- package/models/axis.d.ts +11 -5
- package/models/seriesType/config.d.mts +29 -0
- package/models/seriesType/config.d.ts +29 -0
- package/package.json +85 -85
|
@@ -8,8 +8,10 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from '@mui/x-charts-vendor/d3-shape';
|
|
10
10
|
import { ANIMATION_DURATION_MS, ANIMATION_TIMING_FUNCTION } from "../internals/animation/animation.mjs";
|
|
11
|
-
import { getSymbol } from "../internals/getSymbol.mjs";
|
|
12
11
|
import { useInteractionItemProps } from "../hooks/useInteractionItemProps.mjs";
|
|
12
|
+
import { selectorChartExperimentalFeaturesState } from "../internals/plugins/corePlugins/useChartExperimentalFeature/index.mjs";
|
|
13
|
+
import { useStore } from "../internals/store/useStore.mjs";
|
|
14
|
+
import { getSymbol } from "../internals/getSymbol.mjs";
|
|
13
15
|
import { lineClasses, useUtilityClasses as useLineUtilityClasses } from "./lineClasses.mjs";
|
|
14
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
17
|
const MarkElementPath = styled('path', {
|
|
@@ -52,6 +54,8 @@ function MarkElement(props) {
|
|
|
52
54
|
style
|
|
53
55
|
} = props,
|
|
54
56
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
57
|
+
const store = useStore();
|
|
58
|
+
const enablePositionBasedPointerInteraction = store.use(selectorChartExperimentalFeaturesState)?.enablePositionBasedPointerInteraction;
|
|
55
59
|
const interactionProps = useInteractionItemProps({
|
|
56
60
|
type: 'line',
|
|
57
61
|
seriesId,
|
|
@@ -68,7 +72,7 @@ function MarkElement(props) {
|
|
|
68
72
|
skipAnimation,
|
|
69
73
|
classes: innerClasses
|
|
70
74
|
});
|
|
71
|
-
return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, {
|
|
75
|
+
return /*#__PURE__*/_jsx(MarkElementPath, _extends({}, other, enablePositionBasedPointerInteraction ? {} : interactionProps, {
|
|
72
76
|
style: _extends({}, style, {
|
|
73
77
|
transform: `translate(${x}px, ${y}px)`,
|
|
74
78
|
transformOrigin: `${x}px ${y}px`
|
|
@@ -78,8 +82,7 @@ function MarkElement(props) {
|
|
|
78
82
|
d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
|
|
79
83
|
onClick: onClick,
|
|
80
84
|
cursor: onClick ? 'pointer' : 'unset',
|
|
81
|
-
pointerEvents: hidden ? 'none' : undefined
|
|
82
|
-
}, interactionProps, {
|
|
85
|
+
pointerEvents: hidden ? 'none' : undefined,
|
|
83
86
|
"data-highlighted": isHighlighted || undefined,
|
|
84
87
|
"data-faded": isFaded || undefined,
|
|
85
88
|
"data-series-id": seriesId,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CurveType } from "../../models/curve.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Build the curve segments for a set of pixel-coordinate points
|
|
4
|
+
* using d3's curve factory, then evaluate y at the given pixel x.
|
|
5
|
+
*
|
|
6
|
+
* Returns null if targetX is outside the curve's x range.
|
|
7
|
+
*/
|
|
8
|
+
export declare function evaluateCurveY(points: Array<{
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}>, targetX: number, curveType?: CurveType): number | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CurveType } from "../../models/curve.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build the curve segments for a set of pixel-coordinate points
|
|
4
|
+
* using d3's curve factory, then evaluate y at the given pixel x.
|
|
5
|
+
*
|
|
6
|
+
* Returns null if targetX is outside the curve's x range.
|
|
7
|
+
*/
|
|
8
|
+
export declare function evaluateCurveY(points: Array<{
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}>, targetX: number, curveType?: CurveType): number | null;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.evaluateCurveY = evaluateCurveY;
|
|
7
|
+
var _getCurve = require("../../internals/getCurve");
|
|
8
|
+
/**
|
|
9
|
+
* A straight line segment.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A cubic bezier segment with control points.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function isBezierSegment(segment) {
|
|
17
|
+
return 'cpx1' in segment;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A minimal d3 path context that captures line/bezier segments
|
|
22
|
+
* instead of producing an SVG path string.
|
|
23
|
+
*/
|
|
24
|
+
class SegmentCapture {
|
|
25
|
+
segments = [];
|
|
26
|
+
cx = 0;
|
|
27
|
+
cy = 0;
|
|
28
|
+
moveTo(x, y) {
|
|
29
|
+
this.cx = x;
|
|
30
|
+
this.cy = y;
|
|
31
|
+
}
|
|
32
|
+
lineTo(x, y) {
|
|
33
|
+
this.segments.push({
|
|
34
|
+
x0: this.cx,
|
|
35
|
+
y0: this.cy,
|
|
36
|
+
x1: x,
|
|
37
|
+
y1: y
|
|
38
|
+
});
|
|
39
|
+
this.cx = x;
|
|
40
|
+
this.cy = y;
|
|
41
|
+
}
|
|
42
|
+
bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y) {
|
|
43
|
+
this.segments.push({
|
|
44
|
+
x0: this.cx,
|
|
45
|
+
y0: this.cy,
|
|
46
|
+
cpx1,
|
|
47
|
+
cpy1,
|
|
48
|
+
cpx2,
|
|
49
|
+
cpy2,
|
|
50
|
+
x1: x,
|
|
51
|
+
y1: y
|
|
52
|
+
});
|
|
53
|
+
this.cx = x;
|
|
54
|
+
this.cy = y;
|
|
55
|
+
}
|
|
56
|
+
closePath() {}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Evaluate a cubic Bezier at parameter t. */
|
|
60
|
+
function cubicBezier(t, p0, p1, p2, p3) {
|
|
61
|
+
const mt = 1 - t;
|
|
62
|
+
return mt * mt * mt * p0 + 3 * mt * mt * t * p1 + 3 * mt * t * t * p2 + t * t * t * p3;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Find parameter t such that the segment's x(t) ≈ targetX using bisection.
|
|
67
|
+
* 20 iterations gives ~1e-6 precision relative to the segment's x range.
|
|
68
|
+
*/
|
|
69
|
+
function findTForX(segment, targetX) {
|
|
70
|
+
if (!isBezierSegment(segment)) {
|
|
71
|
+
// Linear segment.
|
|
72
|
+
const dx = segment.x1 - segment.x0;
|
|
73
|
+
return dx === 0 ? 0 : (targetX - segment.x0) / dx;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Cubic bezier — bisect.
|
|
77
|
+
let lo = 0;
|
|
78
|
+
let hi = 1;
|
|
79
|
+
for (let iter = 0; iter < 20; iter += 1) {
|
|
80
|
+
const mid = (lo + hi) / 2;
|
|
81
|
+
const x = cubicBezier(mid, segment.x0, segment.cpx1, segment.cpx2, segment.x1);
|
|
82
|
+
if (x < targetX) {
|
|
83
|
+
lo = mid;
|
|
84
|
+
} else {
|
|
85
|
+
hi = mid;
|
|
86
|
+
}
|
|
87
|
+
if (Math.abs(x - targetX) < 1) {
|
|
88
|
+
return (lo + hi) / 2;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return (lo + hi) / 2;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Evaluate the segment's y at parameter t. */
|
|
95
|
+
function evaluateSegmentY(segment, t) {
|
|
96
|
+
if (!isBezierSegment(segment)) {
|
|
97
|
+
return segment.y0 + t * (segment.y1 - segment.y0);
|
|
98
|
+
}
|
|
99
|
+
return cubicBezier(t, segment.y0, segment.cpy1, segment.cpy2, segment.y1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Build the curve segments for a set of pixel-coordinate points
|
|
104
|
+
* using d3's curve factory, then evaluate y at the given pixel x.
|
|
105
|
+
*
|
|
106
|
+
* Returns null if targetX is outside the curve's x range.
|
|
107
|
+
*/
|
|
108
|
+
function evaluateCurveY(points, targetX, curveType) {
|
|
109
|
+
if (points.length === 0) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (points.length === 1) {
|
|
113
|
+
return points[0].y;
|
|
114
|
+
}
|
|
115
|
+
const capture = new SegmentCapture();
|
|
116
|
+
const factory = (0, _getCurve.getCurveFactory)(curveType);
|
|
117
|
+
const curveInstance = factory(capture);
|
|
118
|
+
curveInstance.lineStart();
|
|
119
|
+
for (const p of points) {
|
|
120
|
+
curveInstance.point(p.x, p.y);
|
|
121
|
+
}
|
|
122
|
+
curveInstance.lineEnd();
|
|
123
|
+
|
|
124
|
+
// Find the segment containing targetX.
|
|
125
|
+
for (const segment of capture.segments) {
|
|
126
|
+
const xMin = Math.min(segment.x0, segment.x1);
|
|
127
|
+
const xMax = Math.max(segment.x0, segment.x1);
|
|
128
|
+
if (targetX >= xMin - 0.5 && targetX <= xMax + 0.5) {
|
|
129
|
+
const t = findTForX(segment, targetX);
|
|
130
|
+
return evaluateSegmentY(segment, t);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { getCurveFactory } from "../../internals/getCurve.mjs";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A straight line segment.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A cubic bezier segment with control points.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
function isBezierSegment(segment) {
|
|
12
|
+
return 'cpx1' in segment;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A minimal d3 path context that captures line/bezier segments
|
|
17
|
+
* instead of producing an SVG path string.
|
|
18
|
+
*/
|
|
19
|
+
class SegmentCapture {
|
|
20
|
+
segments = [];
|
|
21
|
+
cx = 0;
|
|
22
|
+
cy = 0;
|
|
23
|
+
moveTo(x, y) {
|
|
24
|
+
this.cx = x;
|
|
25
|
+
this.cy = y;
|
|
26
|
+
}
|
|
27
|
+
lineTo(x, y) {
|
|
28
|
+
this.segments.push({
|
|
29
|
+
x0: this.cx,
|
|
30
|
+
y0: this.cy,
|
|
31
|
+
x1: x,
|
|
32
|
+
y1: y
|
|
33
|
+
});
|
|
34
|
+
this.cx = x;
|
|
35
|
+
this.cy = y;
|
|
36
|
+
}
|
|
37
|
+
bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y) {
|
|
38
|
+
this.segments.push({
|
|
39
|
+
x0: this.cx,
|
|
40
|
+
y0: this.cy,
|
|
41
|
+
cpx1,
|
|
42
|
+
cpy1,
|
|
43
|
+
cpx2,
|
|
44
|
+
cpy2,
|
|
45
|
+
x1: x,
|
|
46
|
+
y1: y
|
|
47
|
+
});
|
|
48
|
+
this.cx = x;
|
|
49
|
+
this.cy = y;
|
|
50
|
+
}
|
|
51
|
+
closePath() {}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Evaluate a cubic Bezier at parameter t. */
|
|
55
|
+
function cubicBezier(t, p0, p1, p2, p3) {
|
|
56
|
+
const mt = 1 - t;
|
|
57
|
+
return mt * mt * mt * p0 + 3 * mt * mt * t * p1 + 3 * mt * t * t * p2 + t * t * t * p3;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Find parameter t such that the segment's x(t) ≈ targetX using bisection.
|
|
62
|
+
* 20 iterations gives ~1e-6 precision relative to the segment's x range.
|
|
63
|
+
*/
|
|
64
|
+
function findTForX(segment, targetX) {
|
|
65
|
+
if (!isBezierSegment(segment)) {
|
|
66
|
+
// Linear segment.
|
|
67
|
+
const dx = segment.x1 - segment.x0;
|
|
68
|
+
return dx === 0 ? 0 : (targetX - segment.x0) / dx;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Cubic bezier — bisect.
|
|
72
|
+
let lo = 0;
|
|
73
|
+
let hi = 1;
|
|
74
|
+
for (let iter = 0; iter < 20; iter += 1) {
|
|
75
|
+
const mid = (lo + hi) / 2;
|
|
76
|
+
const x = cubicBezier(mid, segment.x0, segment.cpx1, segment.cpx2, segment.x1);
|
|
77
|
+
if (x < targetX) {
|
|
78
|
+
lo = mid;
|
|
79
|
+
} else {
|
|
80
|
+
hi = mid;
|
|
81
|
+
}
|
|
82
|
+
if (Math.abs(x - targetX) < 1) {
|
|
83
|
+
return (lo + hi) / 2;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return (lo + hi) / 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Evaluate the segment's y at parameter t. */
|
|
90
|
+
function evaluateSegmentY(segment, t) {
|
|
91
|
+
if (!isBezierSegment(segment)) {
|
|
92
|
+
return segment.y0 + t * (segment.y1 - segment.y0);
|
|
93
|
+
}
|
|
94
|
+
return cubicBezier(t, segment.y0, segment.cpy1, segment.cpy2, segment.y1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Build the curve segments for a set of pixel-coordinate points
|
|
99
|
+
* using d3's curve factory, then evaluate y at the given pixel x.
|
|
100
|
+
*
|
|
101
|
+
* Returns null if targetX is outside the curve's x range.
|
|
102
|
+
*/
|
|
103
|
+
export function evaluateCurveY(points, targetX, curveType) {
|
|
104
|
+
if (points.length === 0) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
if (points.length === 1) {
|
|
108
|
+
return points[0].y;
|
|
109
|
+
}
|
|
110
|
+
const capture = new SegmentCapture();
|
|
111
|
+
const factory = getCurveFactory(curveType);
|
|
112
|
+
const curveInstance = factory(capture);
|
|
113
|
+
curveInstance.lineStart();
|
|
114
|
+
for (const p of points) {
|
|
115
|
+
curveInstance.point(p.x, p.y);
|
|
116
|
+
}
|
|
117
|
+
curveInstance.lineEnd();
|
|
118
|
+
|
|
119
|
+
// Find the segment containing targetX.
|
|
120
|
+
for (const segment of capture.segments) {
|
|
121
|
+
const xMin = Math.min(segment.x0, segment.x1);
|
|
122
|
+
const xMax = Math.max(segment.x0, segment.x1);
|
|
123
|
+
if (targetX >= xMin - 0.5 && targetX <= xMax + 0.5) {
|
|
124
|
+
const t = findTForX(segment, targetX);
|
|
125
|
+
return evaluateSegmentY(segment, t);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _getLabel = require("../../internals/getLabel");
|
|
8
|
+
const descriptionGetter = params => {
|
|
9
|
+
const {
|
|
10
|
+
identifier,
|
|
11
|
+
series,
|
|
12
|
+
xAxis,
|
|
13
|
+
localeText
|
|
14
|
+
} = params;
|
|
15
|
+
const label = (0, _getLabel.getLabel)(series.label, 'tooltip');
|
|
16
|
+
const dataIndex = identifier.dataIndex;
|
|
17
|
+
if (dataIndex === undefined) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
const xValue = xAxis.data?.[dataIndex] ?? null;
|
|
21
|
+
const yValue = series.data[dataIndex] ?? null;
|
|
22
|
+
const formattedXValue = xAxis.valueFormatter?.(xValue, {
|
|
23
|
+
location: 'tooltip',
|
|
24
|
+
scale: xAxis.scale
|
|
25
|
+
});
|
|
26
|
+
const formattedYValue = series.valueFormatter(yValue, {
|
|
27
|
+
dataIndex
|
|
28
|
+
});
|
|
29
|
+
return localeText.lineDescription({
|
|
30
|
+
x: xValue,
|
|
31
|
+
y: yValue,
|
|
32
|
+
formattedXValue: formattedXValue ?? '',
|
|
33
|
+
formattedYValue: formattedYValue ?? '',
|
|
34
|
+
seriesLabel: label
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var _default = exports.default = descriptionGetter;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getLabel } from "../../internals/getLabel.mjs";
|
|
2
|
+
const descriptionGetter = params => {
|
|
3
|
+
const {
|
|
4
|
+
identifier,
|
|
5
|
+
series,
|
|
6
|
+
xAxis,
|
|
7
|
+
localeText
|
|
8
|
+
} = params;
|
|
9
|
+
const label = getLabel(series.label, 'tooltip');
|
|
10
|
+
const dataIndex = identifier.dataIndex;
|
|
11
|
+
if (dataIndex === undefined) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
const xValue = xAxis.data?.[dataIndex] ?? null;
|
|
15
|
+
const yValue = series.data[dataIndex] ?? null;
|
|
16
|
+
const formattedXValue = xAxis.valueFormatter?.(xValue, {
|
|
17
|
+
location: 'tooltip',
|
|
18
|
+
scale: xAxis.scale
|
|
19
|
+
});
|
|
20
|
+
const formattedYValue = series.valueFormatter(yValue, {
|
|
21
|
+
dataIndex
|
|
22
|
+
});
|
|
23
|
+
return localeText.lineDescription({
|
|
24
|
+
x: xValue,
|
|
25
|
+
y: yValue,
|
|
26
|
+
formattedXValue: formattedXValue ?? '',
|
|
27
|
+
formattedYValue: formattedYValue ?? '',
|
|
28
|
+
seriesLabel: label
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export default descriptionGetter;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UseChartCartesianAxisSignature } from "../../internals/plugins/featurePlugins/useChartCartesianAxis/index.mjs";
|
|
2
|
+
import type { ChartState } from "../../internals/plugins/models/chart.mjs";
|
|
3
|
+
import type { SeriesItemIdentifierWithType } from "../../models/seriesType/index.mjs";
|
|
4
|
+
export default function getItemAtPosition(state: ChartState<[UseChartCartesianAxisSignature]>, point: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}): SeriesItemIdentifierWithType<'line'> | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UseChartCartesianAxisSignature } from "../../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
2
|
+
import type { ChartState } from "../../internals/plugins/models/chart.js";
|
|
3
|
+
import type { SeriesItemIdentifierWithType } from "../../models/seriesType/index.js";
|
|
4
|
+
export default function getItemAtPosition(state: ChartState<[UseChartCartesianAxisSignature]>, point: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}): SeriesItemIdentifierWithType<'line'> | undefined;
|