diff --git a/src/qqq/components/widgets/charts/StackedBarChart.tsx b/src/qqq/components/widgets/charts/StackedBarChart.tsx
index f205ce8..4e812f4 100644
--- a/src/qqq/components/widgets/charts/StackedBarChart.tsx
+++ b/src/qqq/components/widgets/charts/StackedBarChart.tsx
@@ -28,6 +28,7 @@ import {Bar} from "react-chartjs-2";
import {useNavigate} from "react-router-dom";
import colors from "qqq/assets/theme/base/colors";
import {chartColors, DefaultChartData} from "qqq/components/widgets/charts/DefaultChartData";
+import ChartSubheaderWithData, {ChartSubheaderData} from "qqq/components/widgets/components/ChartSubheaderWithData";
ChartJS.register(
CategoryScale,
@@ -39,18 +40,32 @@ ChartJS.register(
);
export const options = {
+ maintainAspectRatio: false,
responsive: true,
animation: {
duration: 0
},
+ plugins: {
+ legend: {
+ position: "bottom",
+ labels: {
+ usePointStyle: true,
+ pointStyle: "circle",
+ pointStyleWidth: 3,
+ padding: 20
+ }
+ }
+ },
scales: {
x: {
stacked: true,
- grid: {offset: false},
+ grid: {display: false},
ticks: {autoSkip: false, maxRotation: 90}
},
y: {
stacked: true,
+ position: "right",
+ ticks: {precision: 0}
},
},
};
@@ -58,10 +73,12 @@ export const options = {
interface Props
{
data: DefaultChartData;
+ chartSubheaderData?: ChartSubheaderData;
}
const {gradients} = colors;
-function StackedBarChart({data}: Props): JSX.Element
+
+function StackedBarChart({data, chartSubheaderData}: Props): JSX.Element
{
const navigate = useNavigate();
@@ -70,23 +87,30 @@ function StackedBarChart({data}: Props): JSX.Element
const handleClick = (e: Array<{}>) =>
{
- if(e && e.length > 0 && data?.urls && data?.urls.length)
+ if (e && e.length > 0 && data?.urls && data?.urls.length)
{
// @ts-ignore
navigate(data.urls[e[0]["index"]]);
}
console.log(e);
- }
+ };
useEffect(() =>
{
- if(data)
+ if (data)
{
data?.datasets.forEach((dataset: any, index: number) =>
{
if (!dataset.backgroundColor)
{
- dataset.backgroundColor = gradients[chartColors[index]].state;
+ if (gradients[chartColors[index]])
+ {
+ dataset.backgroundColor = gradients[chartColors[index]].state;
+ }
+ else
+ {
+ dataset.backgroundColor = chartColors[index];
+ }
}
});
setStateData(stateData);
@@ -95,8 +119,13 @@ function StackedBarChart({data}: Props): JSX.Element
return data ? (
-
- ) : ;
+
+ {chartSubheaderData && ()}
+
+
+
+
+ ) : ;
}
export default StackedBarChart;
diff --git a/src/qqq/components/widgets/charts/piechart/PieChart.tsx b/src/qqq/components/widgets/charts/piechart/PieChart.tsx
index 4105e26..e8269d0 100644
--- a/src/qqq/components/widgets/charts/piechart/PieChart.tsx
+++ b/src/qqq/components/widgets/charts/piechart/PieChart.tsx
@@ -30,6 +30,7 @@ import {useNavigate} from "react-router-dom";
import MDTypography from "qqq/components/legacy/MDTypography";
import {chartColors} from "qqq/components/widgets/charts/DefaultChartData";
import configs from "qqq/components/widgets/charts/piechart/PieChartConfigs";
+import ChartSubheaderWithData, {ChartSubheaderData} from "qqq/components/widgets/components/ChartSubheaderWithData";
//////////////////////////////////////////
// structure of expected bar chart data //
@@ -51,12 +52,13 @@ interface Props
{
description?: string;
chartData: PieChartData;
+ chartSubheaderData?: ChartSubheaderData;
[key: string]: any;
}
-function PieChart({description, chartData}: Props): JSX.Element
+function PieChart({description, chartData, chartSubheaderData}: Props): JSX.Element
{
const navigate = useNavigate();
const [dataLoaded, setDataLoaded] = useState(false);
@@ -69,7 +71,7 @@ function PieChart({description, chartData}: Props): JSX.Element
useEffect(() =>
{
- if(chartData)
+ if (chartData)
{
setDataLoaded(true);
}
@@ -77,19 +79,22 @@ function PieChart({description, chartData}: Props): JSX.Element
const handleClick = (e: Array<{}>) =>
{
- if(e && e.length > 0 && chartData?.dataset?.urls && chartData?.dataset?.urls.length)
+ if (e && e.length > 0 && chartData?.dataset?.urls && chartData?.dataset?.urls.length)
{
// @ts-ignore
navigate(chartData.dataset.urls[e[0]["index"]]);
}
- }
+ };
return (
-
-
+
+
+
+ {chartSubheaderData && ()}
+
-
+
{useMemo(
() => (
@@ -98,32 +103,35 @@ function PieChart({description, chartData}: Props): JSX.Element
)}
{
- ! chartData && (
+ !chartData && (
-
+ justifyContent: "center"
+ }}>
+
)
}
-
{
description && (
-
-
-
-
- {parse(description)}
-
-
+ <>
+
+
+
+
+
+ {parse(description)}
+
+
+
-
+ >
)
}
diff --git a/src/qqq/components/widgets/charts/piechart/PieChartConfigs.ts b/src/qqq/components/widgets/charts/piechart/PieChartConfigs.ts
index 39f825e..1c9bf79 100644
--- a/src/qqq/components/widgets/charts/piechart/PieChartConfigs.ts
+++ b/src/qqq/components/widgets/charts/piechart/PieChartConfigs.ts
@@ -30,10 +30,16 @@ function configs(labels: any, datasets: any)
if (datasets.backgroundColors)
{
datasets.backgroundColors.forEach((color: string) =>
- gradients[color]
- ? backgroundColors.push(gradients[color].state)
- : backgroundColors.push(dark.main)
- );
+ {
+ if (gradients[color])
+ {
+ backgroundColors.push(gradients[color].state);
+ }
+ else
+ {
+ backgroundColors.push(color);
+ }
+ });
}
else
{
@@ -58,12 +64,17 @@ function configs(labels: any, datasets: any)
],
},
options: {
- maintainAspectRatio: true,
+ maintainAspectRatio: false,
responsive: true,
- aspectRatio: 2,
plugins: {
legend: {
position: "bottom",
+ labels: {
+ usePointStyle: true,
+ pointStyle: "circle",
+ pointStyleWidth: 3,
+ padding: 20
+ }
},
},
scales: {