@mantine/charts 7.4.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/README.md +21 -0
- package/cjs/AreaChart/AreaChart.cjs +295 -0
- package/cjs/AreaChart/AreaChart.cjs.map +1 -0
- package/cjs/AreaChart/AreaGradient.cjs +12 -0
- package/cjs/AreaChart/AreaGradient.cjs.map +1 -0
- package/cjs/AreaChart/AreaSplit.cjs +28 -0
- package/cjs/AreaChart/AreaSplit.cjs.map +1 -0
- package/cjs/AreaChart/get-split-offset.cjs +25 -0
- package/cjs/AreaChart/get-split-offset.cjs.map +1 -0
- package/cjs/BarChart/BarChart.cjs +231 -0
- package/cjs/BarChart/BarChart.cjs.map +1 -0
- package/cjs/ChartLegend/ChartLegend.cjs +65 -0
- package/cjs/ChartLegend/ChartLegend.cjs.map +1 -0
- package/cjs/ChartLegend/ChartLegend.module.css.cjs +7 -0
- package/cjs/ChartLegend/ChartLegend.module.css.cjs.map +1 -0
- package/cjs/ChartTooltip/ChartTooltip.cjs +44 -0
- package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -0
- package/cjs/ChartTooltip/ChartTooltip.module.css.cjs +7 -0
- package/cjs/ChartTooltip/ChartTooltip.module.css.cjs.map +1 -0
- package/cjs/LineChart/LineChart.cjs +220 -0
- package/cjs/LineChart/LineChart.cjs.map +1 -0
- package/cjs/Sparkline/Sparkline.cjs +78 -0
- package/cjs/Sparkline/Sparkline.cjs.map +1 -0
- package/cjs/grid-chart.module.css.cjs +7 -0
- package/cjs/grid-chart.module.css.cjs.map +1 -0
- package/cjs/index.cjs +24 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/AreaChart/AreaChart.mjs +293 -0
- package/esm/AreaChart/AreaChart.mjs.map +1 -0
- package/esm/AreaChart/AreaGradient.mjs +10 -0
- package/esm/AreaChart/AreaGradient.mjs.map +1 -0
- package/esm/AreaChart/AreaSplit.mjs +26 -0
- package/esm/AreaChart/AreaSplit.mjs.map +1 -0
- package/esm/AreaChart/get-split-offset.mjs +22 -0
- package/esm/AreaChart/get-split-offset.mjs.map +1 -0
- package/esm/BarChart/BarChart.mjs +229 -0
- package/esm/BarChart/BarChart.mjs.map +1 -0
- package/esm/ChartLegend/ChartLegend.mjs +62 -0
- package/esm/ChartLegend/ChartLegend.mjs.map +1 -0
- package/esm/ChartLegend/ChartLegend.module.css.mjs +5 -0
- package/esm/ChartLegend/ChartLegend.module.css.mjs.map +1 -0
- package/esm/ChartTooltip/ChartTooltip.mjs +41 -0
- package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -0
- package/esm/ChartTooltip/ChartTooltip.module.css.mjs +5 -0
- package/esm/ChartTooltip/ChartTooltip.module.css.mjs.map +1 -0
- package/esm/LineChart/LineChart.mjs +218 -0
- package/esm/LineChart/LineChart.mjs.map +1 -0
- package/esm/Sparkline/Sparkline.mjs +76 -0
- package/esm/Sparkline/Sparkline.mjs.map +1 -0
- package/esm/grid-chart.module.css.mjs +5 -0
- package/esm/grid-chart.module.css.mjs.map +1 -0
- package/esm/index.mjs +9 -0
- package/esm/index.mjs.map +1 -0
- package/lib/AreaChart/AreaChart.d.ts +55 -0
- package/lib/AreaChart/AreaGradient.d.ts +12 -0
- package/lib/AreaChart/AreaSplit.d.ts +13 -0
- package/lib/AreaChart/get-split-offset.d.ts +13 -0
- package/lib/AreaChart/index.d.ts +4 -0
- package/lib/BarChart/BarChart.d.ts +39 -0
- package/lib/BarChart/index.d.ts +2 -0
- package/lib/ChartLegend/ChartLegend.d.ts +18 -0
- package/lib/ChartLegend/index.d.ts +2 -0
- package/lib/ChartTooltip/ChartTooltip.d.ts +22 -0
- package/lib/ChartTooltip/index.d.ts +2 -0
- package/lib/LineChart/LineChart.d.ts +48 -0
- package/lib/LineChart/index.d.ts +2 -0
- package/lib/Sparkline/Sparkline.d.ts +32 -0
- package/lib/Sparkline/index.d.ts +2 -0
- package/lib/index.d.mts +7 -0
- package/lib/index.d.ts +7 -0
- package/lib/types.d.ts +55 -0
- package/package.json +49 -0
- package/styles.css +1 -0
- package/styles.layer.css +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DotProps, LineChart as ReChartsLineChart } from 'recharts';
|
|
3
|
+
import { BoxProps, ElementProps, Factory, StylesApiProps } from '@mantine/core';
|
|
4
|
+
import { ChartLegendStylesNames } from '../ChartLegend';
|
|
5
|
+
import { ChartTooltipStylesNames } from '../ChartTooltip';
|
|
6
|
+
import type { BaseChartStylesNames, ChartSeries, GridChartBaseProps } from '../types';
|
|
7
|
+
export type LineChartCurveType = 'bump' | 'linear' | 'natural' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter';
|
|
8
|
+
export interface LineChartSeries extends ChartSeries {
|
|
9
|
+
strokeDasharray?: string | number;
|
|
10
|
+
}
|
|
11
|
+
export type LineChartStylesNames = 'line' | BaseChartStylesNames | ChartLegendStylesNames | ChartTooltipStylesNames;
|
|
12
|
+
export type LineChartCssVariables = {
|
|
13
|
+
root: '--chart-text-color' | '--chart-grid-color';
|
|
14
|
+
};
|
|
15
|
+
export interface LineChartProps extends BoxProps, GridChartBaseProps, StylesApiProps<LineChartFactory>, ElementProps<'div'> {
|
|
16
|
+
/** Data used to display chart */
|
|
17
|
+
data: Record<string, any>[];
|
|
18
|
+
/** An array of objects with `name` and `color` keys. Determines which data should be consumed from the `data` array. */
|
|
19
|
+
series: LineChartSeries[];
|
|
20
|
+
/** Type of the curve, `'monotone'` by default */
|
|
21
|
+
curveType?: LineChartCurveType;
|
|
22
|
+
/** Controls fill opacity of all lines, `1` by default */
|
|
23
|
+
fillOpacity?: number;
|
|
24
|
+
/** Determines whether dots should be displayed, `true` by default */
|
|
25
|
+
withDots?: boolean;
|
|
26
|
+
/** Props passed down to all dots. Ignored if `withDots={false}` is set. */
|
|
27
|
+
dotProps?: Omit<DotProps, 'ref'>;
|
|
28
|
+
/** Props passed down to all active dots. Ignored if `withDots={false}` is set. */
|
|
29
|
+
activeDotProps?: Omit<DotProps, 'ref'>;
|
|
30
|
+
/** Stroke width for the chart lines, `2` by default */
|
|
31
|
+
strokeWidth?: number;
|
|
32
|
+
/** Props passed down to recharts `LineChart` component */
|
|
33
|
+
lineChartProps?: React.ComponentPropsWithoutRef<typeof ReChartsLineChart>;
|
|
34
|
+
/** Determines whether points with `null` values should be connected, `true` by default */
|
|
35
|
+
connectNulls?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type LineChartFactory = Factory<{
|
|
38
|
+
props: LineChartProps;
|
|
39
|
+
ref: HTMLDivElement;
|
|
40
|
+
stylesNames: LineChartStylesNames;
|
|
41
|
+
vars: LineChartCssVariables;
|
|
42
|
+
}>;
|
|
43
|
+
export declare const LineChart: import("@mantine/core").MantineComponent<{
|
|
44
|
+
props: LineChartProps;
|
|
45
|
+
ref: HTMLDivElement;
|
|
46
|
+
stylesNames: LineChartStylesNames;
|
|
47
|
+
vars: LineChartCssVariables;
|
|
48
|
+
}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BoxProps, ElementProps, Factory, MantineColor, StylesApiProps } from '@mantine/core';
|
|
2
|
+
import { AreaChartCurveType } from '../AreaChart';
|
|
3
|
+
export type SparklineStylesNames = 'root';
|
|
4
|
+
export type SparklineCssVariables = {
|
|
5
|
+
root: '--chart-color';
|
|
6
|
+
};
|
|
7
|
+
export interface SparklineProps extends BoxProps, StylesApiProps<SparklineFactory>, ElementProps<'div'> {
|
|
8
|
+
/** Data used to render the chart */
|
|
9
|
+
data: number[];
|
|
10
|
+
/** Key of `theme.colors` or any valid CSS color, `theme.primaryColor` by default */
|
|
11
|
+
color?: MantineColor;
|
|
12
|
+
/** Determines whether the chart fill should be a gradient, `true` by default */
|
|
13
|
+
withGradient?: boolean;
|
|
14
|
+
/** Controls fill opacity of the area, `0.6` by default */
|
|
15
|
+
fillOpacity?: number;
|
|
16
|
+
/** Type of the curve, `'linear'` by default */
|
|
17
|
+
curveType?: AreaChartCurveType;
|
|
18
|
+
/** Area stroke width, `2` by default */
|
|
19
|
+
strokeWidth?: number;
|
|
20
|
+
}
|
|
21
|
+
export type SparklineFactory = Factory<{
|
|
22
|
+
props: SparklineProps;
|
|
23
|
+
ref: HTMLDivElement;
|
|
24
|
+
stylesNames: SparklineStylesNames;
|
|
25
|
+
vars: SparklineCssVariables;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const Sparkline: import("@mantine/core").MantineComponent<{
|
|
28
|
+
props: SparklineProps;
|
|
29
|
+
ref: HTMLDivElement;
|
|
30
|
+
stylesNames: SparklineStylesNames;
|
|
31
|
+
vars: SparklineCssVariables;
|
|
32
|
+
}>;
|
package/lib/index.d.mts
ADDED
package/lib/index.d.ts
ADDED
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CartesianGridProps, LabelProps, LegendProps, ReferenceLineProps, TooltipProps, XAxisProps, YAxisProps } from 'recharts';
|
|
2
|
+
import type { MantineColor } from '@mantine/core';
|
|
3
|
+
export interface ChartReferenceLineProps extends Omit<ReferenceLineProps, 'ref' | 'label'> {
|
|
4
|
+
color?: MantineColor;
|
|
5
|
+
label?: string;
|
|
6
|
+
labelPosition?: LabelProps['position'];
|
|
7
|
+
}
|
|
8
|
+
export interface ChartSeries {
|
|
9
|
+
name: string;
|
|
10
|
+
color: MantineColor;
|
|
11
|
+
}
|
|
12
|
+
export type BaseChartStylesNames = 'root' | 'container' | 'axis' | 'grid' | 'referenceLine';
|
|
13
|
+
export type ChartData = Record<string, any>[];
|
|
14
|
+
export interface GridChartBaseProps {
|
|
15
|
+
/** Data used to display chart */
|
|
16
|
+
data: ChartData;
|
|
17
|
+
/** Key of the `data` object for x-axis values */
|
|
18
|
+
dataKey: string;
|
|
19
|
+
/** Reference lines that should be displayed on the chart */
|
|
20
|
+
referenceLines?: ChartReferenceLineProps[];
|
|
21
|
+
/** Determines whether x-axis should be hidden, `true` by default */
|
|
22
|
+
withXAxis?: boolean;
|
|
23
|
+
/** Determines whether y-axis should be hidden, `true` by default */
|
|
24
|
+
withYAxis?: boolean;
|
|
25
|
+
/** Props passed down to the `XAxis` recharts component */
|
|
26
|
+
xAxisProps?: Omit<XAxisProps, 'ref'>;
|
|
27
|
+
/** Props passed down to the `YAxis` recharts component */
|
|
28
|
+
yAxisProps?: Omit<YAxisProps, 'ref'>;
|
|
29
|
+
/** Props passed down to the `CartesianGrid` component */
|
|
30
|
+
gridProps?: Omit<CartesianGridProps, 'ref'>;
|
|
31
|
+
/** Specifies which axis should have tick line, `'y'` by default */
|
|
32
|
+
tickLine?: 'x' | 'y' | 'xy' | 'none';
|
|
33
|
+
/** Dash array for the grid lines and cursor, `'5 5'` by default */
|
|
34
|
+
strokeDasharray?: string | number;
|
|
35
|
+
/** Specifies which lines should be displayed in the grid, `'x'` by default */
|
|
36
|
+
gridAxis?: 'x' | 'y' | 'xy' | 'none';
|
|
37
|
+
/** Unit displayed next to each tick in y-axis */
|
|
38
|
+
unit?: string;
|
|
39
|
+
/** Tooltip position animation duration in ms, `0` by default */
|
|
40
|
+
tooltipAnimationDuration?: number;
|
|
41
|
+
/** Props passed down to the `Legend` component */
|
|
42
|
+
legendProps?: Omit<LegendProps, 'ref'>;
|
|
43
|
+
/** Props passed down to the `Tooltip` component */
|
|
44
|
+
tooltipProps?: Omit<TooltipProps<any, any>, 'ref'>;
|
|
45
|
+
/** Determines whether chart legend should be displayed, `false` by default */
|
|
46
|
+
withLegend?: boolean;
|
|
47
|
+
/** Determines whether chart tooltip should be displayed, `true` by default */
|
|
48
|
+
withTooltip?: boolean;
|
|
49
|
+
/** Color of the text displayed inside the chart, `'dimmed'` by default */
|
|
50
|
+
textColor?: MantineColor;
|
|
51
|
+
/** Color of the grid and cursor lines, by default depends on color scheme */
|
|
52
|
+
gridColor?: MantineColor;
|
|
53
|
+
/** Chart orientation, `'horizontal'` by default */
|
|
54
|
+
orientation?: 'horizontal' | 'vertical';
|
|
55
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mantine/charts",
|
|
3
|
+
"version": "7.4.0",
|
|
4
|
+
"description": "Charts components built with recharts and Mantine",
|
|
5
|
+
"homepage": "https://mantine.dev/",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Vitaly Rtishchev <rtivital@gmail.com>",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"react",
|
|
10
|
+
"ui"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"*.css"
|
|
14
|
+
],
|
|
15
|
+
"main": "./cjs/index.cjs",
|
|
16
|
+
"module": "./esm/index.mjs",
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./lib/index.d.mts",
|
|
22
|
+
"default": "./esm/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"default": "./cjs/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./styles.css": "./styles.css",
|
|
30
|
+
"./styles.layer.css": "./styles.layer.css"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"url": "https://github.com/mantinedev/mantine.git",
|
|
34
|
+
"type": "git",
|
|
35
|
+
"directory": "packages/@mantine/charts"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@mantine/core": "7.4.0",
|
|
39
|
+
"@mantine/hooks": "7.4.0",
|
|
40
|
+
"react": "^18.2.0",
|
|
41
|
+
"react-dom": "^18.2.0",
|
|
42
|
+
"recharts": "^2.10.3"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@mantine-tests/core": "1.0.1",
|
|
46
|
+
"@mantine/core": "7.4.0",
|
|
47
|
+
"@mantine/hooks": "7.4.0"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.m-e4d36c9b{background-color:var(--mantine-color-body);border-radius:var(--mantine-radius-default);box-shadow:var(--mantine-shadow-md);min-width:calc(12.5rem*var(--mantine-scale))}:where([data-mantine-color-scheme=light]) .m-e4d36c9b{border:calc(.0625rem*var(--mantine-scale)) solid var(--mantine-color-gray-3)}:where([data-mantine-color-scheme=dark]) .m-e4d36c9b{border:calc(.0625rem*var(--mantine-scale)) solid var(--mantine-color-dark-4)}.m-7f4bcb19{color:var(--mantine-color-bright);font-size:var(--mantine-font-size-md);font-weight:500;padding:var(--mantine-spacing-xs) var(--mantine-spacing-md)}.m-3de554dd{padding:var(--mantine-spacing-sm) var(--mantine-spacing-md);padding-top:0}.m-3de8964e{display:flex;font-size:var(--mantine-font-size-sm);justify-content:space-between}.m-3de8964e:where(.m-3de8964e+.m-3de8964e){margin-top:calc(var(--mantine-spacing-sm)/2)}.m-50186d10{align-items:center;display:flex;gap:var(--mantine-spacing-sm);margin-right:var(--mantine-spacing-xl)}.m-501dadf9{color:var(--mantine-color-text);font-size:var(--mantine-font-size-sm)}.m-50192318{color:var(--mantine-color-bright)}.m-847eaf{align-items:center;display:flex;flex-wrap:wrap;height:100%;justify-content:flex-end}.m-847eaf:where([data-position=top]){padding-bottom:var(--mantine-spacing-md)}.m-847eaf:where([data-position=bottom]){padding-top:var(--mantine-spacing-md)}.m-17da7e62{align-items:center;border-radius:var(--mantine-radius-default);display:flex;gap:calc(.4375rem*var(--mantine-scale));line-height:1;padding:calc(.4375rem*var(--mantine-scale)) var(--mantine-spacing-xs)}@media (hover:hover){:where([data-mantine-color-scheme=light]) .m-17da7e62:where(:hover){background-color:var(--mantine-color-gray-0)}:where([data-mantine-color-scheme=dark]) .m-17da7e62:where(:hover){background-color:var(--mantine-color-dark-5)}}@media (hover:none){:where([data-mantine-color-scheme=light]) .m-17da7e62:where(:active){background-color:var(--mantine-color-gray-0)}:where([data-mantine-color-scheme=dark]) .m-17da7e62:where(:active){background-color:var(--mantine-color-dark-5)}}.m-8ff56c0d{font-size:var(--mantine-font-size-sm);margin:0;padding:0}.m-a50f3e58{display:block;width:100%}:where([data-mantine-color-scheme=light]) .m-a50f3e58{--chart-grid-color:rgba(173,181,189,.6);--chart-cursor-fill:rgba(173,181,189,.15)}:where([data-mantine-color-scheme=dark]) .m-a50f3e58{--chart-cursor-fill:hsla(0,0%,41%,.15);--chart-grid-color:hsla(0,0%,41%,.6)}.m-a50f3e58 :where(text){color:var(--chart-text-color,var(--mantine-color-dimmed));font-family:var(--mantine-font-family)}.m-af9188cb{height:100%;width:100%}.m-a50a48bc{stroke:var(--chart-grid-color)}.m-a507a517{color:var(--chart-grid-color)}
|
package/styles.layer.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer mantine {.m-e4d36c9b{background-color:var(--mantine-color-body);border-radius:var(--mantine-radius-default);box-shadow:var(--mantine-shadow-md);min-width:calc(12.5rem*var(--mantine-scale))}:where([data-mantine-color-scheme=light]) .m-e4d36c9b{border:calc(.0625rem*var(--mantine-scale)) solid var(--mantine-color-gray-3)}:where([data-mantine-color-scheme=dark]) .m-e4d36c9b{border:calc(.0625rem*var(--mantine-scale)) solid var(--mantine-color-dark-4)}.m-7f4bcb19{color:var(--mantine-color-bright);font-size:var(--mantine-font-size-md);font-weight:500;padding:var(--mantine-spacing-xs) var(--mantine-spacing-md)}.m-3de554dd{padding:var(--mantine-spacing-sm) var(--mantine-spacing-md);padding-top:0}.m-3de8964e{display:flex;font-size:var(--mantine-font-size-sm);justify-content:space-between}.m-3de8964e:where(.m-3de8964e+.m-3de8964e){margin-top:calc(var(--mantine-spacing-sm)/2)}.m-50186d10{align-items:center;display:flex;gap:var(--mantine-spacing-sm);margin-right:var(--mantine-spacing-xl)}.m-501dadf9{color:var(--mantine-color-text);font-size:var(--mantine-font-size-sm)}.m-50192318{color:var(--mantine-color-bright)}.m-847eaf{align-items:center;display:flex;flex-wrap:wrap;height:100%;justify-content:flex-end}.m-847eaf:where([data-position=top]){padding-bottom:var(--mantine-spacing-md)}.m-847eaf:where([data-position=bottom]){padding-top:var(--mantine-spacing-md)}.m-17da7e62{align-items:center;border-radius:var(--mantine-radius-default);display:flex;gap:calc(.4375rem*var(--mantine-scale));line-height:1;padding:calc(.4375rem*var(--mantine-scale)) var(--mantine-spacing-xs)}@media (hover:hover){:where([data-mantine-color-scheme=light]) .m-17da7e62:where(:hover){background-color:var(--mantine-color-gray-0)}:where([data-mantine-color-scheme=dark]) .m-17da7e62:where(:hover){background-color:var(--mantine-color-dark-5)}}@media (hover:none){:where([data-mantine-color-scheme=light]) .m-17da7e62:where(:active){background-color:var(--mantine-color-gray-0)}:where([data-mantine-color-scheme=dark]) .m-17da7e62:where(:active){background-color:var(--mantine-color-dark-5)}}.m-8ff56c0d{font-size:var(--mantine-font-size-sm);margin:0;padding:0}.m-a50f3e58{display:block;width:100%}:where([data-mantine-color-scheme=light]) .m-a50f3e58{--chart-grid-color:rgba(173,181,189,.6);--chart-cursor-fill:rgba(173,181,189,.15)}:where([data-mantine-color-scheme=dark]) .m-a50f3e58{--chart-cursor-fill:hsla(0,0%,41%,.15);--chart-grid-color:hsla(0,0%,41%,.6)}.m-a50f3e58 :where(text){color:var(--chart-text-color,var(--mantine-color-dimmed));font-family:var(--mantine-font-family)}.m-af9188cb{height:100%;width:100%}.m-a50a48bc{stroke:var(--chart-grid-color)}.m-a507a517{color:var(--chart-grid-color)}}
|