bug fixed
This commit is contained in:
parent
c014fcf4bc
commit
f6700fd951
@ -5,11 +5,8 @@ import { getSubmissionById } from '@/services/admin/submission';
|
|||||||
import apiClient from '@/services/api/apiClient';
|
import apiClient from '@/services/api/apiClient';
|
||||||
import { getBeforePreviousData, getQuarterPeriods } from '@/services/submissions/submissionService';
|
import { getBeforePreviousData, getQuarterPeriods } from '@/services/submissions/submissionService';
|
||||||
import { getProductSubmissionHistory } from '@/services/submissions/submissionService';
|
import { getProductSubmissionHistory } from '@/services/submissions/submissionService';
|
||||||
import { Chart as ChartJS, CategoryScale, LinearScale, BarElement, LineElement, PointElement, Title, Tooltip, Legend } from 'chart.js';
|
|
||||||
import { Line } from 'react-chartjs-2';
|
import { Line } from 'react-chartjs-2';
|
||||||
|
|
||||||
// Register ChartJS components
|
|
||||||
ChartJS.register(CategoryScale, LinearScale, BarElement, LineElement, PointElement, Title, Tooltip, Legend);
|
|
||||||
|
|
||||||
// Helper function to get months for quarter
|
// Helper function to get months for quarter
|
||||||
const getMonthsForQuarter = (quarter, year) => {
|
const getMonthsForQuarter = (quarter, year) => {
|
||||||
@ -387,22 +384,24 @@ const ProductChart = ({ product, establishmentId }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-lg p-6 mb-6 shadow">
|
<div className="bg-white rounded-lg p-6 mb-6 shadow">
|
||||||
<div className="flex justify-between items-center mb-4">
|
<div className="flex justify-between items-center mb-4">
|
||||||
<h2 className="text-lg font-semibold text-gray-900">Product Performance Overview</h2>
|
<h2 className="text-lg font-semibold text-gray-900">
|
||||||
</div>
|
Product Performance Overview
|
||||||
<ColorLegend />
|
</h2>
|
||||||
<div className="overflow-x-auto">
|
|
||||||
<div style={{ minWidth: `${Math.max(600, chartData.labels.length * 100)}px` }}>
|
|
||||||
<div className="h-96 w-full">
|
|
||||||
<Line
|
|
||||||
options={options}
|
|
||||||
data={chartData}
|
|
||||||
style={{ height: '100%' }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<ColorLegend />
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
{/* min width handled via Tailwind */}
|
||||||
|
<div className="min-w-[600px]">
|
||||||
|
<div className="h-96 w-full">
|
||||||
|
<Line
|
||||||
|
data={chartData}
|
||||||
|
options={options}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -949,7 +948,7 @@ const getQuarterYearLabel = (quarter, year) => {
|
|||||||
const currentLabel = getQuarterYearLabel(currentQuarter, currentYear);
|
const currentLabel = getQuarterYearLabel(currentQuarter, currentYear);
|
||||||
|
|
||||||
// Next Year Forecast
|
// Next Year Forecast
|
||||||
const forecastLabel = getQuarterYearLabel(forecastQuarter, currentYear + 1);
|
const forecastLabel = getQuarterYearLabel(forecastQuarter, currentYear);
|
||||||
|
|
||||||
// Optional: Previous Forecast (same year usually)
|
// Optional: Previous Forecast (same year usually)
|
||||||
// const additionalForecastLabel = getQuarterYearLabel(forecastQuarter, currentYear);
|
// const additionalForecastLabel = getQuarterYearLabel(forecastQuarter, currentYear);
|
||||||
@ -1126,7 +1125,7 @@ const additionalForecastLabel =
|
|||||||
|
|
||||||
<div className="overflow-x-auto rounded-[12px] border border-[#E5E7EB]">
|
<div className="overflow-x-auto rounded-[12px] border border-[#E5E7EB]">
|
||||||
<div className="flex items-center justify-between bg-white p-4 rounded-lg "> <div className="flex items-center gap-4">
|
<div className="flex items-center justify-between bg-white p-4 rounded-lg "> <div className="flex items-center gap-4">
|
||||||
<div className="flex items-center gap-2">
|
{/* <div className="flex items-center gap-2">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="varianceHighlighting"
|
id="varianceHighlighting"
|
||||||
@ -1160,8 +1159,8 @@ const additionalForecastLabel =
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div> */}
|
||||||
<div className="flex items-center gap-2">
|
{/* <div className="flex items-center gap-2">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="showPreviousNext"
|
id="showPreviousNext"
|
||||||
@ -1176,7 +1175,7 @@ const additionalForecastLabel =
|
|||||||
>
|
>
|
||||||
{fetchingNextQuarter ? 'Loading...' : 'Show Historical Comparison'}
|
{fetchingNextQuarter ? 'Loading...' : 'Show Historical Comparison'}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
{varianceHighlighting && (
|
{varianceHighlighting && (
|
||||||
<div className="text-xs text-[#6B7280]">
|
<div className="text-xs text-[#6B7280]">
|
||||||
|
|||||||
27
ipi-survey-platform/src/utils/chartsetup.js
Normal file
27
ipi-survey-platform/src/utils/chartsetup.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// src/utils/chartSetup.js
|
||||||
|
import {
|
||||||
|
Chart as ChartJS,
|
||||||
|
CategoryScale,
|
||||||
|
LinearScale,
|
||||||
|
BarElement,
|
||||||
|
LineElement,
|
||||||
|
PointElement,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
Legend,
|
||||||
|
|
||||||
|
} from 'chart.js';
|
||||||
|
|
||||||
|
ChartJS.register(
|
||||||
|
CategoryScale,
|
||||||
|
LinearScale,
|
||||||
|
BarElement,
|
||||||
|
LineElement,
|
||||||
|
PointElement,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
Legend
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user