diff --git a/frontend/src/components/editor/Step2FuzzyModeling.jsx b/frontend/src/components/editor/Step2FuzzyModeling.jsx
index ee9841e..34ba6f8 100644
--- a/frontend/src/components/editor/Step2FuzzyModeling.jsx
+++ b/frontend/src/components/editor/Step2FuzzyModeling.jsx
@@ -1,11 +1,21 @@
import Chart from '../membershipFunction/Chart';
import Controls from '../membershipFunction/Controls';
+import { CHART_COLORS } from '../../config';
-const COLORS = ['#ef4444', '#f59e0b', '#10b981', '#3b82f6', '#d946ef', '#06b6d4', '#8b5cf6', '#f43f5e', '#6366f1'];
-
-export default function Step2FuzzyModeling({baseScale, mfDefinitions, selectedTerm, setSelectedTerm, updateCurrentMf, handleFinalSubmit, onBack, subscales, onOpenSubscale}) {
+export default function Step2FuzzyModeling({
+ baseScale,
+ mfDefinitions,
+ selectedTerm,
+ setSelectedTerm,
+ updateCurrentMf,
+ handleFinalSubmit,
+ onBack,
+ subscales,
+ onOpenSubscale
+}) {
const scaleKeys = Object.keys(baseScale);
- const selectedColor = COLORS[scaleKeys.indexOf(selectedTerm) % COLORS.length] || '#2563eb';
+
+ const selectedColor = CHART_COLORS[scaleKeys.indexOf(selectedTerm) % CHART_COLORS.length] || '#2563eb';
return (
@@ -17,11 +27,18 @@ export default function Step2FuzzyModeling({baseScale, mfDefinitions, selectedTe
{scaleKeys.map((name, index) => {
- const color = COLORS[index % COLORS.length];
const isSelected = selectedTerm === name;
+ const color = CHART_COLORS[index % CHART_COLORS.length];
+
return (
-
);
}
\ No newline at end of file
diff --git a/frontend/src/components/editor/Step3FinalGraph.jsx b/frontend/src/components/editor/Step3FinalGraph.jsx
index 0173abf..35d728f 100644
--- a/frontend/src/components/editor/Step3FinalGraph.jsx
+++ b/frontend/src/components/editor/Step3FinalGraph.jsx
@@ -1,85 +1,101 @@
-import {
- LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer
-} from 'recharts';
+import { useMemo } from 'react';
+import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
import { CHART_COLORS } from '../../config';
const Step3FinalGraph = ({ data }) => {
- if (!data || !data.results) return
Cargando gráfico final...
;
+ const sortedResults = useMemo(() => {
+ if (!data || !data.results) return [];
- const resultsWithOriginalIndex = data.results.map((item, index) => ({
- ...item,
- originalIndex: index
- }));
+ const withPermanentColors = data.results.map((item, index) => ({
+ ...item,
+ color: CHART_COLORS[index % CHART_COLORS.length]
+ }));
- const sortedResults = [...resultsWithOriginalIndex].sort((a, b) => {
- const valA = a.core ? a.core[0] : 0;
- const valB = b.core ? b.core[0] : 0;
- return valA - valB;
- });
+ return withPermanentColors.sort((a, b) => {
+ const coreA = Array.isArray(a.core) ? Number(a.core[0]) : 0;
+ const coreB = Array.isArray(b.core) ? Number(b.core[0]) : 0;
+ return coreA - coreB;
+ });
+ }, [data]);
+
+ if (!data || !data.results) {
+ return
Cargando gráfico final...
;
+ }
return (
-
-
Espectro Difuso Final
+
+
Espectro Difuso Final
-
-
-
-
-
-
-
- [value.toFixed(3), name]}
- labelFormatter={(label) => `X: ${Number(label).toFixed(3)}`}
- contentStyle={{ borderRadius: '12px', border: 'none', boxShadow: '0 10px 15px -3px rgb(0 0 0 / 0.1)' }}
- />
-
-
-
);
};