Skip to content

Commit

Permalink
🐛 fix: Bug Grafico
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrogomes18 committed Sep 23, 2024
1 parent 4574bc9 commit 7be438f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion %ProgramData%/Microsoft/Windows/UUS/State/_active.uusver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1307.2407.15032.0
1308.2407.15042.0
70 changes: 38 additions & 32 deletions src/components/BarChart/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import * as S from './styles';
import { Dimensions } from 'react-native';
import { Dimensions, Text } from 'react-native';
import { BarChart } from 'react-native-chart-kit';
import ScatterPlotComponent, { ScatterPlotProps } from '@components/Scratter';

Expand All @@ -16,26 +16,30 @@ export interface BarChartProps {

const BarChartComponent: React.FC<BarChartProps> = ({
type,
questionsBar,
questionsBar = [],
moduleAverages,
}) => {
const chartWidth = Dimensions.get('window').width - 50;
const chartHeight = 200;
const barChartData = {
labels: questionsBar?.map((_item, index) => `${index + 1}`),
datasets: [
{
data: questionsBar?.map((item) =>
Math.min(Math.max(item.averageGrade, 0), 5)
),
colors: questionsBar?.map(
() =>
(_opacity = 1) =>
'#3E63DD'
),
},
],
};
const hasBarChartData = questionsBar && questionsBar.length > 0;

const barChartData = hasBarChartData
? {
labels: questionsBar.map((_item, index) => `${index + 1}`),
datasets: [
{
data: questionsBar.map((item) =>
Math.min(Math.max(item.averageGrade, 0), 5)
),
colors: questionsBar.map(
() =>
(_opacity = 1) =>
'#3E63DD'
),
},
],
}
: null;

const barChartConfig = {
backgroundGradientFrom: '#F8F9FA',
Expand All @@ -56,21 +60,23 @@ const BarChartComponent: React.FC<BarChartProps> = ({
{type === 'modulo' && (
<>
<S.TitleSlider>Médias por módulo</S.TitleSlider>
<BarChart
data={barChartData}
width={chartWidth}
height={chartHeight}
yAxisLabel=""
yAxisSuffix=""
chartConfig={barChartConfig}
showValuesOnTopOfBars={false}
showBarTops={false}
fromZero
flatColor
fromNumber={5}
withInnerLines={false}
withCustomBarColorFromData
/>
{hasBarChartData && barChartData && (
<BarChart
data={barChartData}
width={chartWidth}
height={chartHeight}
yAxisLabel=""
yAxisSuffix=""
chartConfig={barChartConfig}
showValuesOnTopOfBars={false}
showBarTops={false}
fromZero
flatColor
fromNumber={5}
withInnerLines={false}
withCustomBarColorFromData
/>
)}
</>
)}
{type === 'matriz' && (
Expand Down
1 change: 0 additions & 1 deletion src/services/ModuleGradeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default class ModuleGradeServices {
): Promise<ScatterPlotProps[]> {
const moduleGradeSellerResponse: AxiosResponse<ScatterPlotProps[]> =
await api.get(`/module/getAllModuleInfo/${supervisorID}`);
console.log(moduleGradeSellerResponse.data);

return moduleGradeSellerResponse.data;
}
Expand Down

0 comments on commit 7be438f

Please sign in to comment.