@mui/x-charts 7.9.0 → 7.11.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 +2 -2
- package/BarChart/formatter.js +1 -1
- package/BarChart/useBarChartProps.js +38 -33
- package/CHANGELOG.md +159 -0
- package/ChartContainer/ChartContainer.d.ts +28 -2
- package/ChartContainer/ChartContainer.js +25 -66
- package/ChartContainer/useChartContainerHooks.d.ts +1 -1
- package/ChartContainer/useChartContainerHooks.js +2 -2
- package/ChartContainer/useChartContainerProps.d.ts +86 -0
- package/ChartContainer/useChartContainerProps.js +95 -0
- package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
- package/ChartContainer/useDefaultizeAxis.js +29 -0
- package/ChartsLegend/ChartsLegend.d.ts +3 -12
- package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
- package/ChartsLegend/ContinuousColorLegend.js +398 -0
- package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
- package/ChartsLegend/DefaultChartsLegend.js +13 -198
- package/ChartsLegend/LegendPerItem.d.ts +61 -0
- package/ChartsLegend/LegendPerItem.js +151 -0
- package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
- package/ChartsLegend/PiecewiseColorLegend.js +169 -0
- package/ChartsLegend/chartsLegend.types.d.ts +31 -0
- package/ChartsLegend/chartsLegend.types.js +5 -0
- package/ChartsLegend/index.d.ts +2 -0
- package/ChartsLegend/index.js +22 -0
- package/ChartsLegend/legend.types.d.ts +62 -0
- package/ChartsLegend/legend.types.js +5 -0
- package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
- package/ChartsLegend/legendItemsPlacement.js +79 -0
- package/ChartsLegend/useAxis.d.ts +7 -0
- package/ChartsLegend/useAxis.js +47 -0
- package/ChartsLegend/utils.d.ts +1 -8
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsSurface.js +3 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
- package/ChartsXAxis/ChartsXAxis.js +1 -1
- package/ChartsYAxis/ChartsYAxis.js +15 -3
- package/Gauge/Gauge.d.ts +1 -4
- package/Gauge/Gauge.js +9 -6
- package/Gauge/GaugeContainer.js +8 -4
- package/Gauge/GaugeProvider.js +9 -9
- package/LineChart/AnimatedArea.js +2 -2
- package/LineChart/AnimatedLine.js +2 -2
- package/LineChart/AreaPlot.js +7 -1
- package/LineChart/LineChart.js +2 -2
- package/LineChart/LineHighlightPlot.js +8 -0
- package/LineChart/MarkElement.js +2 -2
- package/LineChart/MarkPlot.js +4 -20
- package/LineChart/extremums.js +1 -1
- package/LineChart/formatter.js +1 -1
- package/LineChart/useLineChartProps.js +38 -33
- package/PieChart/PieChart.d.ts +1 -4
- package/PieChart/PieChart.js +40 -34
- package/PieChart/PiePlot.js +6 -6
- package/PieChart/getPieCoordinates.js +3 -3
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +6 -2
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
- package/ScatterChart/Scatter.js +6 -9
- package/ScatterChart/useScatterChartProps.js +35 -30
- package/SparkLineChart/SparkLineChart.js +27 -22
- package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
- package/context/CartesianProvider/CartesianProvider.js +18 -7
- package/context/CartesianProvider/computeValue.d.ts +32 -9
- package/context/CartesianProvider/computeValue.js +20 -16
- package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
- package/context/CartesianProvider/defaultizeAxis.js +21 -0
- package/context/CartesianProvider/index.d.ts +0 -1
- package/context/CartesianProvider/index.js +1 -3
- package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
- package/context/CartesianProvider/normalizeAxis.js +1 -1
- package/context/DrawingProvider.d.ts +11 -0
- package/context/DrawingProvider.js +9 -2
- package/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/formatter.js +1 -1
- package/esm/BarChart/useBarChartProps.js +38 -33
- package/esm/ChartContainer/ChartContainer.js +25 -66
- package/esm/ChartContainer/useChartContainerHooks.js +2 -2
- package/esm/ChartContainer/useChartContainerProps.js +87 -0
- package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
- package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/esm/ChartsLegend/LegendPerItem.js +141 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/esm/ChartsLegend/chartsLegend.types.js +1 -0
- package/esm/ChartsLegend/index.js +2 -0
- package/esm/ChartsLegend/legend.types.js +1 -0
- package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
- package/esm/ChartsLegend/useAxis.js +39 -0
- package/esm/ChartsSurface.js +3 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
- package/esm/Gauge/Gauge.js +8 -5
- package/esm/Gauge/GaugeContainer.js +8 -4
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/LineChart.js +2 -2
- package/esm/LineChart/LineHighlightPlot.js +8 -0
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +3 -19
- package/esm/LineChart/extremums.js +1 -1
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/useLineChartProps.js +38 -33
- package/esm/PieChart/PieChart.js +39 -33
- package/esm/PieChart/PiePlot.js +1 -1
- package/esm/PieChart/getPieCoordinates.js +1 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +6 -2
- package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/esm/ScatterChart/Scatter.js +6 -9
- package/esm/ScatterChart/useScatterChartProps.js +35 -30
- package/esm/SparkLineChart/SparkLineChart.js +27 -22
- package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
- package/esm/context/CartesianProvider/computeValue.js +20 -16
- package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/esm/context/CartesianProvider/index.js +1 -3
- package/esm/context/CartesianProvider/normalizeAxis.js +1 -1
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/hooks/useAxisEvents.js +3 -10
- package/esm/hooks/useDrawingArea.js +5 -3
- package/esm/hooks/useReducedMotion.js +4 -2
- package/esm/internals/cleanId.js +6 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
- package/esm/internals/getSymbol.js +5 -0
- package/esm/internals/index.js +3 -1
- package/esm/internals/isDefined.js +3 -0
- package/esm/internals/notNull.js +3 -0
- package/esm/internals/ts-generic.js +1 -0
- package/hooks/useAxisEvents.js +3 -10
- package/hooks/useDrawingArea.js +5 -3
- package/hooks/useReducedMotion.js +4 -2
- package/index.js +1 -1
- package/internals/cleanId.d.ts +4 -0
- package/internals/cleanId.js +12 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/internals/getPercentageValue.d.ts +7 -0
- package/internals/{utils.js → getPercentageValue.js} +1 -15
- package/internals/getSymbol.d.ts +2 -0
- package/internals/getSymbol.js +11 -0
- package/internals/index.d.ts +3 -1
- package/internals/index.js +25 -5
- package/internals/isDefined.d.ts +1 -0
- package/internals/isDefined.js +9 -0
- package/internals/notNull.d.ts +1 -0
- package/internals/notNull.js +9 -0
- package/internals/ts-generic.d.ts +5 -0
- package/internals/ts-generic.js +5 -0
- package/models/axis.d.ts +5 -2
- package/models/helpers.d.ts +1 -0
- package/models/seriesType/config.d.ts +2 -16
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/formatter.js +1 -1
- package/modern/BarChart/useBarChartProps.js +38 -33
- package/modern/ChartContainer/ChartContainer.js +25 -66
- package/modern/ChartContainer/useChartContainerHooks.js +2 -2
- package/modern/ChartContainer/useChartContainerProps.js +87 -0
- package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
- package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/modern/ChartsLegend/LegendPerItem.js +141 -0
- package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/modern/ChartsLegend/chartsLegend.types.js +1 -0
- package/modern/ChartsLegend/index.js +2 -0
- package/modern/ChartsLegend/legend.types.js +1 -0
- package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
- package/modern/ChartsLegend/useAxis.js +39 -0
- package/modern/ChartsSurface.js +3 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
- package/modern/Gauge/Gauge.js +8 -5
- package/modern/Gauge/GaugeContainer.js +8 -4
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/LineChart.js +2 -2
- package/modern/LineChart/LineHighlightPlot.js +8 -0
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +3 -19
- package/modern/LineChart/extremums.js +1 -1
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/useLineChartProps.js +38 -33
- package/modern/PieChart/PieChart.js +39 -33
- package/modern/PieChart/PiePlot.js +1 -1
- package/modern/PieChart/getPieCoordinates.js +1 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +6 -2
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/modern/ScatterChart/Scatter.js +6 -9
- package/modern/ScatterChart/useScatterChartProps.js +35 -30
- package/modern/SparkLineChart/SparkLineChart.js +27 -22
- package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
- package/modern/context/CartesianProvider/computeValue.js +20 -16
- package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/modern/context/CartesianProvider/index.js +1 -3
- package/modern/context/CartesianProvider/normalizeAxis.js +1 -1
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/modern/hooks/useAxisEvents.js +3 -10
- package/modern/hooks/useDrawingArea.js +5 -3
- package/modern/hooks/useReducedMotion.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/cleanId.js +6 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
- package/modern/internals/getSymbol.js +5 -0
- package/modern/internals/index.js +3 -1
- package/modern/internals/isDefined.js +3 -0
- package/modern/internals/notNull.js +3 -0
- package/modern/internals/ts-generic.js +1 -0
- package/package.json +4 -4
- package/internals/utils.d.ts +0 -18
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MakeOptional } from '../models/helpers';
|
|
2
|
+
import { AxisConfig, ScaleName } from '../models';
|
|
3
|
+
import { ChartsAxisProps } from '../models/axis';
|
|
4
|
+
export declare const useDefaultizeAxis: (inXAxis: MakeOptional<AxisConfig<ScaleName, any, ChartsAxisProps>, "id">[] | undefined, inYAxis: MakeOptional<AxisConfig<ScaleName, any, ChartsAxisProps>, "id">[] | undefined) => {
|
|
5
|
+
reverse?: boolean;
|
|
6
|
+
fill?: string;
|
|
7
|
+
stroke?: string;
|
|
8
|
+
data?: any[] | undefined;
|
|
9
|
+
label?: string;
|
|
10
|
+
max?: number | Date;
|
|
11
|
+
min?: number | Date;
|
|
12
|
+
classes?: Partial<import("..").ChartsAxisClasses>;
|
|
13
|
+
slots?: Partial<import("../models/axis").ChartsAxisSlots>;
|
|
14
|
+
slotProps?: Partial<import("../models/axis").ChartsAxisSlotProps>;
|
|
15
|
+
dataKey?: string;
|
|
16
|
+
valueFormatter?: ((value: any, context: import("../models/axis").AxisValueFormatterContext) => string) | undefined;
|
|
17
|
+
colorMap?: import("../models/colorMapping").ContinuousColorConfig<number | Date> | import("../models/colorMapping").PiecewiseColorConfig<number | Date> | import("../models/colorMapping").OrdinalColorConfig<string | number | Date> | undefined;
|
|
18
|
+
tickMaxStep?: number;
|
|
19
|
+
tickMinStep?: number;
|
|
20
|
+
tickNumber?: number;
|
|
21
|
+
tickPlacement?: "start" | "end" | "middle" | "extremities";
|
|
22
|
+
tickLabelPlacement?: "middle" | "tick";
|
|
23
|
+
scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
|
|
24
|
+
axisId?: import("../models/axis").AxisId;
|
|
25
|
+
disableLine?: boolean;
|
|
26
|
+
disableTicks?: boolean;
|
|
27
|
+
tickFontSize?: number;
|
|
28
|
+
tickLabelStyle?: import("..").ChartsTextProps["style"];
|
|
29
|
+
labelStyle?: import("..").ChartsTextProps["style"];
|
|
30
|
+
tickLabelInterval?: "auto" | ((value: any, index: number) => boolean);
|
|
31
|
+
labelFontSize?: number;
|
|
32
|
+
tickSize?: number;
|
|
33
|
+
tickInterval?: "auto" | ((value: any, index: number) => boolean) | any[];
|
|
34
|
+
hideTooltip?: boolean;
|
|
35
|
+
id: import("../models/axis").AxisId;
|
|
36
|
+
}[][];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useDefaultizeAxis = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const defaultizeAxis = (inAxis, axisName) => {
|
|
14
|
+
const DEFAULT_AXIS_KEY = axisName === 'x' ? _constants.DEFAULT_X_AXIS_KEY : _constants.DEFAULT_Y_AXIS_KEY;
|
|
15
|
+
return [...(inAxis?.map((axis, index) => (0, _extends2.default)({
|
|
16
|
+
id: `defaultized-${axisName}-axis-${index}`
|
|
17
|
+
}, axis)) ?? []), ...(inAxis === undefined || inAxis.findIndex(({
|
|
18
|
+
id
|
|
19
|
+
}) => id === DEFAULT_AXIS_KEY) === -1 ? [{
|
|
20
|
+
id: DEFAULT_AXIS_KEY,
|
|
21
|
+
scaleType: 'linear'
|
|
22
|
+
}] : [])];
|
|
23
|
+
};
|
|
24
|
+
const useDefaultizeAxis = (inXAxis, inYAxis) => {
|
|
25
|
+
const xAxis = React.useMemo(() => defaultizeAxis(inXAxis, 'x'), [inXAxis]);
|
|
26
|
+
const yAxis = React.useMemo(() => defaultizeAxis(inYAxis, 'y'), [inYAxis]);
|
|
27
|
+
return [xAxis, yAxis];
|
|
28
|
+
};
|
|
29
|
+
exports.useDefaultizeAxis = useDefaultizeAxis;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AnchorPosition, Direction } from './utils';
|
|
3
2
|
import { ChartsLegendClasses } from './chartsLegendClasses';
|
|
4
3
|
import { LegendRendererProps } from './DefaultChartsLegend';
|
|
4
|
+
import { LegendPlacement } from './legend.types';
|
|
5
5
|
export interface ChartsLegendSlots {
|
|
6
6
|
/**
|
|
7
7
|
* Custom rendering of the legend.
|
|
@@ -12,11 +12,7 @@ export interface ChartsLegendSlots {
|
|
|
12
12
|
export interface ChartsLegendSlotProps {
|
|
13
13
|
legend?: Partial<LegendRendererProps>;
|
|
14
14
|
}
|
|
15
|
-
export
|
|
16
|
-
/**
|
|
17
|
-
* The position of the legend.
|
|
18
|
-
*/
|
|
19
|
-
position?: AnchorPosition;
|
|
15
|
+
export interface ChartsLegendProps extends LegendPlacement {
|
|
20
16
|
/**
|
|
21
17
|
* Override or extend the styles applied to the component.
|
|
22
18
|
*/
|
|
@@ -26,11 +22,6 @@ export type ChartsLegendProps = {
|
|
|
26
22
|
* @default false
|
|
27
23
|
*/
|
|
28
24
|
hidden?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* The direction of the legend layout.
|
|
31
|
-
* The default depends on the chart.
|
|
32
|
-
*/
|
|
33
|
-
direction?: Direction;
|
|
34
25
|
/**
|
|
35
26
|
* Overridable component slots.
|
|
36
27
|
* @default {}
|
|
@@ -41,7 +32,7 @@ export type ChartsLegendProps = {
|
|
|
41
32
|
* @default {}
|
|
42
33
|
*/
|
|
43
34
|
slotProps?: ChartsLegendSlotProps;
|
|
44
|
-
}
|
|
35
|
+
}
|
|
45
36
|
declare function ChartsLegend(inProps: ChartsLegendProps): React.JSX.Element;
|
|
46
37
|
declare namespace ChartsLegend {
|
|
47
38
|
var propTypes: any;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ContinuousScaleName } from '../models/axis';
|
|
3
|
+
import { ChartsTextProps } from '../ChartsText';
|
|
4
|
+
import { ColorLegendSelector, LegendPlacement } from './legend.types';
|
|
5
|
+
type LabelFormatter = (params: {
|
|
6
|
+
value: number | Date;
|
|
7
|
+
formattedValue: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
export interface ContinuousColorLegendProps extends LegendPlacement, ColorLegendSelector {
|
|
10
|
+
/**
|
|
11
|
+
* The label to display at the minimum side of the gradient.
|
|
12
|
+
* Can either be a string, or a function.
|
|
13
|
+
* @default ({ formattedValue }) => formattedValue
|
|
14
|
+
*/
|
|
15
|
+
minLabel?: string | LabelFormatter;
|
|
16
|
+
/**
|
|
17
|
+
* The label to display at the maximum side of the gradient.
|
|
18
|
+
* Can either be a string, or a function.
|
|
19
|
+
* If not defined, the formatted maximal value is display.
|
|
20
|
+
* @default ({ formattedValue }) => formattedValue
|
|
21
|
+
*/
|
|
22
|
+
maxLabel?: string | LabelFormatter;
|
|
23
|
+
/**
|
|
24
|
+
* A unique identifier for the gradient.
|
|
25
|
+
* @default auto-generated id
|
|
26
|
+
*/
|
|
27
|
+
id?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The scale used to display gradient colors.
|
|
30
|
+
* @default 'linear'
|
|
31
|
+
*/
|
|
32
|
+
scaleType?: ContinuousScaleName;
|
|
33
|
+
/**
|
|
34
|
+
* The length of the gradient bar.
|
|
35
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
36
|
+
* The '100%' is the length of the svg.
|
|
37
|
+
* @default '50%'
|
|
38
|
+
*/
|
|
39
|
+
length?: number | string;
|
|
40
|
+
/**
|
|
41
|
+
* The thickness of the gradient bar.
|
|
42
|
+
* @default 5
|
|
43
|
+
*/
|
|
44
|
+
thickness?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The alignment of the texts with the gradient bar.
|
|
47
|
+
* @default 'middle'
|
|
48
|
+
*/
|
|
49
|
+
align?: 'start' | 'middle' | 'end';
|
|
50
|
+
/**
|
|
51
|
+
* The space between the gradient bar and the labels.
|
|
52
|
+
* @default 4
|
|
53
|
+
*/
|
|
54
|
+
spacing?: number;
|
|
55
|
+
/**
|
|
56
|
+
* The style applied to labels.
|
|
57
|
+
* @default theme.typography.subtitle1
|
|
58
|
+
*/
|
|
59
|
+
labelStyle?: ChartsTextProps['style'];
|
|
60
|
+
}
|
|
61
|
+
declare function ContinuousColorLegend(props: ContinuousColorLegendProps): React.JSX.Element | null;
|
|
62
|
+
declare namespace ContinuousColorLegend {
|
|
63
|
+
var propTypes: any;
|
|
64
|
+
}
|
|
65
|
+
export { ContinuousColorLegend };
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ContinuousColorLegend = ContinuousColorLegend;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _ChartsContinuousGradient = _interopRequireDefault(require("../internals/components/ChartsAxesGradients/ChartsContinuousGradient"));
|
|
13
|
+
var _hooks = require("../hooks");
|
|
14
|
+
var _getScale = require("../internals/getScale");
|
|
15
|
+
var _getPercentageValue = require("../internals/getPercentageValue");
|
|
16
|
+
var _ChartsText = require("../ChartsText");
|
|
17
|
+
var _domUtils = require("../internals/domUtils");
|
|
18
|
+
var _useAxis = require("./useAxis");
|
|
19
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
function getPositionOffset(position, legendBox, svgBox) {
|
|
23
|
+
let offsetX = 0;
|
|
24
|
+
let offsetY = 0;
|
|
25
|
+
switch (position.horizontal) {
|
|
26
|
+
case 'left':
|
|
27
|
+
offsetX = 0;
|
|
28
|
+
break;
|
|
29
|
+
case 'middle':
|
|
30
|
+
offsetX = (svgBox.width - legendBox.width) / 2;
|
|
31
|
+
break;
|
|
32
|
+
case 'right':
|
|
33
|
+
default:
|
|
34
|
+
offsetX = svgBox.width - legendBox.width;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
switch (position.vertical) {
|
|
38
|
+
case 'top':
|
|
39
|
+
offsetY = 0;
|
|
40
|
+
break;
|
|
41
|
+
case 'middle':
|
|
42
|
+
offsetY = (svgBox.height - legendBox.height) / 2;
|
|
43
|
+
break;
|
|
44
|
+
case 'bottom':
|
|
45
|
+
default:
|
|
46
|
+
offsetY = svgBox.height - legendBox.height;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
offsetX,
|
|
51
|
+
offsetY
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Takes placement parameters and element bounding boxes.
|
|
57
|
+
* Returns the x, y coordinates of the elements. And the textAnchor, dominantBaseline for texts.
|
|
58
|
+
*/
|
|
59
|
+
function getElementPositions(text1Box, barBox, text2Box, params) {
|
|
60
|
+
if (params.direction === 'column') {
|
|
61
|
+
const text1 = {
|
|
62
|
+
y: text1Box.height,
|
|
63
|
+
dominantBaseline: 'auto'
|
|
64
|
+
};
|
|
65
|
+
const text2 = {
|
|
66
|
+
y: text1Box.height + 2 * params.spacing + barBox.height,
|
|
67
|
+
dominantBaseline: 'hanging'
|
|
68
|
+
};
|
|
69
|
+
const bar = {
|
|
70
|
+
y: text1Box.height + params.spacing
|
|
71
|
+
};
|
|
72
|
+
const totalWidth = Math.max(text1Box.width, barBox.width, text2Box.width);
|
|
73
|
+
const totalHeight = text1Box.height + barBox.height + text2Box.height + 2 * params.spacing;
|
|
74
|
+
const boundingBox = {
|
|
75
|
+
width: totalWidth,
|
|
76
|
+
height: totalHeight
|
|
77
|
+
};
|
|
78
|
+
switch (params.align) {
|
|
79
|
+
case 'start':
|
|
80
|
+
return {
|
|
81
|
+
text1: (0, _extends2.default)({}, text1, {
|
|
82
|
+
textAnchor: 'start',
|
|
83
|
+
x: 0
|
|
84
|
+
}),
|
|
85
|
+
text2: (0, _extends2.default)({}, text2, {
|
|
86
|
+
textAnchor: 'start',
|
|
87
|
+
x: 0
|
|
88
|
+
}),
|
|
89
|
+
bar: (0, _extends2.default)({}, bar, {
|
|
90
|
+
x: 0
|
|
91
|
+
}),
|
|
92
|
+
boundingBox
|
|
93
|
+
};
|
|
94
|
+
case 'end':
|
|
95
|
+
return {
|
|
96
|
+
text1: (0, _extends2.default)({}, text1, {
|
|
97
|
+
textAnchor: 'end',
|
|
98
|
+
x: totalWidth
|
|
99
|
+
}),
|
|
100
|
+
text2: (0, _extends2.default)({}, text2, {
|
|
101
|
+
textAnchor: 'end',
|
|
102
|
+
x: totalWidth
|
|
103
|
+
}),
|
|
104
|
+
bar: (0, _extends2.default)({}, bar, {
|
|
105
|
+
x: totalWidth - barBox.width
|
|
106
|
+
}),
|
|
107
|
+
boundingBox
|
|
108
|
+
};
|
|
109
|
+
case 'middle':
|
|
110
|
+
default:
|
|
111
|
+
return {
|
|
112
|
+
text1: (0, _extends2.default)({}, text1, {
|
|
113
|
+
textAnchor: 'middle',
|
|
114
|
+
x: totalWidth / 2
|
|
115
|
+
}),
|
|
116
|
+
text2: (0, _extends2.default)({}, text2, {
|
|
117
|
+
textAnchor: 'middle',
|
|
118
|
+
x: totalWidth / 2
|
|
119
|
+
}),
|
|
120
|
+
bar: (0, _extends2.default)({}, bar, {
|
|
121
|
+
x: totalWidth / 2 - barBox.width / 2
|
|
122
|
+
}),
|
|
123
|
+
boundingBox
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
const text1 = {
|
|
128
|
+
x: text1Box.width,
|
|
129
|
+
textAnchor: 'end'
|
|
130
|
+
};
|
|
131
|
+
const text2 = {
|
|
132
|
+
x: text1Box.width + 2 * params.spacing + barBox.width,
|
|
133
|
+
textAnchor: 'start'
|
|
134
|
+
};
|
|
135
|
+
const bar = {
|
|
136
|
+
x: text1Box.width + params.spacing
|
|
137
|
+
};
|
|
138
|
+
const totalHeight = Math.max(text1Box.height, barBox.height, text2Box.height);
|
|
139
|
+
const totalWidth = text1Box.width + barBox.width + text2Box.width + 2 * params.spacing;
|
|
140
|
+
const boundingBox = {
|
|
141
|
+
width: totalWidth,
|
|
142
|
+
height: totalHeight
|
|
143
|
+
};
|
|
144
|
+
switch (params.align) {
|
|
145
|
+
case 'start':
|
|
146
|
+
return {
|
|
147
|
+
text1: (0, _extends2.default)({}, text1, {
|
|
148
|
+
dominantBaseline: 'hanging',
|
|
149
|
+
y: 0
|
|
150
|
+
}),
|
|
151
|
+
text2: (0, _extends2.default)({}, text2, {
|
|
152
|
+
dominantBaseline: 'hanging',
|
|
153
|
+
y: 0
|
|
154
|
+
}),
|
|
155
|
+
bar: (0, _extends2.default)({}, bar, {
|
|
156
|
+
y: 0
|
|
157
|
+
}),
|
|
158
|
+
boundingBox
|
|
159
|
+
};
|
|
160
|
+
case 'end':
|
|
161
|
+
return {
|
|
162
|
+
text1: (0, _extends2.default)({}, text1, {
|
|
163
|
+
dominantBaseline: 'auto',
|
|
164
|
+
y: totalHeight
|
|
165
|
+
}),
|
|
166
|
+
text2: (0, _extends2.default)({}, text2, {
|
|
167
|
+
dominantBaseline: 'auto',
|
|
168
|
+
y: totalHeight
|
|
169
|
+
}),
|
|
170
|
+
bar: (0, _extends2.default)({}, bar, {
|
|
171
|
+
y: totalHeight - barBox.height
|
|
172
|
+
}),
|
|
173
|
+
boundingBox
|
|
174
|
+
};
|
|
175
|
+
case 'middle':
|
|
176
|
+
default:
|
|
177
|
+
return {
|
|
178
|
+
text1: (0, _extends2.default)({}, text1, {
|
|
179
|
+
dominantBaseline: 'central',
|
|
180
|
+
y: totalHeight / 2
|
|
181
|
+
}),
|
|
182
|
+
text2: (0, _extends2.default)({}, text2, {
|
|
183
|
+
dominantBaseline: 'central',
|
|
184
|
+
y: totalHeight / 2
|
|
185
|
+
}),
|
|
186
|
+
bar: (0, _extends2.default)({}, bar, {
|
|
187
|
+
y: totalHeight / 2 - barBox.height / 2
|
|
188
|
+
}),
|
|
189
|
+
boundingBox
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const defaultLabelFormatter = ({
|
|
195
|
+
formattedValue
|
|
196
|
+
}) => formattedValue;
|
|
197
|
+
function ContinuousColorLegend(props) {
|
|
198
|
+
const theme = (0, _styles.useTheme)();
|
|
199
|
+
const {
|
|
200
|
+
id: idProp,
|
|
201
|
+
minLabel = defaultLabelFormatter,
|
|
202
|
+
maxLabel = defaultLabelFormatter,
|
|
203
|
+
scaleType = 'linear',
|
|
204
|
+
direction,
|
|
205
|
+
length = '50%',
|
|
206
|
+
thickness = 5,
|
|
207
|
+
spacing = 4,
|
|
208
|
+
align = 'middle',
|
|
209
|
+
labelStyle = theme.typography.subtitle1,
|
|
210
|
+
position,
|
|
211
|
+
axisDirection,
|
|
212
|
+
axisId
|
|
213
|
+
} = props;
|
|
214
|
+
const chartId = (0, _hooks.useChartId)();
|
|
215
|
+
const id = idProp ?? `gradient-legend-${chartId}`;
|
|
216
|
+
const isRTL = theme.direction === 'rtl';
|
|
217
|
+
const axisItem = (0, _useAxis.useAxis)({
|
|
218
|
+
axisDirection,
|
|
219
|
+
axisId
|
|
220
|
+
});
|
|
221
|
+
const {
|
|
222
|
+
width,
|
|
223
|
+
height,
|
|
224
|
+
left,
|
|
225
|
+
right,
|
|
226
|
+
top,
|
|
227
|
+
bottom
|
|
228
|
+
} = (0, _hooks.useDrawingArea)();
|
|
229
|
+
const refLength = direction === 'column' ? height + top + bottom : width + left + right;
|
|
230
|
+
const size = (0, _getPercentageValue.getPercentageValue)(length, refLength);
|
|
231
|
+
const isReversed = direction === 'column';
|
|
232
|
+
const colorMap = axisItem?.colorMap;
|
|
233
|
+
if (!colorMap || !colorMap.type || colorMap.type !== 'continuous') {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Define the coordinate to color mapping
|
|
238
|
+
|
|
239
|
+
const colorScale = axisItem.colorScale;
|
|
240
|
+
const minValue = colorMap.min ?? 0;
|
|
241
|
+
const maxValue = colorMap.max ?? 100;
|
|
242
|
+
const scale = (0, _getScale.getScale)(scaleType, [minValue, maxValue], isReversed ? [size, 0] : [0, size]);
|
|
243
|
+
|
|
244
|
+
// Get texts to display
|
|
245
|
+
|
|
246
|
+
const formattedMin = axisItem.valueFormatter?.(minValue, {
|
|
247
|
+
location: 'legend'
|
|
248
|
+
}) ?? minValue.toLocaleString();
|
|
249
|
+
const formattedMax = axisItem.valueFormatter?.(maxValue, {
|
|
250
|
+
location: 'legend'
|
|
251
|
+
}) ?? maxValue.toLocaleString();
|
|
252
|
+
const minText = typeof minLabel === 'string' ? minLabel : minLabel({
|
|
253
|
+
value: minValue ?? 0,
|
|
254
|
+
formattedValue: formattedMin
|
|
255
|
+
});
|
|
256
|
+
const maxText = typeof maxLabel === 'string' ? maxLabel : maxLabel({
|
|
257
|
+
value: maxValue ?? 0,
|
|
258
|
+
formattedValue: formattedMax
|
|
259
|
+
});
|
|
260
|
+
const text1 = isReversed ? maxText : minText;
|
|
261
|
+
const text2 = isReversed ? minText : maxText;
|
|
262
|
+
const text1Box = (0, _domUtils.getStringSize)(text1, (0, _extends2.default)({}, labelStyle));
|
|
263
|
+
const text2Box = (0, _domUtils.getStringSize)(text2, (0, _extends2.default)({}, labelStyle));
|
|
264
|
+
|
|
265
|
+
// Place bar and texts
|
|
266
|
+
|
|
267
|
+
const barBox = direction === 'column' || isRTL && direction === 'row' ? {
|
|
268
|
+
width: thickness,
|
|
269
|
+
height: size
|
|
270
|
+
} : {
|
|
271
|
+
width: size,
|
|
272
|
+
height: thickness
|
|
273
|
+
};
|
|
274
|
+
const legendPositions = getElementPositions(text1Box, barBox, text2Box, {
|
|
275
|
+
spacing,
|
|
276
|
+
align,
|
|
277
|
+
direction
|
|
278
|
+
});
|
|
279
|
+
const svgBoundingBox = {
|
|
280
|
+
width: width + left + right,
|
|
281
|
+
height: height + top + bottom
|
|
282
|
+
};
|
|
283
|
+
const positionOffset = getPositionOffset((0, _extends2.default)({
|
|
284
|
+
horizontal: 'middle',
|
|
285
|
+
vertical: 'top'
|
|
286
|
+
}, position), legendPositions.boundingBox, svgBoundingBox);
|
|
287
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
288
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsContinuousGradient.default, {
|
|
289
|
+
isReversed: isReversed,
|
|
290
|
+
gradientId: id,
|
|
291
|
+
size: size,
|
|
292
|
+
direction: direction === 'row' ? 'x' : 'y',
|
|
293
|
+
scale: scale,
|
|
294
|
+
colorScale: colorScale,
|
|
295
|
+
colorMap: colorMap,
|
|
296
|
+
gradientUnits: "objectBoundingBox"
|
|
297
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, {
|
|
298
|
+
text: text1,
|
|
299
|
+
x: positionOffset.offsetX + legendPositions.text1.x,
|
|
300
|
+
y: positionOffset.offsetY + legendPositions.text1.y,
|
|
301
|
+
style: (0, _extends2.default)({
|
|
302
|
+
dominantBaseline: legendPositions.text1.dominantBaseline,
|
|
303
|
+
textAnchor: legendPositions.text1.textAnchor
|
|
304
|
+
}, labelStyle)
|
|
305
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({
|
|
306
|
+
x: positionOffset.offsetX + legendPositions.bar.x,
|
|
307
|
+
y: positionOffset.offsetY + legendPositions.bar.y
|
|
308
|
+
}, barBox, {
|
|
309
|
+
fill: `url(#${id})`
|
|
310
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, {
|
|
311
|
+
text: text2,
|
|
312
|
+
x: positionOffset.offsetX + legendPositions.text2.x,
|
|
313
|
+
y: positionOffset.offsetY + legendPositions.text2.y,
|
|
314
|
+
style: (0, _extends2.default)({
|
|
315
|
+
dominantBaseline: legendPositions.text2.dominantBaseline,
|
|
316
|
+
textAnchor: legendPositions.text2.textAnchor
|
|
317
|
+
}, labelStyle)
|
|
318
|
+
})]
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
process.env.NODE_ENV !== "production" ? ContinuousColorLegend.propTypes = {
|
|
322
|
+
// ----------------------------- Warning --------------------------------
|
|
323
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
324
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
325
|
+
// ----------------------------------------------------------------------
|
|
326
|
+
/**
|
|
327
|
+
* The alignment of the texts with the gradient bar.
|
|
328
|
+
* @default 'middle'
|
|
329
|
+
*/
|
|
330
|
+
align: _propTypes.default.oneOf(['end', 'middle', 'start']),
|
|
331
|
+
/**
|
|
332
|
+
* The axis direction containing the color configuration to represent.
|
|
333
|
+
* @default 'z'
|
|
334
|
+
*/
|
|
335
|
+
axisDirection: _propTypes.default.oneOf(['x', 'y', 'z']),
|
|
336
|
+
/**
|
|
337
|
+
* The id of the axis item with the color configuration to represent.
|
|
338
|
+
* @default The first axis item.
|
|
339
|
+
*/
|
|
340
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
341
|
+
/**
|
|
342
|
+
* The direction of the legend layout.
|
|
343
|
+
* The default depends on the chart.
|
|
344
|
+
*/
|
|
345
|
+
direction: _propTypes.default.oneOf(['column', 'row']),
|
|
346
|
+
/**
|
|
347
|
+
* A unique identifier for the gradient.
|
|
348
|
+
* @default auto-generated id
|
|
349
|
+
*/
|
|
350
|
+
id: _propTypes.default.string,
|
|
351
|
+
/**
|
|
352
|
+
* The style applied to labels.
|
|
353
|
+
* @default theme.typography.subtitle1
|
|
354
|
+
*/
|
|
355
|
+
labelStyle: _propTypes.default.object,
|
|
356
|
+
/**
|
|
357
|
+
* The length of the gradient bar.
|
|
358
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
359
|
+
* The '100%' is the length of the svg.
|
|
360
|
+
* @default '50%'
|
|
361
|
+
*/
|
|
362
|
+
length: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
363
|
+
/**
|
|
364
|
+
* The label to display at the maximum side of the gradient.
|
|
365
|
+
* Can either be a string, or a function.
|
|
366
|
+
* If not defined, the formatted maximal value is display.
|
|
367
|
+
* @default ({ formattedValue }) => formattedValue
|
|
368
|
+
*/
|
|
369
|
+
maxLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
|
370
|
+
/**
|
|
371
|
+
* The label to display at the minimum side of the gradient.
|
|
372
|
+
* Can either be a string, or a function.
|
|
373
|
+
* @default ({ formattedValue }) => formattedValue
|
|
374
|
+
*/
|
|
375
|
+
minLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
|
376
|
+
/**
|
|
377
|
+
* The position of the legend.
|
|
378
|
+
*/
|
|
379
|
+
position: _propTypes.default.shape({
|
|
380
|
+
horizontal: _propTypes.default.oneOf(['left', 'middle', 'right']).isRequired,
|
|
381
|
+
vertical: _propTypes.default.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
382
|
+
}),
|
|
383
|
+
/**
|
|
384
|
+
* The scale used to display gradient colors.
|
|
385
|
+
* @default 'linear'
|
|
386
|
+
*/
|
|
387
|
+
scaleType: _propTypes.default.oneOf(['linear', 'log', 'pow', 'sqrt', 'time', 'utc']),
|
|
388
|
+
/**
|
|
389
|
+
* The space between the gradient bar and the labels.
|
|
390
|
+
* @default 4
|
|
391
|
+
*/
|
|
392
|
+
spacing: _propTypes.default.number,
|
|
393
|
+
/**
|
|
394
|
+
* The thickness of the gradient bar.
|
|
395
|
+
* @default 5
|
|
396
|
+
*/
|
|
397
|
+
thickness: _propTypes.default.number
|
|
398
|
+
} : void 0;
|
|
@@ -1,59 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { DrawingArea } from '../context/DrawingProvider';
|
|
3
|
-
import { AnchorPosition, Direction } from './utils';
|
|
4
2
|
import { FormattedSeries } from '../context/SeriesContextProvider';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { CardinalDirections } from '../models/layout';
|
|
9
|
-
import type { ChartsLegendProps } from './ChartsLegend';
|
|
10
|
-
export type ChartsLegendRootOwnerState = {
|
|
11
|
-
position: AnchorPosition;
|
|
12
|
-
direction: Direction;
|
|
13
|
-
drawingArea: DrawingArea;
|
|
14
|
-
offsetX?: number;
|
|
15
|
-
offsetY?: number;
|
|
16
|
-
seriesNumber: number;
|
|
17
|
-
};
|
|
18
|
-
export declare const ChartsLegendRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.SVGProps<SVGGElement>, keyof React.SVGProps<SVGGElement>>, {}>;
|
|
19
|
-
export interface LegendRendererProps extends DefaultizedProps<Omit<ChartsLegendProps, 'slots' | 'slotProps'>, 'direction' | 'position'> {
|
|
3
|
+
import { LegendPerItemProps } from './LegendPerItem';
|
|
4
|
+
import { DrawingArea } from '../context/DrawingProvider';
|
|
5
|
+
export interface LegendRendererProps extends Omit<LegendPerItemProps, 'itemsToDisplay'> {
|
|
20
6
|
series: FormattedSeries;
|
|
21
|
-
seriesToDisplay:
|
|
22
|
-
drawingArea: DrawingArea;
|
|
23
|
-
classes: Record<'mark' | 'series' | 'root', string>;
|
|
24
|
-
/**
|
|
25
|
-
* Style applied to legend labels.
|
|
26
|
-
* @default theme.typography.subtitle1
|
|
27
|
-
*/
|
|
28
|
-
labelStyle?: ChartsTextStyle;
|
|
29
|
-
/**
|
|
30
|
-
* Width of the item mark (in px).
|
|
31
|
-
* @default 20
|
|
32
|
-
*/
|
|
33
|
-
itemMarkWidth?: number;
|
|
34
|
-
/**
|
|
35
|
-
* Height of the item mark (in px).
|
|
36
|
-
* @default 20
|
|
37
|
-
*/
|
|
38
|
-
itemMarkHeight?: number;
|
|
39
|
-
/**
|
|
40
|
-
* Space between the mark and the label (in px).
|
|
41
|
-
* @default 5
|
|
42
|
-
*/
|
|
43
|
-
markGap?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Space between two legend items (in px).
|
|
46
|
-
* @default 10
|
|
47
|
-
*/
|
|
48
|
-
itemGap?: number;
|
|
7
|
+
seriesToDisplay: LegendPerItemProps['itemsToDisplay'];
|
|
49
8
|
/**
|
|
50
|
-
*
|
|
51
|
-
* Can either be a single number, or an object with top, left, bottom, right properties.
|
|
52
|
-
* @default 10
|
|
9
|
+
* @deprecated Use the `useDrawingArea` hook instead.
|
|
53
10
|
*/
|
|
54
|
-
|
|
11
|
+
drawingArea: Omit<DrawingArea, 'isPointInside'>;
|
|
55
12
|
}
|
|
56
|
-
declare function DefaultChartsLegend(props: LegendRendererProps): React.JSX.Element
|
|
13
|
+
declare function DefaultChartsLegend(props: LegendRendererProps): React.JSX.Element;
|
|
57
14
|
declare namespace DefaultChartsLegend {
|
|
58
15
|
var propTypes: any;
|
|
59
16
|
}
|