Skip to content

Commit

Permalink
Merge branch 'develop' into frontend/#142
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasTubertSFC committed Jul 12, 2024
2 parents 29bc269 + 31a2f67 commit 3f95172
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AfterViewInit,
Component,
inject,
Input,
OnInit,
} from '@angular/core';
Expand All @@ -11,6 +12,7 @@ import { LineChart, LineSeriesOption } from 'echarts/charts';
import { UniversalTransition } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';
import { Observations } from '../../../../models/observations';
import { TranslateService } from '@ngx-translate/core';

type EChartsOption = echarts.ComposeOption<
GridComponentOption | LineSeriesOption
Expand All @@ -22,12 +24,14 @@ type EChartsOption = echarts.ComposeOption<
styleUrl: './laeq-tchart.component.scss',
})
export class LAeqTChartComponent implements OnInit, AfterViewInit {
private translations = inject(TranslateService);

@Input() observationSelected!: Observations;

private myLineChart!: echarts.ECharts;
private options: EChartsOption;
private loadingOptions = {
text: 'Carregant...',
text: this.translations.instant('app.loading'),
color: '#FF7A1F',
};

Expand Down Expand Up @@ -57,10 +61,16 @@ export class LAeqTChartComponent implements OnInit, AfterViewInit {
this.options = {
xAxis: {
type: 'category',
name: this.translations.instant('map.laeqtChart.axisX'),
nameGap: 35,
nameLocation: 'middle',
data: seconds,
},
yAxis: {
type: 'value',
name: this.translations.instant('map.laeqtChart.axisY'),
nameGap: 35,
nameLocation: 'middle',
},
series: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ export class OneThirdOctaveChartComponent implements OnInit, AfterViewInit {
let pond: number[] = [];
let noPond: number[] = [];
this.hertzLevels.forEach(() => {
pond.push(random(0, 1000));
noPond.push(random(0, 1000));
pond.push(random(20, 80));
noPond.push(random(20, 80));
});
dBLevels.push(pond);
dBLevels.push(noPond);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,25 @@ export class PerceptionChartComponent implements OnInit, OnDestroy{
this.translations.instant('soundscape.perception.veryQuiet')
],
[
this.translations.instant('soundscape.perception.dirty'),
this.translations.instant('soundscape.perception.clean'),
this.translations.instant('soundscape.perception.veryClean')
this.translations.instant('soundscape.perception.veryBad'),
this.translations.instant('soundscape.perception.bad'),
this.translations.instant('soundscape.perception.medium'),
this.translations.instant('soundscape.perception.good'),
this.translations.instant('soundscape.perception.verGood')
],
[
this.translations.instant('soundscape.perception.notAccessible'),
this.translations.instant('soundscape.perception.accessible'),
this.translations.instant('soundscape.perception.veryAccessible')
this.translations.instant('soundscape.perception.veryBad'),
this.translations.instant('soundscape.perception.bad'),
this.translations.instant('soundscape.perception.medium'),
this.translations.instant('soundscape.perception.good'),
this.translations.instant('soundscape.perception.verGood')
],
[
this.translations.instant('soundscape.perception.notSafe'),
this.translations.instant('soundscape.perception.safe'),
this.translations.instant('soundscape.perception.verySafe')
this.translations.instant('soundscape.perception.veryBad'),
this.translations.instant('soundscape.perception.bad'),
this.translations.instant('soundscape.perception.medium'),
this.translations.instant('soundscape.perception.good'),
this.translations.instant('soundscape.perception.verGood')
]
];

Expand Down Expand Up @@ -109,25 +115,35 @@ export class PerceptionChartComponent implements OnInit, OnDestroy{
let cleanliness: number[] = Array.from({length: this.legendsLabels[1].length}, () => 0);
let accessibility: number[] = Array.from({length: this.legendsLabels[2].length}, () => 0);
let safety: number[] = Array.from({length: this.legendsLabels[3].length}, () => 0);
//let numeric = 0;
//let noNumeric = 0;


this.observations.forEach(obs => {

if(Number(obs.attributes.quiet)){
quiet[Number(obs.attributes.quiet) - 1] ++;
}

if(Number(obs.attributes.cleanliness) && Number(obs.attributes.cleanliness) <= 3){

if(Number(obs.attributes.cleanliness)){
cleanliness[Number(obs.attributes.cleanliness) - 1] ++;
}

if(Number(obs.attributes.accessibility) && Number(obs.attributes.accessibility) <= 3){
if(Number(obs.attributes.accessibility)){
accessibility[Number(obs.attributes.accessibility) - 1]++;
}

if(Number(obs.attributes.safety) && Number(obs.attributes.safety) <= 3){
if(Number(obs.attributes.safety)){
safety[Number(obs.attributes.safety) - 1] ++;
}

});

//console.log("Total de observaciones" ,this.observations.length);
//console.log("Observacion con valor númerico", numeric);
//console.log("Observacion con valor NO númerico", noNumeric);

data.push(quiet);
data.push(cleanliness);
data.push(accessibility);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class TagCloudComponent implements OnInit, OnDestroy{
this.text = "";

this.observations.forEach((obs: Observations) => {
this.text = this.text + " " + obs.attributes.protection.toLocaleLowerCase();
if(obs.attributes.protection !== null) this.text = this.text + " " + obs.attributes.protection.toLocaleLowerCase();
})

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
inject,
} from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';

import type { Observations } from '../../../../models/observations';
import { Subscription } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';

import * as echarts from 'echarts/core';
import {
Expand All @@ -26,10 +26,11 @@ import { CandlestickChart, CandlestickSeriesOption } from 'echarts/charts';
import { CanvasRenderer } from 'echarts/renderers';
import { CallbackDataParams } from 'echarts/types/dist/shared';
import { SeriesOption } from 'echarts';

import type { Observations } from '../../../../models/observations';
import energeticAvg from '../../../../../utils/energeticAvg';
import { ObservationsService } from '../../../../services/observations/observations.service';
import { Subscription } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';


type EChartsOption = echarts.ComposeOption<
| GridComponentOption
Expand Down Expand Up @@ -94,6 +95,11 @@ const colors: Colors = {
},
};

//I create this global variables to be able to pass the translation to
//Tooltip of the chart
let hourWord = ''
let numOfObsWord = ''

@Component({
selector: 'app-temporal-evolution-sound-level-chart',
templateUrl: './temporal-evolution-sound-level-chart.component.html',
Expand Down Expand Up @@ -127,6 +133,9 @@ export class TemporalEvolutionSoundLevelChartComponent
public filterState!: string;

ngOnInit(): void {
hourWord = this.translations.instant('soundscape.temporalEvolution.tooltip.hour')
numOfObsWord = this.translations.instant('soundscape.temporalEvolution.tooltip.numObs')

echarts.use([
GridComponent,
CandlestickChart,
Expand Down Expand Up @@ -295,8 +304,9 @@ export class TemporalEvolutionSoundLevelChartComponent
curr.pop();
if (!acc[hour]) {
acc[hour] = [curr as number[]];
} else {
acc[hour].push(curr as number[]);
}
acc[hour].push(curr as number[]);
return acc;
},
{}
Expand All @@ -320,7 +330,7 @@ export class TemporalEvolutionSoundLevelChartComponent
const avgLAmax = energeticAvg(LAmax);
const avgLeq = energeticAvg(Leq);

const avg = [avgL90, avgL10, avgLAmin, avgLAmax, avgLeq];
const avg = [avgL90, avgL10, avgLAmin, avgLAmax, avgLeq, data.length];

avgByHour[keyOfHours] = avg;
}
Expand Down Expand Up @@ -467,15 +477,17 @@ export class TemporalEvolutionSoundLevelChartComponent
let p = params as CallbackDataParams;
let values: string[] = [];
const data = p.data as number[];
const date = p.name;
const date = p.name+':00';
const L90 = data[1];
const L10 = data[2];
const LAmin = data[3];
const LAmax = data[4];
const Leq = data[5];
const numOfObs = data[6]
const html = `
<b>${p.seriesName}</b> <br>
Hora: ${date} <br>
${hourWord}: ${date} <br>
${numOfObsWord}: ${numOfObs} <br>
LAeq: ${Leq} <br>
L10: ${L10} <br>
L90: ${L90} <br>
Expand All @@ -498,11 +510,15 @@ export class TemporalEvolutionSoundLevelChartComponent
xAxis: {
data: hours,
name: this.translations.instant('soundscape.temporalEvolution.hours'),
nameGap: 35,
nameLocation: 'middle',
},
yAxis: {
name: this.translations.instant(
'soundscape.temporalEvolution.pressureLevel'
),
nameLocation: 'middle',
nameGap: 35,
},
series: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export class TonalFrequencyChartComponent {
let pond: number[] = [];
let noPond: number[] = [];
this.hertzLevels.forEach(() => {
pond.push(random(0,1000));
noPond.push(random(0,1000));
pond.push(random(20,80));
noPond.push(random(20,80));
});
dBLevels.push(pond);
dBLevels.push(noPond);
Expand Down
18 changes: 16 additions & 2 deletions src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@
"title": "Tipus de mapa",
"standard": "Estandar",
"satellite": "Satèl·lit"
},
"laeqtChart":{
"axisX": "Temps (segons)",
"axisY": "Nivell de pressió sonora (dBA)"
}
},
},
"overview":{
"observations": "Resum",
"titleMenu": "Resum",
Expand Down Expand Up @@ -146,6 +150,12 @@
"clean": "Net",
"veryClean": "Molt net",

"veryBad": "Molt dolent",
"bad": "Dolent",
"medium": "Mitjà",
"good": "",
"verGood": "Molt bé",

"notAccessible": "Poc accessible",
"accessible": "Accessible",
"veryAccessible": "Molt accessible",
Expand Down Expand Up @@ -189,7 +199,11 @@
"morning": "Dia",
"afternoon": "Vespre",
"night": "Nit",
"pressureLevel": "Nivell de pressió sonora (dBA)"
"pressureLevel": "Nivell de pressió sonora (dBA)",
"tooltip":{
"hour":"Hora",
"numObs":"Observacions"
}
}
},
"login":{
Expand Down

0 comments on commit 3f95172

Please sign in to comment.