@wavv/ui 2.2.2-alpha.7 → 2.2.2-alpha.8
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/build/components/BarChart.d.ts +1 -1
- package/build/components/BarChart.js +6 -2
- package/build/components/ChartHelpers.d.ts +6 -2
- package/build/components/ChartHelpers.js +8 -1
- package/build/components/LineChart.d.ts +1 -1
- package/build/components/LineChart.js +6 -2
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ type Props = {
|
|
|
25
25
|
/** The width of the Y axis */
|
|
26
26
|
yAxisWidth?: number;
|
|
27
27
|
} & ChartProps;
|
|
28
|
-
declare const BarChart: ({ data, legend, keys, stacked, barGap, barCategoryGap, barSize, maxBarSize, vertical, hideYLabels, hideXLabels, diagonalXLabels, maxXLabelLength, xAxisHeight, yAxisWidth, axisColor, tooltipLegendPostfix, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
declare const BarChart: ({ data, legend, keys, stacked, barGap, barCategoryGap, barSize, maxBarSize, vertical, hideYLabels, hideXLabels, diagonalXLabels, maxXLabelLength, xAxisHeight, yAxisWidth, axisColor, tooltipLegendPostfix, initialDimension, width, height, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
29
29
|
export declare const DiagonalAxisTick: ({ x, y, payload, maxXLabelLength, axisColor, }: {
|
|
30
30
|
x: number;
|
|
31
31
|
y: number;
|
|
@@ -3,21 +3,25 @@ import { useTheme } from "@emotion/react";
|
|
|
3
3
|
import styled from "@emotion/styled";
|
|
4
4
|
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, XAxis, YAxis } from "recharts";
|
|
5
5
|
import { formatNumber } from "../utils/formatNumber.js";
|
|
6
|
-
import { ChartContainer, ChartStyles, LegendContent, Tooltip } from "./ChartHelpers.js";
|
|
7
|
-
const BarChart_BarChart = ({ data, legend, keys, stacked, barGap, barCategoryGap, barSize = 16, maxBarSize, vertical = false, hideYLabels, hideXLabels, diagonalXLabels, maxXLabelLength = 10, xAxisHeight = 22, yAxisWidth = 45, axisColor, tooltipLegendPostfix, ...rest })=>{
|
|
6
|
+
import { ChartContainer, ChartStyles, LegendContent, Tooltip, getInitialDimension } from "./ChartHelpers.js";
|
|
7
|
+
const BarChart_BarChart = ({ data, legend, keys, stacked, barGap, barCategoryGap, barSize = 16, maxBarSize, vertical = false, hideYLabels, hideXLabels, diagonalXLabels, maxXLabelLength = 10, xAxisHeight = 22, yAxisWidth = 45, axisColor, tooltipLegendPostfix, initialDimension, width, height, ...rest })=>{
|
|
8
8
|
const { scale2 } = useTheme();
|
|
9
9
|
const xAxisTick = diagonalXLabels ? (args)=>DiagonalAxisTick({
|
|
10
10
|
...args,
|
|
11
11
|
maxXLabelLength,
|
|
12
12
|
axisColor
|
|
13
13
|
}) : {};
|
|
14
|
+
const initial = getInitialDimension(initialDimension, width, height);
|
|
14
15
|
return /*#__PURE__*/ jsxs(ChartContainer, {
|
|
16
|
+
width: width,
|
|
17
|
+
height: height,
|
|
15
18
|
...rest,
|
|
16
19
|
children: [
|
|
17
20
|
/*#__PURE__*/ jsx(ChartStyles, {}),
|
|
18
21
|
/*#__PURE__*/ jsx(ResponsiveContainer, {
|
|
19
22
|
width: "100%",
|
|
20
23
|
height: "100%",
|
|
24
|
+
initialDimension: initial,
|
|
21
25
|
children: /*#__PURE__*/ jsxs(BarChart, {
|
|
22
26
|
margin: {
|
|
23
27
|
top: 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LegendPayload, type TooltipContentProps } from 'recharts';
|
|
1
|
+
import { type LegendPayload, type TooltipContentProps, type ResponsiveContainerProps } from 'recharts';
|
|
2
2
|
import type { Attributes } from './typeDefs/elementTypes';
|
|
3
3
|
import type { Margin, MaxWidthHeight, WidthHeight } from './types';
|
|
4
4
|
type ChartData = {
|
|
@@ -23,7 +23,11 @@ export type ChartProps = {
|
|
|
23
23
|
axisColor?: string;
|
|
24
24
|
/** The postfix to display after the legend value in the tooltip */
|
|
25
25
|
tooltipLegendPostfix?: React.ReactNode;
|
|
26
|
-
} & Margin & WidthHeight & MaxWidthHeight & ElAttributes;
|
|
26
|
+
} & Pick<ResponsiveContainerProps, 'initialDimension'> & Margin & WidthHeight & MaxWidthHeight & ElAttributes;
|
|
27
|
+
type InitialDimension = ResponsiveContainerProps['initialDimension'];
|
|
28
|
+
type Width = WidthHeight['width'];
|
|
29
|
+
type Height = WidthHeight['height'];
|
|
30
|
+
export declare const getInitialDimension: (initialDimension: InitialDimension, width: Width, height: Height) => InitialDimension;
|
|
27
31
|
export declare const ChartStyles: () => import("react/jsx-runtime").JSX.Element;
|
|
28
32
|
export declare const ChartContainer: import("@emotion/styled").StyledComponent<{
|
|
29
33
|
theme?: import("@emotion/react").Theme;
|
|
@@ -5,6 +5,13 @@ import { Tooltip } from "recharts";
|
|
|
5
5
|
import { numberWithCommas } from "../utils/index.js";
|
|
6
6
|
import Dot from "./Dot.js";
|
|
7
7
|
import { marginProps } from "./helpers/styledProps.js";
|
|
8
|
+
const getInitialDimension = (initialDimension, width, height)=>{
|
|
9
|
+
if (initialDimension) return initialDimension;
|
|
10
|
+
if ('number' == typeof width && 'number' == typeof height) return {
|
|
11
|
+
width,
|
|
12
|
+
height
|
|
13
|
+
};
|
|
14
|
+
};
|
|
8
15
|
const ChartStyles = ()=>/*#__PURE__*/ jsx(Global, {
|
|
9
16
|
styles: {
|
|
10
17
|
'.recharts-cartesian-grid-vertical line:first-of-type': {
|
|
@@ -118,4 +125,4 @@ const TooltipLabel = styled.div(({ theme })=>({
|
|
|
118
125
|
color: theme.tooltip.color.subtext,
|
|
119
126
|
marginBottom: 4
|
|
120
127
|
}));
|
|
121
|
-
export { ChartContainer, ChartStyles, LegendContent, ChartHelpers_Tooltip as Tooltip, TooltipContent };
|
|
128
|
+
export { ChartContainer, ChartStyles, LegendContent, ChartHelpers_Tooltip as Tooltip, TooltipContent, getInitialDimension };
|
|
@@ -2,5 +2,5 @@ import { type ChartProps } from './ChartHelpers';
|
|
|
2
2
|
type Props = {
|
|
3
3
|
enableLegendToggle?: boolean;
|
|
4
4
|
} & ChartProps;
|
|
5
|
-
declare const LineChart: ({ data, legend, keys, enableLegendToggle, axisColor, tooltipLegendPostfix, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const LineChart: ({ data, legend, keys, enableLegendToggle, axisColor, tooltipLegendPostfix, initialDimension, width, height, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default LineChart;
|
|
@@ -3,8 +3,8 @@ import { useTheme } from "@emotion/react";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, XAxis, YAxis } from "recharts";
|
|
5
5
|
import { formatNumber } from "../utils/formatNumber.js";
|
|
6
|
-
import { ChartContainer, ChartStyles, LegendContent, Tooltip } from "./ChartHelpers.js";
|
|
7
|
-
const LineChart_LineChart = ({ data, legend, keys, enableLegendToggle, axisColor, tooltipLegendPostfix, ...rest })=>{
|
|
6
|
+
import { ChartContainer, ChartStyles, LegendContent, Tooltip, getInitialDimension } from "./ChartHelpers.js";
|
|
7
|
+
const LineChart_LineChart = ({ data, legend, keys, enableLegendToggle, axisColor, tooltipLegendPostfix, initialDimension, width, height, ...rest })=>{
|
|
8
8
|
const [lines, setLines] = useState(keys);
|
|
9
9
|
const { scale2 } = useTheme();
|
|
10
10
|
const handleLineToggle = (item)=>{
|
|
@@ -19,13 +19,17 @@ const LineChart_LineChart = ({ data, legend, keys, enableLegendToggle, axisColor
|
|
|
19
19
|
setLines((prevLines)=>toggleLines(prevLines));
|
|
20
20
|
};
|
|
21
21
|
const toggleData = enableLegendToggle && keys.length > 1 ? handleLineToggle : void 0;
|
|
22
|
+
const initial = getInitialDimension(initialDimension, width, height);
|
|
22
23
|
return /*#__PURE__*/ jsxs(ChartContainer, {
|
|
24
|
+
width: width,
|
|
25
|
+
height: height,
|
|
23
26
|
...rest,
|
|
24
27
|
children: [
|
|
25
28
|
/*#__PURE__*/ jsx(ChartStyles, {}),
|
|
26
29
|
/*#__PURE__*/ jsx(ResponsiveContainer, {
|
|
27
30
|
width: "100%",
|
|
28
31
|
height: "100%",
|
|
32
|
+
initialDimension: initial,
|
|
29
33
|
children: /*#__PURE__*/ jsxs(LineChart, {
|
|
30
34
|
margin: {
|
|
31
35
|
top: 8,
|