@campxdev/react-blueprint 1.2.14 → 1.2.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/react-blueprint",
3
- "version": "1.2.14",
3
+ "version": "1.2.15",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -1,4 +1,11 @@
1
- import { Stack, SxProps, useTheme } from '@mui/material';
1
+ import {
2
+ Box,
3
+ Stack,
4
+ styled,
5
+ SxProps,
6
+ useTheme,
7
+ Typography,
8
+ } from '@mui/material';
2
9
  import {
3
10
  Bar,
4
11
  CartesianGrid,
@@ -15,14 +22,18 @@ import {
15
22
  CartesianGridProps,
16
23
  LegendProps,
17
24
  MarginProps,
25
+ SubTitleProps,
18
26
  TitleProps,
19
27
  } from '../types/types';
20
28
  import { LayoutType } from 'recharts/types/util/types';
21
- import { Typography } from '../../export';
29
+ import { StyledContainer } from '../../export';
22
30
 
23
31
  export type BarChartProps = {
24
32
  title?: string;
33
+ showSubtitle?: boolean;
34
+ subTitle?: string;
25
35
  titleProps?: TitleProps;
36
+ subTitleProps?: SubTitleProps;
26
37
  width?: number;
27
38
  height?: number;
28
39
  layout?: LayoutType;
@@ -50,6 +61,9 @@ type BarItem = {
50
61
 
51
62
  export const BarChart = ({
52
63
  title = 'Bar Chart',
64
+ showSubtitle = false,
65
+ subTitle = '',
66
+ subTitleProps = { variant: 'caption' },
53
67
  titleProps = { variant: 'subtitle2' },
54
68
  width = 700,
55
69
  height = 500,
@@ -83,6 +97,15 @@ export const BarChart = ({
83
97
  >
84
98
  {title}
85
99
  </Typography>
100
+ {showSubtitle && (
101
+ <Typography
102
+ variant={subTitleProps.variant}
103
+ align={'center'}
104
+ sx={subTitleProps.sx}
105
+ >
106
+ {title}
107
+ </Typography>
108
+ )}
86
109
  <ReBarChart
87
110
  width={width}
88
111
  height={height}
@@ -97,6 +120,7 @@ export const BarChart = ({
97
120
  )}
98
121
  {showToolTip && (
99
122
  <Tooltip
123
+ content={CustomTooltip}
100
124
  cursor={{ fill: theme.palette.secondary.light, fillOpacity: '50%' }}
101
125
  itemStyle={{
102
126
  color: theme.palette.text.secondary,
@@ -186,3 +210,31 @@ export const BarChart = ({
186
210
  </Stack>
187
211
  );
188
212
  };
213
+
214
+ const CustomTooltip = ({ active, payload }: any) => {
215
+ const theme = useTheme();
216
+ if (active && payload && payload.length) {
217
+ return (
218
+ <StyledContainer>
219
+ <Typography variant="body2">{`${payload[0].payload.name}`}</Typography>
220
+ <Box sx={{ display: 'flex', flexDirection: 'column' }}>
221
+ {payload.map((p: any, index: number) => (
222
+ <Typography variant="caption" key={index}>
223
+ <span>{`${p.name}`}</span>
224
+ <span
225
+ style={{
226
+ fontWeight: 'bold',
227
+ color: theme.palette.text.primary,
228
+ }}
229
+ >
230
+ {'\xa0\xa0' + `${p.value}`}
231
+ </span>
232
+ </Typography>
233
+ ))}
234
+ </Box>
235
+ </StyledContainer>
236
+ );
237
+ }
238
+
239
+ return null;
240
+ };
@@ -22,6 +22,11 @@ export type TitleProps = {
22
22
  sx?: any;
23
23
  };
24
24
 
25
+ export type SubTitleProps = {
26
+ variant?: Variant;
27
+ sx?: any;
28
+ };
29
+
25
30
  export type MarginProps = {
26
31
  top?: number;
27
32
  right?: number;
@@ -7,18 +7,21 @@ import {
7
7
  const data = [
8
8
  {
9
9
  name: 'Page A',
10
+ sub: 'PA',
10
11
  uv: 4000,
11
12
  pv: 2400,
12
13
  amt: 2400,
13
14
  },
14
15
  {
15
16
  name: 'Page B',
17
+ sub: 'PB',
16
18
  uv: 3000,
17
19
  pv: 1398,
18
20
  amt: 2210,
19
21
  },
20
22
  {
21
23
  name: 'Page C',
24
+ sub: 'PC',
22
25
  uv: 2000,
23
26
  pv: 9800,
24
27
  amt: 2290,
@@ -122,7 +125,7 @@ export const Default = {
122
125
  args: {
123
126
  data: data,
124
127
  bars: bars,
125
- dataKey: 'name',
128
+ dataKey: 'sub',
126
129
  containerSx: { width: '800px', height: '800px' },
127
130
  cartesianGrid: { showCartesianGrid: true, size: 5 },
128
131
  axisLabelProps: {