Skip to content

Commit

Permalink
Pie Chart displays values obtained from SImaPro
Browse files Browse the repository at this point in the history
#82 the details page displays data from API...
  • Loading branch information
SaiVarunVaranasi committed Jun 28, 2021
1 parent c00ea70 commit 12c8c43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
22 changes: 12 additions & 10 deletions frontend/src/components/details/PieChartComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getMaterialCompositionData,
getMaterialCompositionLabels
} from 'interface/projectInterface';
import theme from 'resources/theme';
//import theme from 'resources/theme';
/**
* Pie Chart Diagram
*/
Expand All @@ -29,15 +29,17 @@ const PieChartComponent = () => {

labels: labels,
// TODO: color map
colors: [
'#fae920',
'#cfd6e3',
'#eb8fa1',
'#89b5c4',
theme.color.Alminium,
'#36a6c7',
'#eb8323'
],
// fill: {
// colors: [
// '#fae920',
// '#cfd6e3',
// '#eb8fa1',
// '#89b5c4',
// theme.color.Alminium,
// '#36a6c7',
// '#eb8323'
// ]
// },
responsive: [
{
breakpoint: 5600,
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/interface/projectInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,8 @@ export function setMaterialCompositionData(compositionData) {
materialDataInPercent = [];
materialCompositionData = Array.from(compositionData);
console.log(materialCompositionData);
let sum = 0;
for (let i = 0; i < materialCompositionData.length; i++) {
sum += Number(materialCompositionData[i]);
}
console.log(sum);
for (let i = 0; i < materialCompositionData.length; i++) {
materialDataInPercent[i] = (Number(materialCompositionData[i] / sum) * 100).toFixed(2);
materialDataInPercent[i] = Number(materialCompositionData[i]);
}
console.log(materialDataInPercent);
}
Expand Down

0 comments on commit 12c8c43

Please sign in to comment.