-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneralChartBuilderService.js
More file actions
48 lines (43 loc) · 1.65 KB
/
generalChartBuilderService.js
File metadata and controls
48 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class GeneralChartBuilderService {
constructor() {
this._fontFamily = "titulos-observatorio";
this.noDataMessage = "Não há dados com esses critérios para a localidade selecionada";
this.loadingMessage = "Carregando...";
}
static getSlicedDataset(dataset, options) {
let slicedDS = dataset;
if (options !== null && options !== undefined &&
options.limit !== null && options.limit !== undefined &&
dataset.length > options.limit) {
slicedDS = dataset.slice(0, options.limit - 1);
}
return slicedDS;
}
// Helper functions ( TODO move to services)
static getDefaultXYConfig(axesStrokeClass = "") {
return {
gridConfig: { stroke: "transparent" },
barConfig: { stroke: axesStrokeClass },
shapeConfig: {
labelConfig: { fontColor: axesStrokeClass },
stroke: axesStrokeClass
}
}
}
static getTransparentXYConfig() {
return {
labels: [],
gridConfig: {stroke: "transparent"},
ticks: [],
barConfig: {"stroke-width": 0}
}
}
static clearLabel(d, removed_text_list = [], desc_field = "ds_indicador_radical", year_field = "nu_competencia"){
let label = String(d[desc_field]).replace(", " + d[year_field],"").replace("," + d[year_field],"").replace(d[year_field],"").replace(" "," ");
for(let indxText in removed_text_list){
label = String(label).replace(removed_text_list[indxText],"");
}
return label;
}
}
module.exports = GeneralChartBuilderService