@mui/x-charts 8.0.0-alpha.5 → 8.0.0-alpha.7
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/AnimatedBarElement.js +1 -0
- package/BarChart/BarChart.js +17 -7
- package/BarChart/BarLabel/BarLabel.d.ts +1 -479
- package/BarChart/BarLabel/barLabelClasses.d.ts +1 -1
- package/BarChart/legend.js +1 -0
- package/BarChart/useBarChartProps.d.ts +4 -2
- package/BarChart/useBarChartProps.js +16 -3
- package/CHANGELOG.md +206 -1
- package/ChartsLabel/ChartsLabel.d.ts +2 -3
- package/ChartsLabel/ChartsLabel.js +3 -18
- package/ChartsLabel/ChartsLabelGradient.d.ts +9 -8
- package/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -3
- package/ChartsLabel/ChartsLabelMark.js +5 -2
- package/ChartsLabel/index.d.ts +7 -0
- package/ChartsLabel/index.js +6 -0
- package/ChartsLabel/labelClasses.d.ts +0 -1
- package/ChartsLabel/labelGradientClasses.d.ts +5 -4
- package/ChartsLabel/labelGradientClasses.js +3 -2
- package/ChartsLabel/labelMarkClasses.d.ts +3 -2
- package/ChartsLabel/labelMarkClasses.js +3 -2
- package/ChartsLabel/package.json +6 -0
- package/ChartsLegend/ChartsLegend.d.ts +18 -22
- package/ChartsLegend/ChartsLegend.js +100 -109
- package/ChartsLegend/ContinuousColorLegend.d.ts +29 -38
- package/ChartsLegend/ContinuousColorLegend.js +198 -321
- package/ChartsLegend/PiecewiseColorLegend.d.ts +27 -19
- package/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/ChartsLegend/chartsLegend.types.d.ts +17 -60
- package/ChartsLegend/chartsLegendClasses.d.ts +7 -8
- package/ChartsLegend/chartsLegendClasses.js +16 -2
- package/ChartsLegend/colorLegend.types.d.ts +13 -0
- package/ChartsLegend/colorLegend.types.js +1 -0
- package/ChartsLegend/continuousColorLegendClasses.d.ts +26 -0
- package/ChartsLegend/continuousColorLegendClasses.js +23 -0
- package/ChartsLegend/direction.d.ts +1 -0
- package/ChartsLegend/direction.js +1 -0
- package/ChartsLegend/index.d.ts +13 -3
- package/ChartsLegend/index.js +9 -3
- package/ChartsLegend/legend.types.d.ts +10 -54
- package/ChartsLegend/legendContext.types.d.ts +55 -0
- package/ChartsLegend/legendContext.types.js +1 -0
- package/ChartsLegend/onClickContextBuilder.d.ts +2 -0
- package/ChartsLegend/onClickContextBuilder.js +7 -0
- package/ChartsLegend/piecewiseColorDefaultLabelFormatter.d.ts +2 -0
- package/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
- package/ChartsLegend/piecewiseColorLegend.types.d.ts +26 -0
- package/ChartsLegend/piecewiseColorLegend.types.js +1 -0
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +28 -0
- package/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
- package/ChartsLegend/useAxis.d.ts +1 -1
- package/ChartsLegend/useAxis.js +0 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +1 -1
- package/ChartsSurface/ChartsSurface.js +0 -1
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -1
- package/LineChart/AnimatedArea.js +1 -0
- package/LineChart/AnimatedLine.js +1 -0
- package/LineChart/AppearingMask.js +1 -0
- package/LineChart/CircleMarkElement.js +1 -0
- package/LineChart/LineChart.js +20 -10
- package/LineChart/MarkElement.js +3 -1
- package/LineChart/legend.js +1 -0
- package/LineChart/useLineChartProps.d.ts +4 -2
- package/LineChart/useLineChartProps.js +15 -2
- package/PieChart/PieArc.js +3 -1
- package/PieChart/PieArcLabel.js +13 -9
- package/PieChart/PieArcLabelPlot.js +1 -0
- package/PieChart/PieArcPlot.js +1 -0
- package/PieChart/PieChart.js +42 -41
- package/PieChart/legend.js +1 -0
- package/ScatterChart/ScatterChart.js +21 -11
- package/ScatterChart/legend.js +1 -0
- package/ScatterChart/useScatterChartProps.d.ts +4 -2
- package/ScatterChart/useScatterChartProps.js +15 -2
- package/SparkLineChart/SparkLineChart.js +1 -4
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/context/CartesianProvider/defaultizeAxis.d.ts +9 -9
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +18 -18
- package/context/ChartDataProvider/useDefaultizeAxis.d.ts +9 -9
- package/context/ChartProvider/ChartProvider.types.d.ts +1 -1
- package/context/InteractionSelectors.d.ts +11 -11
- package/context/PluginProvider/SeriesFormatter.types.d.ts +1 -1
- package/context/PluginProvider/mergePlugins.d.ts +8 -8
- package/context/SizeProvider/Size.types.d.ts +1 -1
- package/context/SizeProvider/useChartContainerDimensions.d.ts +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +2 -1
- package/hooks/useLegend.d.ts +13 -0
- package/{modern/ChartsLegend/utils.js → hooks/useLegend.js} +20 -1
- package/hooks/useSvgRef.d.ts +1 -1
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/internals/calculateMargins.d.ts +7 -0
- package/internals/calculateMargins.js +25 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +2 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.d.ts +17 -0
- package/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
- package/internals/components/ChartsWrapper/index.d.ts +1 -0
- package/internals/components/ChartsWrapper/index.js +1 -0
- package/internals/consumeSlots.d.ts +48 -0
- package/internals/consumeSlots.js +101 -0
- package/internals/consumeThemeProps.d.ts +3 -7
- package/internals/consumeThemeProps.js +18 -27
- package/internals/defaultizeColor.d.ts +6 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
- package/internals/plugins/models/plugin.d.ts +1 -1
- package/internals/store/useCharts.d.ts +2 -2
- package/internals/store/useCharts.types.d.ts +1 -1
- package/models/seriesType/common.d.ts +9 -0
- package/models/seriesType/pie.d.ts +9 -0
- package/modern/BarChart/AnimatedBarElement.js +1 -0
- package/modern/BarChart/BarChart.js +17 -7
- package/modern/BarChart/legend.js +1 -0
- package/modern/BarChart/useBarChartProps.js +16 -3
- package/modern/ChartsLabel/ChartsLabel.js +3 -18
- package/modern/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/modern/ChartsLabel/ChartsLabelMark.js +5 -2
- package/modern/ChartsLabel/index.js +6 -0
- package/modern/ChartsLabel/labelGradientClasses.js +3 -2
- package/modern/ChartsLabel/labelMarkClasses.js +3 -2
- package/modern/ChartsLegend/ChartsLegend.js +100 -109
- package/modern/ChartsLegend/ContinuousColorLegend.js +198 -321
- package/modern/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/modern/ChartsLegend/chartsLegendClasses.js +16 -2
- package/modern/ChartsLegend/colorLegend.types.js +1 -0
- package/modern/ChartsLegend/continuousColorLegendClasses.js +23 -0
- package/modern/ChartsLegend/direction.js +1 -0
- package/modern/ChartsLegend/index.js +9 -3
- package/modern/ChartsLegend/legendContext.types.js +1 -0
- package/modern/ChartsLegend/onClickContextBuilder.js +7 -0
- package/modern/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +9 -0
- package/modern/ChartsLegend/piecewiseColorLegend.types.js +1 -0
- package/modern/ChartsLegend/piecewiseColorLegendClasses.js +23 -0
- package/modern/ChartsLegend/useAxis.js +0 -1
- package/modern/ChartsSurface/ChartsSurface.js +0 -1
- package/modern/LineChart/AnimatedArea.js +1 -0
- package/modern/LineChart/AnimatedLine.js +1 -0
- package/modern/LineChart/AppearingMask.js +1 -0
- package/modern/LineChart/CircleMarkElement.js +1 -0
- package/modern/LineChart/LineChart.js +20 -10
- package/modern/LineChart/MarkElement.js +3 -1
- package/modern/LineChart/legend.js +1 -0
- package/modern/LineChart/useLineChartProps.js +15 -2
- package/modern/PieChart/PieArc.js +3 -1
- package/modern/PieChart/PieArcLabel.js +13 -9
- package/modern/PieChart/PieArcLabelPlot.js +1 -0
- package/modern/PieChart/PieArcPlot.js +1 -0
- package/modern/PieChart/PieChart.js +42 -41
- package/modern/PieChart/legend.js +1 -0
- package/modern/ScatterChart/ScatterChart.js +21 -11
- package/modern/ScatterChart/legend.js +1 -0
- package/modern/ScatterChart/useScatterChartProps.js +15 -2
- package/modern/SparkLineChart/SparkLineChart.js +1 -4
- package/modern/constants/index.js +2 -1
- package/modern/hooks/index.js +2 -1
- package/{ChartsLegend/utils.js → modern/hooks/useLegend.js} +20 -1
- package/modern/index.js +2 -1
- package/modern/internals/calculateMargins.js +25 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +60 -16
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +61 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/modern/internals/components/ChartsWrapper/ChartsWrapper.js +66 -0
- package/modern/internals/components/ChartsWrapper/index.js +1 -0
- package/modern/internals/consumeSlots.js +101 -0
- package/modern/internals/consumeThemeProps.js +18 -27
- package/modern/internals/index.js +1 -0
- package/node/BarChart/AnimatedBarElement.js +1 -0
- package/node/BarChart/BarChart.js +17 -7
- package/node/BarChart/legend.js +1 -0
- package/node/BarChart/useBarChartProps.js +15 -3
- package/node/ChartsLabel/ChartsLabel.js +3 -18
- package/node/ChartsLabel/ChartsLabelGradient.js +21 -18
- package/node/ChartsLabel/ChartsLabelMark.js +5 -2
- package/node/ChartsLabel/index.js +26 -0
- package/node/ChartsLabel/labelGradientClasses.js +3 -2
- package/node/ChartsLabel/labelMarkClasses.js +3 -2
- package/node/ChartsLegend/ChartsLegend.js +99 -108
- package/node/ChartsLegend/ContinuousColorLegend.js +199 -322
- package/node/ChartsLegend/PiecewiseColorLegend.js +201 -111
- package/node/ChartsLegend/chartsLegendClasses.js +17 -3
- package/node/ChartsLegend/colorLegend.types.js +5 -0
- package/node/ChartsLegend/continuousColorLegendClasses.js +31 -0
- package/node/ChartsLegend/direction.js +5 -0
- package/node/ChartsLegend/index.js +80 -16
- package/node/ChartsLegend/legendContext.types.js +5 -0
- package/node/ChartsLegend/onClickContextBuilder.js +14 -0
- package/node/ChartsLegend/piecewiseColorDefaultLabelFormatter.js +15 -0
- package/node/ChartsLegend/piecewiseColorLegend.types.js +5 -0
- package/node/ChartsLegend/piecewiseColorLegendClasses.js +31 -0
- package/node/ChartsSurface/ChartsSurface.js +0 -1
- package/node/LineChart/AnimatedArea.js +1 -0
- package/node/LineChart/AnimatedLine.js +1 -0
- package/node/LineChart/AppearingMask.js +1 -0
- package/node/LineChart/CircleMarkElement.js +1 -0
- package/node/LineChart/LineChart.js +20 -10
- package/node/LineChart/MarkElement.js +3 -1
- package/node/LineChart/legend.js +1 -0
- package/node/LineChart/useLineChartProps.js +14 -2
- package/node/PieChart/PieArc.js +3 -1
- package/node/PieChart/PieArcLabel.js +13 -9
- package/node/PieChart/PieArcLabelPlot.js +1 -0
- package/node/PieChart/PieArcPlot.js +1 -0
- package/node/PieChart/PieChart.js +42 -41
- package/node/PieChart/legend.js +1 -0
- package/node/ScatterChart/ScatterChart.js +21 -11
- package/node/ScatterChart/legend.js +1 -0
- package/node/ScatterChart/useScatterChartProps.js +14 -2
- package/node/SparkLineChart/SparkLineChart.js +1 -4
- package/node/constants/index.js +3 -2
- package/node/hooks/index.js +13 -1
- package/node/{ChartsLegend/utils.js → hooks/useLegend.js} +19 -1
- package/node/index.js +12 -1
- package/node/internals/calculateMargins.js +33 -0
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +61 -16
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +6 -6
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradientObjectBound.js +69 -0
- package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/node/internals/components/ChartsWrapper/ChartsWrapper.js +72 -0
- package/node/internals/components/ChartsWrapper/index.js +16 -0
- package/node/internals/consumeSlots.js +109 -0
- package/node/internals/consumeThemeProps.js +18 -27
- package/node/internals/index.js +12 -0
- package/package.json +4 -4
- package/ChartsLegend/ChartsLegendItem.d.ts +0 -26
- package/ChartsLegend/ChartsLegendItem.js +0 -65
- package/ChartsLegend/DefaultChartsLegend.d.ts +0 -25
- package/ChartsLegend/DefaultChartsLegend.js +0 -112
- package/ChartsLegend/LegendPerItem.d.ts +0 -65
- package/ChartsLegend/LegendPerItem.js +0 -129
- package/ChartsLegend/legendItemsPlacement.d.ts +0 -3
- package/ChartsLegend/legendItemsPlacement.js +0 -72
- package/ChartsLegend/utils.d.ts +0 -2
- package/modern/ChartsLegend/ChartsLegendItem.js +0 -65
- package/modern/ChartsLegend/DefaultChartsLegend.js +0 -112
- package/modern/ChartsLegend/LegendPerItem.js +0 -129
- package/modern/ChartsLegend/legendItemsPlacement.js +0 -72
- package/node/ChartsLegend/ChartsLegendItem.js +0 -72
- package/node/ChartsLegend/DefaultChartsLegend.js +0 -118
- package/node/ChartsLegend/LegendPerItem.js +0 -137
- package/node/ChartsLegend/legendItemsPlacement.js +0 -79
|
@@ -1,62 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import { AxisId } from '../models/axis';
|
|
3
|
-
export type AnchorX = 'left' | 'right' | 'middle';
|
|
4
|
-
export type AnchorY = 'top' | 'bottom' | 'middle';
|
|
5
|
-
export type AnchorPosition = {
|
|
6
|
-
horizontal: AnchorX;
|
|
7
|
-
vertical: AnchorY;
|
|
8
|
-
};
|
|
9
|
-
export type Direction = 'row' | 'column';
|
|
10
|
-
export interface ColorLegendSelector {
|
|
11
|
-
/**
|
|
12
|
-
* The axis direction containing the color configuration to represent.
|
|
13
|
-
* @default 'z'
|
|
14
|
-
*/
|
|
15
|
-
axisDirection?: 'x' | 'y' | 'z';
|
|
1
|
+
export type LegendPosition = {
|
|
16
2
|
/**
|
|
17
|
-
* The
|
|
18
|
-
* @default The first axis item.
|
|
3
|
+
* The vertical position of the legend.
|
|
19
4
|
*/
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
export interface LegendPlacement {
|
|
5
|
+
vertical?: 'top' | 'middle' | 'bottom';
|
|
23
6
|
/**
|
|
24
|
-
* The position of the legend.
|
|
7
|
+
* The horizontal position of the legend.
|
|
25
8
|
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The direction of the legend layout.
|
|
29
|
-
* The default depends on the chart.
|
|
30
|
-
*/
|
|
31
|
-
direction?: Direction;
|
|
32
|
-
}
|
|
33
|
-
export type BoundingBox = {
|
|
34
|
-
width: number;
|
|
35
|
-
height: number;
|
|
9
|
+
horizontal?: 'left' | 'middle' | 'right';
|
|
36
10
|
};
|
|
37
|
-
export
|
|
38
|
-
x: number;
|
|
39
|
-
y: number;
|
|
40
|
-
}
|
|
41
|
-
export interface TextPosition extends Position {
|
|
42
|
-
dominantBaseline: ChartsTextBaseline;
|
|
43
|
-
textAnchor: ChartsTextStyle['textAnchor'];
|
|
44
|
-
}
|
|
45
|
-
export type PiecewiseLabelFormatterParams = {
|
|
46
|
-
/**
|
|
47
|
-
* The min value of the piece. `null` is infinite.
|
|
48
|
-
*/
|
|
49
|
-
min: number | Date | null;
|
|
50
|
-
/**
|
|
51
|
-
* The max value of the piece. `null` is infinite.
|
|
52
|
-
*/
|
|
53
|
-
max: number | Date | null;
|
|
54
|
-
/**
|
|
55
|
-
* The formatted min value of the piece. `null` is infinite.
|
|
56
|
-
*/
|
|
57
|
-
formattedMin: string | null;
|
|
11
|
+
export type ChartsLegendPosition = {
|
|
58
12
|
/**
|
|
59
|
-
* The
|
|
13
|
+
* The position of the legend in relation to the chart.
|
|
14
|
+
* This property is only passed to the Chart components, e.g. `ScatterChart`, and not the slots themselves.
|
|
15
|
+
* If customization is needed, simply use the composition pattern.
|
|
60
16
|
*/
|
|
61
|
-
|
|
17
|
+
position?: LegendPosition;
|
|
62
18
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ChartsLabelMarkProps } from '../ChartsLabel/ChartsLabelMark';
|
|
2
|
+
import { PieItemId } from '../models';
|
|
3
|
+
import { SeriesId } from '../models/seriesType/common';
|
|
4
|
+
interface LegendItemContextBase {
|
|
5
|
+
/**
|
|
6
|
+
* The color used in the legend
|
|
7
|
+
*/
|
|
8
|
+
color: string;
|
|
9
|
+
/**
|
|
10
|
+
* The label displayed in the legend
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
}
|
|
14
|
+
export interface LegendItemParams extends Partial<Omit<SeriesLegendItemContext, 'type' | keyof LegendItemContextBase>>, Partial<Omit<PiecewiseColorLegendItemContext, 'type' | keyof LegendItemContextBase>>, LegendItemContextBase {
|
|
15
|
+
/**
|
|
16
|
+
* The identifier of the legend element.
|
|
17
|
+
* Used for internal purpose such as `key` props
|
|
18
|
+
*/
|
|
19
|
+
id: number | string;
|
|
20
|
+
markType: ChartsLabelMarkProps['type'];
|
|
21
|
+
}
|
|
22
|
+
export interface SeriesLegendItemContext extends LegendItemContextBase {
|
|
23
|
+
/**
|
|
24
|
+
* The type of the legend item
|
|
25
|
+
* - `series` is used for series legend item
|
|
26
|
+
* - `piecewiseColor` is used for piecewise color legend item
|
|
27
|
+
*/
|
|
28
|
+
type: 'series';
|
|
29
|
+
/**
|
|
30
|
+
* The identifier of the series
|
|
31
|
+
*/
|
|
32
|
+
seriesId: SeriesId;
|
|
33
|
+
/**
|
|
34
|
+
* The identifier of the pie item
|
|
35
|
+
*/
|
|
36
|
+
itemId?: PieItemId;
|
|
37
|
+
}
|
|
38
|
+
export interface PiecewiseColorLegendItemContext extends LegendItemContextBase {
|
|
39
|
+
/**
|
|
40
|
+
* The type of the legend item
|
|
41
|
+
* - `series` is used for series legend item
|
|
42
|
+
* - `piecewiseColor` is used for piecewise color legend item
|
|
43
|
+
*/
|
|
44
|
+
type: 'piecewiseColor';
|
|
45
|
+
/**
|
|
46
|
+
* The minimum value of the category
|
|
47
|
+
*/
|
|
48
|
+
minValue: number | Date | null;
|
|
49
|
+
/**
|
|
50
|
+
* The maximum value of the category
|
|
51
|
+
*/
|
|
52
|
+
maxValue: number | Date | null;
|
|
53
|
+
}
|
|
54
|
+
export type LegendItemContext = SeriesLegendItemContext | PiecewiseColorLegendItemContext;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type PiecewiseLabelFormatterParams = {
|
|
2
|
+
/**
|
|
3
|
+
* The index of the entry.
|
|
4
|
+
*/
|
|
5
|
+
index: number;
|
|
6
|
+
/**
|
|
7
|
+
* The length of the entries array.
|
|
8
|
+
*/
|
|
9
|
+
length: number;
|
|
10
|
+
/**
|
|
11
|
+
* The min value of the piece. `null` is infinite.
|
|
12
|
+
*/
|
|
13
|
+
min: number | Date | null;
|
|
14
|
+
/**
|
|
15
|
+
* The max value of the piece. `null` is infinite.
|
|
16
|
+
*/
|
|
17
|
+
max: number | Date | null;
|
|
18
|
+
/**
|
|
19
|
+
* The formatted min value of the piece. `null` is infinite.
|
|
20
|
+
*/
|
|
21
|
+
formattedMin: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* The formatted max value of the piece. `null` is infinite.
|
|
24
|
+
*/
|
|
25
|
+
formattedMax: string | null;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PiecewiseColorLegendProps } from './PiecewiseColorLegend';
|
|
2
|
+
import type { ChartsLegendSlotExtension } from './chartsLegend.types';
|
|
3
|
+
export interface PiecewiseColorLegendClasses {
|
|
4
|
+
/** Styles applied to the root element. */
|
|
5
|
+
root: string;
|
|
6
|
+
/** Styles applied to the list item that renders the `minLabel`. */
|
|
7
|
+
minLabel: string;
|
|
8
|
+
/** Styles applied to the list item that renders the `maxLabel`. */
|
|
9
|
+
maxLabel: string;
|
|
10
|
+
/** Styles applied to the list items. */
|
|
11
|
+
item: string;
|
|
12
|
+
/** Styles applied to the legend in column layout. */
|
|
13
|
+
vertical: string;
|
|
14
|
+
/** Styles applied to the legend in row layout. */
|
|
15
|
+
horizontal: string;
|
|
16
|
+
/** Styles applied to the legend with the labels before the color marks. */
|
|
17
|
+
start: string;
|
|
18
|
+
/** Styles applied to the legend with the labels after the color marks. */
|
|
19
|
+
end: string;
|
|
20
|
+
/** Styles applied to the legend with the labels on the extremes of the color marks. */
|
|
21
|
+
extremes: string;
|
|
22
|
+
/** Styles applied to the marks. */
|
|
23
|
+
mark: string;
|
|
24
|
+
/** Styles applied to the series label. */
|
|
25
|
+
label: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const useUtilityClasses: (props: PiecewiseColorLegendProps & ChartsLegendSlotExtension) => Record<"root" | "label" | "mark" | "item" | "minLabel" | "maxLabel", string>;
|
|
28
|
+
export declare const piecewiseColorLegendClasses: PiecewiseColorLegendClasses;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
4
|
+
function getLegendUtilityClass(slot) {
|
|
5
|
+
return generateUtilityClass('MuiPiecewiseColorLegendClasses', slot);
|
|
6
|
+
}
|
|
7
|
+
export const useUtilityClasses = props => {
|
|
8
|
+
const {
|
|
9
|
+
classes,
|
|
10
|
+
direction,
|
|
11
|
+
labelPosition
|
|
12
|
+
} = props;
|
|
13
|
+
const slots = {
|
|
14
|
+
root: ['root', direction, labelPosition],
|
|
15
|
+
minLabel: ['minLabel'],
|
|
16
|
+
maxLabel: ['maxLabel'],
|
|
17
|
+
item: ['item'],
|
|
18
|
+
mark: ['mark'],
|
|
19
|
+
label: ['label']
|
|
20
|
+
};
|
|
21
|
+
return composeClasses(slots, getLegendUtilityClass, classes);
|
|
22
|
+
};
|
|
23
|
+
export const piecewiseColorLegendClasses = generateUtilityClasses('MuiPiecewiseColorLegendClasses', ['root', 'minLabel', 'maxLabel', 'item', 'vertical', 'horizontal', 'start', 'end', 'extremes', 'mark', 'label']);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxisDefaultized } from '../models/axis';
|
|
2
2
|
import { ZAxisDefaultized } from '../models/z-axis';
|
|
3
|
-
import { ColorLegendSelector } from './
|
|
3
|
+
import { ColorLegendSelector } from './colorLegend.types';
|
|
4
4
|
/**
|
|
5
5
|
* Helper to select an axis definition according to its direction and id.
|
|
6
6
|
*/
|
package/ChartsLegend/useAxis.js
CHANGED
|
@@ -8,6 +8,6 @@ export type ChartsXReferenceLineProps<TValue extends string | number | Date = st
|
|
|
8
8
|
*/
|
|
9
9
|
x: TValue;
|
|
10
10
|
};
|
|
11
|
-
export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"
|
|
11
|
+
export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
|
|
12
12
|
declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
|
|
13
13
|
export { ChartsXReferenceLine };
|
|
@@ -8,6 +8,6 @@ export type ChartsYReferenceLineProps<TValue extends string | number | Date = st
|
|
|
8
8
|
*/
|
|
9
9
|
y: TValue;
|
|
10
10
|
};
|
|
11
|
-
export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"
|
|
11
|
+
export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
|
|
12
12
|
declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
|
|
13
13
|
export { ChartsYReferenceLine };
|
|
@@ -23,4 +23,4 @@ export interface ChartsTooltipClasses {
|
|
|
23
23
|
export type ChartsTooltipClassKey = keyof Omit<ChartsTooltipClasses, 'markCell' | 'labelCell' | 'valueCell'>;
|
|
24
24
|
export declare function getChartsTooltipUtilityClass(slot: string): string;
|
|
25
25
|
export declare const chartsTooltipClasses: ChartsTooltipClasses;
|
|
26
|
-
export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"
|
|
26
|
+
export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"root" | "mark" | "table" | "cell" | "row" | "markCell" | "labelCell" | "valueCell" | "paper" | "axisValueCell", string>;
|
|
@@ -44,6 +44,7 @@ function AnimatedArea(props) {
|
|
|
44
44
|
skipAnimation: skipAnimation,
|
|
45
45
|
id: `${ownerState.id}-area-clip`,
|
|
46
46
|
children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(animated.path, _extends({
|
|
47
|
+
// @ts-expect-error
|
|
47
48
|
d: style.value.to(interpolator),
|
|
48
49
|
fill: ownerState.gradientId ? `url(#${ownerState.gradientId})` : ownerState.color,
|
|
49
50
|
filter:
|
|
@@ -44,6 +44,7 @@ function AnimatedLine(props) {
|
|
|
44
44
|
skipAnimation: skipAnimation,
|
|
45
45
|
id: `${ownerState.id}-line-clip`,
|
|
46
46
|
children: transitionChange((style, interpolator) => /*#__PURE__*/_jsx(animated.path, _extends({
|
|
47
|
+
// @ts-expect-error
|
|
47
48
|
d: style.value.to(interpolator),
|
|
48
49
|
stroke: ownerState.gradientId ? `url(#${ownerState.gradientId})` : ownerState.color,
|
|
49
50
|
strokeWidth: 2,
|
package/LineChart/LineChart.js
CHANGED
|
@@ -6,7 +6,6 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import { AreaPlot } from "./AreaPlot.js";
|
|
8
8
|
import { LinePlot } from "./LinePlot.js";
|
|
9
|
-
import { ChartContainer } from "../ChartContainer/index.js";
|
|
10
9
|
import { MarkPlot } from "./MarkPlot.js";
|
|
11
10
|
import { ChartsAxis } from "../ChartsAxis/ChartsAxis.js";
|
|
12
11
|
import { ChartsTooltip } from "../ChartsTooltip/index.js";
|
|
@@ -18,6 +17,10 @@ import { ChartsGrid } from "../ChartsGrid/index.js";
|
|
|
18
17
|
import { ChartsOnAxisClickHandler } from "../ChartsOnAxisClickHandler/index.js";
|
|
19
18
|
import { ChartsOverlay } from "../ChartsOverlay/index.js";
|
|
20
19
|
import { useLineChartProps } from "./useLineChartProps.js";
|
|
20
|
+
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
21
|
+
import { ChartDataProvider } from "../context/index.js";
|
|
22
|
+
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
23
|
+
import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
|
|
21
24
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
25
|
/**
|
|
23
26
|
* Demos:
|
|
@@ -35,6 +38,7 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref)
|
|
|
35
38
|
name: 'MuiLineChart'
|
|
36
39
|
});
|
|
37
40
|
const {
|
|
41
|
+
chartsWrapperProps,
|
|
38
42
|
chartContainerProps,
|
|
39
43
|
axisClickHandlerProps,
|
|
40
44
|
gridProps,
|
|
@@ -50,16 +54,22 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref)
|
|
|
50
54
|
legendProps,
|
|
51
55
|
children
|
|
52
56
|
} = useLineChartProps(props);
|
|
57
|
+
const {
|
|
58
|
+
chartDataProviderProps,
|
|
59
|
+
chartsSurfaceProps
|
|
60
|
+
} = useChartContainerProps(chartContainerProps, ref);
|
|
53
61
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
54
|
-
return /*#__PURE__*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
63
|
+
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
64
|
+
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
65
|
+
children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
66
|
+
children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
67
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
|
|
68
|
+
"data-drawing-container": true,
|
|
69
|
+
children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
|
|
70
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
71
|
+
}))]
|
|
72
|
+
}))
|
|
63
73
|
}));
|
|
64
74
|
});
|
|
65
75
|
process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
package/LineChart/MarkElement.js
CHANGED
|
@@ -80,7 +80,9 @@ function MarkElement(props) {
|
|
|
80
80
|
transform: to([position.x, position.y], (pX, pY) => `translate(${pX}px, ${pY}px)`),
|
|
81
81
|
transformOrigin: to([position.x, position.y], (pX, pY) => `${pX}px ${pY}px`)
|
|
82
82
|
},
|
|
83
|
-
ownerState: ownerState
|
|
83
|
+
ownerState: ownerState
|
|
84
|
+
// @ts-expect-error
|
|
85
|
+
,
|
|
84
86
|
className: classes.root,
|
|
85
87
|
d: d3Symbol(d3SymbolsFill[getSymbol(shape)])(),
|
|
86
88
|
onClick: onClick,
|
package/LineChart/legend.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ChartsAxisProps } from '../ChartsAxis';
|
|
|
2
2
|
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
3
3
|
import { ChartsClipPathProps } from '../ChartsClipPath';
|
|
4
4
|
import { ChartsGridProps } from '../ChartsGrid';
|
|
5
|
-
import {
|
|
5
|
+
import { ChartsLegendSlotExtension } from '../ChartsLegend';
|
|
6
6
|
import { ChartsOnAxisClickHandlerProps } from '../ChartsOnAxisClickHandler';
|
|
7
7
|
import { ChartsOverlayProps } from '../ChartsOverlay';
|
|
8
8
|
import { ChartContainerProps } from '../ChartContainer';
|
|
@@ -11,6 +11,7 @@ import type { LineChartProps } from './LineChart';
|
|
|
11
11
|
import { LineHighlightPlotProps } from './LineHighlightPlot';
|
|
12
12
|
import { LinePlotProps } from './LinePlot';
|
|
13
13
|
import { MarkPlotProps } from './MarkPlot';
|
|
14
|
+
import type { ChartsWrapperProps } from '../internals/components/ChartsWrapper';
|
|
14
15
|
/**
|
|
15
16
|
* A helper function that extracts LineChartProps from the input props
|
|
16
17
|
* and returns an object with props for the children components of LineChart.
|
|
@@ -19,6 +20,7 @@ import { MarkPlotProps } from './MarkPlot';
|
|
|
19
20
|
* @returns An object with props for the children components of LineChart
|
|
20
21
|
*/
|
|
21
22
|
export declare const useLineChartProps: (props: LineChartProps) => {
|
|
23
|
+
chartsWrapperProps: Omit<ChartsWrapperProps, "children">;
|
|
22
24
|
chartContainerProps: ChartContainerProps;
|
|
23
25
|
axisClickHandlerProps: ChartsOnAxisClickHandlerProps;
|
|
24
26
|
gridProps: ChartsGridProps;
|
|
@@ -33,6 +35,6 @@ export declare const useLineChartProps: (props: LineChartProps) => {
|
|
|
33
35
|
chartsAxisProps: ChartsAxisProps;
|
|
34
36
|
axisHighlightProps: ChartsAxisHighlightProps;
|
|
35
37
|
lineHighlightPlotProps: LineHighlightPlotProps;
|
|
36
|
-
legendProps:
|
|
38
|
+
legendProps: ChartsLegendSlotExtension;
|
|
37
39
|
children: import("react").ReactNode;
|
|
38
40
|
};
|
|
@@ -5,6 +5,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className", "experimentalMarkRendering"];
|
|
6
6
|
import useId from '@mui/utils/useId';
|
|
7
7
|
import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|
|
8
|
+
import { calculateMargins } from "../internals/calculateMargins.js";
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* A helper function that extracts LineChartProps from the input props
|
|
10
12
|
* and returns an object with props for the children components of LineChart.
|
|
@@ -29,6 +31,7 @@ export const useLineChartProps = props => {
|
|
|
29
31
|
onMarkClick,
|
|
30
32
|
axisHighlight,
|
|
31
33
|
disableLineItemHighlight,
|
|
34
|
+
hideLegend,
|
|
32
35
|
grid,
|
|
33
36
|
topAxis,
|
|
34
37
|
leftAxis,
|
|
@@ -54,7 +57,12 @@ export const useLineChartProps = props => {
|
|
|
54
57
|
}, s)),
|
|
55
58
|
width,
|
|
56
59
|
height,
|
|
57
|
-
margin
|
|
60
|
+
margin: calculateMargins({
|
|
61
|
+
margin,
|
|
62
|
+
hideLegend,
|
|
63
|
+
slotProps,
|
|
64
|
+
series
|
|
65
|
+
}),
|
|
58
66
|
colors,
|
|
59
67
|
dataset,
|
|
60
68
|
xAxis: xAxis ?? [{
|
|
@@ -65,7 +73,6 @@ export const useLineChartProps = props => {
|
|
|
65
73
|
}, (_, index) => index)
|
|
66
74
|
}],
|
|
67
75
|
yAxis,
|
|
68
|
-
sx,
|
|
69
76
|
highlightedItem,
|
|
70
77
|
onHighlightChange,
|
|
71
78
|
disableAxisListener: slotProps?.tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
@@ -126,7 +133,13 @@ export const useLineChartProps = props => {
|
|
|
126
133
|
slots,
|
|
127
134
|
slotProps
|
|
128
135
|
};
|
|
136
|
+
const chartsWrapperProps = {
|
|
137
|
+
sx,
|
|
138
|
+
legendPosition: props.slotProps?.legend?.position,
|
|
139
|
+
legendDirection: props.slotProps?.legend?.direction
|
|
140
|
+
};
|
|
129
141
|
return {
|
|
142
|
+
chartsWrapperProps,
|
|
130
143
|
chartContainerProps,
|
|
131
144
|
axisClickHandlerProps,
|
|
132
145
|
gridProps,
|
package/PieChart/PieArc.js
CHANGED
|
@@ -76,7 +76,9 @@ function PieArc(props) {
|
|
|
76
76
|
innerRadius: iR,
|
|
77
77
|
outerRadius: oR
|
|
78
78
|
})),
|
|
79
|
-
visibility: to([startAngle, endAngle], (sA, eA) => sA === eA ? 'hidden' : 'visible')
|
|
79
|
+
visibility: to([startAngle, endAngle], (sA, eA) => sA === eA ? 'hidden' : 'visible')
|
|
80
|
+
// @ts-expect-error
|
|
81
|
+
,
|
|
80
82
|
onClick: onClick,
|
|
81
83
|
cursor: onClick ? 'pointer' : 'unset',
|
|
82
84
|
ownerState: ownerState,
|
package/PieChart/PieArcLabel.js
CHANGED
|
@@ -84,15 +84,19 @@ function PieArcLabel(props) {
|
|
|
84
84
|
isHighlighted
|
|
85
85
|
};
|
|
86
86
|
const classes = useUtilityClasses(ownerState);
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
return (
|
|
88
|
+
/*#__PURE__*/
|
|
89
|
+
// @ts-expect-error
|
|
90
|
+
_jsx(PieArcLabelRoot, _extends({
|
|
91
|
+
className: classes.root
|
|
92
|
+
}, other, {
|
|
93
|
+
style: _extends({
|
|
94
|
+
x: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'x')),
|
|
95
|
+
y: to([startAngle, endAngle, paddingAngle, arcLabelRadius, cornerRadius], getLabelPosition(formattedArcLabel, 'y'))
|
|
96
|
+
}, style),
|
|
97
|
+
children: formattedArcLabel
|
|
98
|
+
}))
|
|
99
|
+
);
|
|
96
100
|
}
|
|
97
101
|
process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
98
102
|
// ----------------------------- Warning --------------------------------
|
|
@@ -133,6 +133,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
|
133
133
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
134
134
|
index: PropTypes.number.isRequired,
|
|
135
135
|
label: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
136
|
+
labelMarkType: PropTypes.oneOf(['circle', 'line', 'square']),
|
|
136
137
|
padAngle: PropTypes.number.isRequired,
|
|
137
138
|
startAngle: PropTypes.number.isRequired,
|
|
138
139
|
value: PropTypes.number.isRequired
|
package/PieChart/PieArcPlot.js
CHANGED
|
@@ -99,6 +99,7 @@ process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
|
|
99
99
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
100
100
|
index: PropTypes.number.isRequired,
|
|
101
101
|
label: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
102
|
+
labelMarkType: PropTypes.oneOf(['circle', 'line', 'square']),
|
|
102
103
|
padAngle: PropTypes.number.isRequired,
|
|
103
104
|
startAngle: PropTypes.number.isRequired,
|
|
104
105
|
value: PropTypes.number.isRequired
|