merged to main

This commit is contained in:
Nalvazhuthi
2025-04-11 18:44:48 +05:30
30 changed files with 1273 additions and 1079 deletions

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useState } from "react";
import { Doughnut } from "react-chartjs-2";
import { Line } from "react-chartjs-2";
import io from "socket.io-client";
import axios from "axios";
@@ -16,7 +16,7 @@ interface ChartComponentProps {
fontWeight?: "Light" | "Regular" | "Bold";
}
const DoughnutGraphComponent = ({
const LineGraphComponent = ({
id,
type,
title,
@@ -52,7 +52,7 @@ const DoughnutGraphComponent = ({
};
useEffect(() => {
},[])
// Memoize Theme Colors
@@ -97,11 +97,11 @@ const DoughnutGraphComponent = ({
},
},
scales: {
// x: {
// ticks: {
// display: true, // This hides the x-axis labels
// },
// },
x: {
ticks: {
display: true, // This hides the x-axis labels
},
},
},
}),
[title, chartFontStyle, name]
@@ -161,6 +161,8 @@ const DoughnutGraphComponent = ({
try {
const response = await axios.get(`http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${id}/${organization}`);
if (response.status === 200) {
console.log('line chart res',response);
setmeasurements(response.data.Data.measurements)
setDuration(response.data.Data.duration)
setName(response.data.widgetName)
@@ -184,7 +186,7 @@ const DoughnutGraphComponent = ({
}
,[chartMeasurements, chartDuration, widgetName])
return <Doughnut data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
return <Line data={Object.keys(measurements).length > 0 ? chartData : defaultData} options={options} />;
};
export default DoughnutGraphComponent;
export default LineGraphComponent;