- Updated to use configurable gaugeHeader, gaugeSubheader and containerHeight etc
This commit is contained in:
1 parent
f4f863e60f
commit
a2d31124ff
3 files changed
+21
-23
No files matched your search
@@ -7,12 +7,21 @@ const commonRadialBarProps = {
|
|||||||
minAngle: 15,
|
minAngle: 15,
|
||||||
clockWise: true,
|
clockWise: true,
|
||||||
dataKey: "value",
|
dataKey: "value",
|
||||||
cornerRadius: 0
|
cornerRadius: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Gauge = ({ progressValue, displayText, theme }) => {
|
const Gauge = ({
|
||||||
|
progressValue,
|
||||||
|
displayText,
|
||||||
|
theme,
|
||||||
|
containerHeight,
|
||||||
|
gaugeHeader,
|
||||||
|
gaugeSubheader,
|
||||||
|
}) => {
|
||||||
|
const header = gaugeHeader ?? { fontSize: "11px" };
|
||||||
|
const subheader = gaugeSubheader ?? { fontSize: "9px" };
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer>
|
<ResponsiveContainer height={containerHeight ?? 160}>
|
||||||
<RadialBarChart
|
<RadialBarChart
|
||||||
cx="50%"
|
cx="50%"
|
||||||
cy="50%"
|
cy="50%"
|
||||||
@@ -45,14 +54,14 @@ const Gauge = ({ progressValue, displayText, theme }) => {
|
|||||||
<text
|
<text
|
||||||
x="50%"
|
x="50%"
|
||||||
y="45%"
|
y="45%"
|
||||||
style={theme.palette.gaugePercentageText}
|
style={{ ...theme.palette.gaugeHeaderCommon, ...header }}
|
||||||
>
|
>
|
||||||
{`${progressValue}%`}
|
{`${progressValue}%`}
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text
|
||||||
x="50%"
|
x="50%"
|
||||||
y="55%"
|
y="55%"
|
||||||
style={theme.palette.gaugeDisplayText}
|
style={{ ...theme.palette.gaugeHeaderCommon, ...subheader }}
|
||||||
>
|
>
|
||||||
{`${displayText}`}
|
{`${displayText}`}
|
||||||
</text>
|
</text>
|
||||||
@@ -65,5 +74,8 @@ Gauge.propTypes = {
|
|||||||
progressValue: PropTypes.number.isRequired,
|
progressValue: PropTypes.number.isRequired,
|
||||||
displayText: PropTypes.string.isRequired,
|
displayText: PropTypes.string.isRequired,
|
||||||
theme: PropTypes.object.isRequired,
|
theme: PropTypes.object.isRequired,
|
||||||
|
containerHeight: PropTypes.number,
|
||||||
|
gaugeHeader: PropTypes.object,
|
||||||
|
gaugeSubheader: PropTypes.object,
|
||||||
};
|
};
|
||||||
export default Gauge;
|
export default Gauge;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { createTheme } from "@mui/material";
|
import { createTheme } from "@mui/material";
|
||||||
import { gaugeText } from "./lightTheme"
|
import { gaugeHeaderCommon } from "./lightTheme"
|
||||||
|
export { gaugeHeaderCommon }
|
||||||
|
|
||||||
const text = {
|
const text = {
|
||||||
primary: "#fafafa",
|
primary: "#fafafa",
|
||||||
@@ -35,14 +36,6 @@ const darkTheme = createTheme({
|
|||||||
primary: { main: "#1570ef" },
|
primary: { main: "#1570ef" },
|
||||||
secondary: { main: "#2D2D33" },
|
secondary: { main: "#2D2D33" },
|
||||||
text: text,
|
text: text,
|
||||||
gaugePercentageText: {
|
|
||||||
...gaugeText,
|
|
||||||
fontSize: "11px"
|
|
||||||
},
|
|
||||||
gaugeDisplayText: {
|
|
||||||
...gaugeText,
|
|
||||||
fontSize: "9px"
|
|
||||||
},
|
|
||||||
background: background,
|
background: background,
|
||||||
border: border,
|
border: border,
|
||||||
info: {
|
info: {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const background = {
|
|||||||
accent: "#f9fafb",
|
accent: "#f9fafb",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const gaugeText = {
|
export const gaugeHeaderCommon = {
|
||||||
fontWeight: 400,
|
fontWeight: 400,
|
||||||
fill: text.tertiary,
|
fill: text.tertiary,
|
||||||
textAnchor: "middle",
|
textAnchor: "middle",
|
||||||
@@ -40,14 +40,7 @@ const lightTheme = createTheme({
|
|||||||
primary: { main: "#1570EF" },
|
primary: { main: "#1570EF" },
|
||||||
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
|
secondary: { main: "#F4F4F4", dark: "#e3e3e3", contrastText: "#475467" },
|
||||||
text: text,
|
text: text,
|
||||||
gaugePercentageText: {
|
gaugeHeaderCommon: gaugeHeaderCommon,
|
||||||
...gaugeText,
|
|
||||||
fontSize: "11px"
|
|
||||||
},
|
|
||||||
gaugeDisplayText: {
|
|
||||||
...gaugeText,
|
|
||||||
fontSize: "9px"
|
|
||||||
},
|
|
||||||
background: background,
|
background: background,
|
||||||
border: border,
|
border: border,
|
||||||
info: {
|
info: {
|
||||||
|
|||||||
Reference in new issue
Block a user