@tmf_ciclica/ciclicastorybook 1.0.12 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +32 -54
- package/.storybook/main.js +0 -21
- package/.storybook/preview.jsx +0 -31
- package/eslint.config.js +0 -38
- package/index.html +0 -13
- package/public/vite.svg +0 -1
- package/src/App.css +0 -0
- package/src/App.jsx +0 -36
- package/src/_variables.scss +0 -56
- package/src/assets/img/arrowDown.svg +0 -3
- package/src/assets/img/closeIcon.svg +0 -4
- package/src/assets/img/copyIcon.svg +0 -17
- package/src/assets/img/deleteIcon.svg +0 -6
- package/src/assets/img/eyeActiveIcon.svg +0 -6
- package/src/assets/img/eyeNotActiveIcon.svg +0 -8
- package/src/assets/img/filtersIcon.svg +0 -6
- package/src/assets/img/langarrow.png +0 -0
- package/src/assets/img/pause.svg +0 -5
- package/src/assets/img/play.svg +0 -4
- package/src/assets/img/processingIcon.svg +0 -20
- package/src/assets/img/sample-image.png +0 -0
- package/src/assets/img/sample2.png +0 -0
- package/src/assets/img/world.svg +0 -3
- package/src/assets/mapStyles/mapStyle.js +0 -781
- package/src/components/AmbitSelector/AmbitItem/AmbitItem.jsx +0 -74
- package/src/components/AmbitSelector/AmbitItem/AmbitItem.module.scss +0 -27
- package/src/components/AmbitSelector/AmbitSelector.jsx +0 -68
- package/src/components/AmbitSelector/AmbitSelector.module.scss +0 -29
- package/src/components/AmbitSelector/AmbitSelector.stories.jsx +0 -21
- package/src/components/ButtonsList/ButtonsList.jsx +0 -92
- package/src/components/ButtonsList/ButtonsList.module.scss +0 -37
- package/src/components/ButtonsList/ButtonsList.stories.jsx +0 -55
- package/src/components/DropdownList/DropdownList.jsx +0 -69
- package/src/components/DropdownList/DropdownList.module.scss +0 -20
- package/src/components/DropdownList/DropdownList.stories.jsx +0 -22
- package/src/components/DropdownList/DropdownListExample/DropDownListExample.jsx +0 -33
- package/src/components/DropdownList/DropdownListExample/DropdownListExample.stories.jsx +0 -11
- package/src/components/EditAmbit/EditAmbit.jsx +0 -7
- package/src/components/FiltersAmbit/AppliedFilters/AppliedFilters.jsx +0 -57
- package/src/components/FiltersAmbit/AppliedFilters/AppliedFilters.module.scss +0 -13
- package/src/components/FiltersAmbit/AppliedFilters/AppliedFilters.stories.jsx +0 -47
- package/src/components/FiltersAmbit/FiltersAmbit.jsx +0 -58
- package/src/components/FiltersAmbit/FiltersAmbit.module.scss +0 -28
- package/src/components/FiltersAmbit/FiltersAmbit.stories.jsx +0 -36
- package/src/components/FiltersAmbit/GeographicFilters/GeographicalFilters.jsx +0 -33
- package/src/components/FiltersAmbit/GeographicFilters/GeographicalFilters.module.scss +0 -13
- package/src/components/FiltersAmbit/GeographicFilters/GeographicalFilters.stories.jsx +0 -47
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFilters.jsx +0 -83
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFilters.module.scss +0 -8
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFilters.stories.jsx +0 -17
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersCategory/TematicalFiltersCategory.jsx +0 -60
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/AbsoluteSlider/AbsoluteSlider.jsx +0 -61
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/AbsoluteSlider/AbsoluteSlider.module.scss +0 -45
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/CategoryCheckbox/CategoryChackbox.module.scss +0 -18
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/CategoryCheckbox/CategoryCheckbox.jsx +0 -47
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/TematicalFiltersInput.jsx +0 -267
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/TematicalFiltersInput.module.scss +0 -31
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersSubcat/TematicalFiltersSubcat.jsx +0 -58
- package/src/components/FiltersAmbit/useAmbitStore.jsx +0 -10
- package/src/components/Graphic/BarChart/BarChart.jsx +0 -146
- package/src/components/Graphic/BarChart/BarChart.module.scss +0 -5
- package/src/components/Graphic/BarChart/BarChart.stories.jsx +0 -18
- package/src/components/Graphic/Graphic.jsx +0 -55
- package/src/components/Graphic/Graphic.module.scss +0 -12
- package/src/components/Graphic/Graphic.stories.jsx +0 -25
- package/src/components/IndicatorsList/Indicator/Indicator.jsx +0 -180
- package/src/components/IndicatorsList/Indicator/Indicator.module.scss +0 -46
- package/src/components/IndicatorsList/IndicatorSubCategory/IndicatorSubCategory.jsx +0 -76
- package/src/components/IndicatorsList/IndicatorSubCategory/IndicatorSubCategory.module.scss +0 -12
- package/src/components/IndicatorsList/IndicatorsCategory/IndicatorsCategory.jsx +0 -122
- package/src/components/IndicatorsList/IndicatorsCategory/IndicatorsCategory.module.scss +0 -20
- package/src/components/IndicatorsList/IndicatorsList.jsx +0 -173
- package/src/components/IndicatorsList/IndicatorsList.module.scss +0 -10
- package/src/components/IndicatorsList/IndicatorsList.stories.jsx +0 -263
- package/src/components/LangSelector/LangSelector.jsx +0 -70
- package/src/components/LangSelector/LangSelector.module.scss +0 -41
- package/src/components/LangSelector/LangSelector.stories.jsx +0 -27
- package/src/components/Legend/Legend.jsx +0 -132
- package/src/components/Legend/Legend.module.scss +0 -121
- package/src/components/Legend/Legend.stories.jsx +0 -53
- package/src/components/LogoApp/LogoApp.jsx +0 -33
- package/src/components/LogoApp/LogoApp.module.scss +0 -7
- package/src/components/LogoApp/LogoApp.stories.jsx +0 -27
- package/src/components/MapboxMap/MapboxMap.jsx +0 -160
- package/src/components/MapboxMap/MapboxMap.module.scss +0 -4
- package/src/components/MapboxMap/MapboxMap.stories.jsx +0 -57
- package/src/components/MaplibreMap/MaplibreMap.jsx +0 -166
- package/src/components/MaplibreMap/MaplibreMap.module.scss +0 -5
- package/src/components/MaplibreMap/MaplibreMap.stories.jsx +0 -55
- package/src/components/SectionBar/SectionBar.jsx +0 -41
- package/src/components/SectionBar/SectionBar.module.scss +0 -40
- package/src/components/SectionBar/SectionBar.stories.jsx +0 -35
- package/src/components/TimeSlider/TimeSlider.jsx +0 -147
- package/src/components/TimeSlider/TimeSlider.module.scss +0 -63
- package/src/components/TimeSlider/TimeSlider.stories.jsx +0 -9
- package/src/components/Tooltip/Tooltip.jsx +0 -40
- package/src/components/Tooltip/Tooltip.module.scss +0 -141
- package/src/components/Tooltip/Tooltip.stories.jsx +0 -51
- package/src/components/TopNavMenu/TopNavMenu.jsx +0 -62
- package/src/components/TopNavMenu/TopNavMenu.module.scss +0 -21
- package/src/components/TopNavMenu/TopNavMenu.stories.jsx +0 -20
- package/src/components/UserMenuTrigger/UserMenuTrigger.jsx +0 -47
- package/src/components/UserMenuTrigger/UserMenuTrigger.module.scss +0 -5
- package/src/components/UserMenuTrigger/UserMenuTrigger.stories.jsx +0 -33
- package/src/components/index.jsx +0 -17
- package/src/constants/indicators.js +0 -1371
- package/src/constants/mapTexts.js +0 -161
- package/src/constants/textLayers.js +0 -639
- package/src/constants/topNavMenuOptions.js +0 -14
- package/src/i18n.js +0 -19
- package/src/index.jsx +0 -2
- package/src/index.scss +0 -87
- package/src/locales/ca.json +0 -8
- package/src/locales/es.json +0 -15
- package/src/main.jsx +0 -10
- package/src/sections/HeaderSection/HeaderSection.jsx +0 -51
- package/src/sections/HeaderSection/HeaderSection.module.scss +0 -33
- package/src/sections/HeaderSection/HeaderSection.stories.jsx +0 -61
- package/src/sections/RightSidebar/RightSidebar.jsx +0 -35
- package/src/sections/RightSidebar/RightSidebar.module.scss +0 -39
- package/src/sections/RightSidebar/RightSidebar.stories.jsx +0 -21
- package/src/sections/index.jsx +0 -2
- package/src/store/index.js +0 -1
- package/src/store/mapSlice/index.js +0 -1
- package/src/store/mapSlice/mapSlice.js +0 -30
- package/src/store/rightBarSlice/index.js +0 -1
- package/src/store/rightBarSlice/rightBarSlice.js +0 -28
- package/src/store/routerSlice/index.js +0 -1
- package/src/store/routerSlice/routerSlice.js +0 -14
- package/src/store/store.js +0 -14
- package/src/store/userSlice/index.js +0 -1
- package/src/store/userSlice/userSlice.js +0 -22
- package/tmf_ciclica-ciclicastorybook-1.0.8.tgz +0 -0
- package/vite.config.js +0 -49
package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/TematicalFiltersInput.jsx
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from "react"
|
|
2
|
-
import { CategoryCheckbox } from "./CategoryCheckbox/CategoryCheckbox"
|
|
3
|
-
import { AbsoluteSlider } from "./AbsoluteSlider/AbsoluteSlider"
|
|
4
|
-
import { DropdownList } from "../../../DropdownList/DropdownList"
|
|
5
|
-
import PropTypes from "prop-types"
|
|
6
|
-
import style from "./TematicalFiltersInput.module.scss"
|
|
7
|
-
import { useAmbitStore } from "../../useAmbitStore"
|
|
8
|
-
export const TematicalFiltersInput = ({
|
|
9
|
-
indicator,
|
|
10
|
-
//onChangeBothType
|
|
11
|
-
}) => {
|
|
12
|
-
const [selectedType, setSelectedType] = useState()
|
|
13
|
-
const {
|
|
14
|
-
type: indicatorType,
|
|
15
|
-
name,
|
|
16
|
-
values,
|
|
17
|
-
minValue,
|
|
18
|
-
maxValue,
|
|
19
|
-
unit,
|
|
20
|
-
} = indicator || {}
|
|
21
|
-
const isTypeCat = useMemo(
|
|
22
|
-
() => indicatorType == "cat" || selectedType == "cat",
|
|
23
|
-
[selectedType, indicatorType]
|
|
24
|
-
)
|
|
25
|
-
const isTypeAbs = useMemo(
|
|
26
|
-
() => indicatorType == "abs" || selectedType == "abs",
|
|
27
|
-
[selectedType, indicatorType]
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
tematicalFiltersSelected,
|
|
32
|
-
selectedIndicator,
|
|
33
|
-
fontColor,
|
|
34
|
-
inputsColor,
|
|
35
|
-
} = useAmbitStore((s) => s)
|
|
36
|
-
|
|
37
|
-
const onChangeInput = (indicatorValue) => {
|
|
38
|
-
if (indicatorValue) {
|
|
39
|
-
const { min, max, valueClicked, allValues } = indicatorValue || {}
|
|
40
|
-
const { code, type: indicatorType } = indicator || {}
|
|
41
|
-
const type = isTypeAbs ? "abs" : isTypeCat ? "cat" : "both"
|
|
42
|
-
|
|
43
|
-
//Code is an array. If type is both, we need to check if the value is for category or absolute.
|
|
44
|
-
//Code [1] is the category code, code[0] is the absolute code.
|
|
45
|
-
let newCode = code[0]
|
|
46
|
-
if (indicatorType == "both") {
|
|
47
|
-
newCode = type == "cat" ? code[1] : code[0]
|
|
48
|
-
}
|
|
49
|
-
//By default all categories are selected.
|
|
50
|
-
//When deselecting one category, We will send all the indexes of the values selected in the values array.
|
|
51
|
-
if (type == "cat") {
|
|
52
|
-
useAmbitStore.setState((actual) => {
|
|
53
|
-
let foundIndicator = actual.tematicalFiltersSelected.find(
|
|
54
|
-
(f) => f.code === newCode
|
|
55
|
-
)
|
|
56
|
-
if (foundIndicator) {
|
|
57
|
-
let newValues = [foundIndicator.values]
|
|
58
|
-
//If the indicator already exists, we will update the values array.
|
|
59
|
-
if (foundIndicator.values.includes(valueClicked)) {
|
|
60
|
-
//if the value
|
|
61
|
-
newValues = foundIndicator.values.filter(
|
|
62
|
-
(v) => v !== valueClicked
|
|
63
|
-
)
|
|
64
|
-
if (newValues.length < 1) {
|
|
65
|
-
//If there are no values left, we will remove the indicator from the actual. array.
|
|
66
|
-
return {
|
|
67
|
-
tematicalFiltersSelected:
|
|
68
|
-
actual.tematicalFiltersSelected.filter(
|
|
69
|
-
(f) => f.code !== newCode
|
|
70
|
-
),
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
//If the value is not selected, we will add it to the values array.
|
|
75
|
-
newValues = [...foundIndicator.values, valueClicked]
|
|
76
|
-
}
|
|
77
|
-
//Update the existing filter with the new values.
|
|
78
|
-
return {
|
|
79
|
-
tematicalFiltersSelected: actual.tematicalFiltersSelected.map(
|
|
80
|
-
(f) => (f.code === newCode ? { ...f, values: newValues } : f)
|
|
81
|
-
),
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
console.log("entra aqui: ", allValues, " ", valueClicked)
|
|
85
|
-
let allValuesIndexes = allValues.map((f, index) => index)
|
|
86
|
-
//If the indicator does not exist, we will add it to the filtersSelected array.
|
|
87
|
-
//We will send the values array without the valueClicked index.
|
|
88
|
-
return {
|
|
89
|
-
tematicalFiltersSelected: [
|
|
90
|
-
...tematicalFiltersSelected,
|
|
91
|
-
{
|
|
92
|
-
type: "cat",
|
|
93
|
-
code: newCode,
|
|
94
|
-
values: allValuesIndexes.filter((f) => f !== valueClicked),
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
//If type is abs we will send the min and max values selected in the slider.
|
|
101
|
-
} else if (type == "abs") {
|
|
102
|
-
useAmbitStore.setState((actual) => {
|
|
103
|
-
let foundIndicator = actual.tematicalFiltersSelected.find(
|
|
104
|
-
(f) => f.code === newCode
|
|
105
|
-
)
|
|
106
|
-
if (foundIndicator) {
|
|
107
|
-
//If the indicator already exists, we will update the min and max values.
|
|
108
|
-
let updatedIndicator = { ...foundIndicator }
|
|
109
|
-
updatedIndicator.min = min
|
|
110
|
-
updatedIndicator.max = max
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
tematicalFiltersSelected: actual.tematicalFiltersSelected.map(
|
|
114
|
-
(f) => (f.code === newCode ? updatedIndicator : f)
|
|
115
|
-
),
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
//If the indicator does not exist, we will add it to the filtersSelected array.
|
|
119
|
-
return {
|
|
120
|
-
tematicalFiltersSelected: [
|
|
121
|
-
...tematicalFiltersSelected,
|
|
122
|
-
{ type: "abs", code: newCode, min, max },
|
|
123
|
-
],
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
//Filters selected map is the filtersSelected array parsed
|
|
132
|
-
//to a json easy to access the value with {indicator.code: set of values}
|
|
133
|
-
const filtersSelectedMap = useMemo(() => {
|
|
134
|
-
const map = {}
|
|
135
|
-
if (tematicalFiltersSelected?.length > 0) {
|
|
136
|
-
for (const item of tematicalFiltersSelected) {
|
|
137
|
-
if (item.type === "cat") {
|
|
138
|
-
map[item.code] = new Set(item.values)
|
|
139
|
-
} else {
|
|
140
|
-
map[item.code] = [item.min, item.max]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return map
|
|
145
|
-
}, [tematicalFiltersSelected])
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<div className={style.tematicalFiltersInputContainer}>
|
|
149
|
-
<DropdownList
|
|
150
|
-
titleFontStyles={{ fontSize: 16, fontWeight: 400 }}
|
|
151
|
-
title={name}
|
|
152
|
-
isOpen={selectedIndicator == `id${name}`}
|
|
153
|
-
onClick={() =>
|
|
154
|
-
useAmbitStore.setState(() => ({
|
|
155
|
-
selectedIndicator:
|
|
156
|
-
selectedIndicator == `id${name}` ? "" : `id${name}`,
|
|
157
|
-
}))
|
|
158
|
-
}
|
|
159
|
-
showBottomBar={false}
|
|
160
|
-
height={38}
|
|
161
|
-
titleMarginChildren={14}
|
|
162
|
-
className={"tematicalFiltersInputContainer"}
|
|
163
|
-
color={fontColor}
|
|
164
|
-
>
|
|
165
|
-
{indicatorType == "both" && (
|
|
166
|
-
<div
|
|
167
|
-
className={style.inputTypeContainer}
|
|
168
|
-
style={{ color: fontColor }}
|
|
169
|
-
>
|
|
170
|
-
<label>
|
|
171
|
-
<input
|
|
172
|
-
type="radio"
|
|
173
|
-
name="tipo"
|
|
174
|
-
value="abs"
|
|
175
|
-
// checked={selectedType == "abs"}
|
|
176
|
-
onChange={() => {
|
|
177
|
-
setSelectedType("abs")
|
|
178
|
-
//onChangeBothType && onChangeBothType({ code: code[1] })
|
|
179
|
-
}}
|
|
180
|
-
style={{
|
|
181
|
-
marginRight: 4,
|
|
182
|
-
backgroundColor:
|
|
183
|
-
selectedType == "abs" ? inputsColor : "white",
|
|
184
|
-
border: `1.5px solid ${
|
|
185
|
-
selectedType == "abs" ? inputsColor : fontColor
|
|
186
|
-
}`,
|
|
187
|
-
}}
|
|
188
|
-
/>
|
|
189
|
-
Absoluto
|
|
190
|
-
</label>
|
|
191
|
-
|
|
192
|
-
<label>
|
|
193
|
-
<input
|
|
194
|
-
type="radio"
|
|
195
|
-
name="tipo"
|
|
196
|
-
value="cat"
|
|
197
|
-
// checked={selectedType == "cat"}
|
|
198
|
-
onChange={() => {
|
|
199
|
-
setSelectedType("cat")
|
|
200
|
-
//onChangeBothType && onChangeBothType({ code: code[0] })
|
|
201
|
-
}}
|
|
202
|
-
style={{
|
|
203
|
-
marginRight: 4,
|
|
204
|
-
backgroundColor:
|
|
205
|
-
selectedType == "cat" ? inputsColor : "white",
|
|
206
|
-
border: `1.5px solid ${
|
|
207
|
-
selectedType == "cat" ? inputsColor : fontColor
|
|
208
|
-
}`,
|
|
209
|
-
}}
|
|
210
|
-
/>
|
|
211
|
-
Categórico
|
|
212
|
-
</label>
|
|
213
|
-
</div>
|
|
214
|
-
)}
|
|
215
|
-
{isTypeCat && (
|
|
216
|
-
<div className={style.checkboxContainer}>
|
|
217
|
-
{values.map((indicatorValue, index) => (
|
|
218
|
-
<CategoryCheckbox
|
|
219
|
-
key={`checkbox-${index}`}
|
|
220
|
-
onClick={() =>
|
|
221
|
-
onChangeInput({ valueClicked: index, allValues: values })
|
|
222
|
-
}
|
|
223
|
-
indicator={indicatorValue}
|
|
224
|
-
//Filters selected map is the filtersSelected array parsed
|
|
225
|
-
// to a json easy to access the value with {indicator.code: set of values}
|
|
226
|
-
value={
|
|
227
|
-
filtersSelectedMap[
|
|
228
|
-
indicator.code[indicatorType == "both" ? 1 : 0]
|
|
229
|
-
]?.has(index) ||
|
|
230
|
-
!filtersSelectedMap[
|
|
231
|
-
indicator.code[indicatorType == "both" ? 1 : 0]
|
|
232
|
-
]
|
|
233
|
-
}
|
|
234
|
-
/>
|
|
235
|
-
))}
|
|
236
|
-
</div>
|
|
237
|
-
)}
|
|
238
|
-
{isTypeAbs && (
|
|
239
|
-
<div className={style.absoluteSliderContainer}>
|
|
240
|
-
<AbsoluteSlider
|
|
241
|
-
onChange={onChangeInput}
|
|
242
|
-
min={minValue}
|
|
243
|
-
max={maxValue}
|
|
244
|
-
unit={unit}
|
|
245
|
-
value={filtersSelectedMap[indicator.code[0]]}
|
|
246
|
-
/>
|
|
247
|
-
</div>
|
|
248
|
-
)}
|
|
249
|
-
</DropdownList>
|
|
250
|
-
</div>
|
|
251
|
-
)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
TematicalFiltersInput.propTypes = {
|
|
255
|
-
indicator: PropTypes.shape({
|
|
256
|
-
name: PropTypes.string,
|
|
257
|
-
type: PropTypes.string,
|
|
258
|
-
code: PropTypes.arrayOf(PropTypes.string),
|
|
259
|
-
values: PropTypes.arrayOf(
|
|
260
|
-
PropTypes.shape({
|
|
261
|
-
codename: PropTypes.oneOfType(PropTypes.array, PropTypes.string),
|
|
262
|
-
title: PropTypes.string,
|
|
263
|
-
})
|
|
264
|
-
),
|
|
265
|
-
}),
|
|
266
|
-
//onChangeBothType: PropTypes.func,
|
|
267
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
.tematicalFiltersInputContainer {
|
|
2
|
-
.inputTypeContainer {
|
|
3
|
-
@include flex($direction: column, $align: flex-start);
|
|
4
|
-
gap: 14px;
|
|
5
|
-
padding-bottom: 14px;
|
|
6
|
-
label,
|
|
7
|
-
input {
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
font-size: 14px;
|
|
10
|
-
}
|
|
11
|
-
input[type="radio"] {
|
|
12
|
-
appearance: none;
|
|
13
|
-
-webkit-appearance: none;
|
|
14
|
-
width: 16px;
|
|
15
|
-
height: 16px;
|
|
16
|
-
border-radius: 50%; // redondo como un radio
|
|
17
|
-
background-color: white;
|
|
18
|
-
transition: background-color 0.2s ease;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
vertical-align: middle;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
.checkboxContainer {
|
|
24
|
-
@include flex($direction: column, $align: flex-start);
|
|
25
|
-
gap: 14px;
|
|
26
|
-
}
|
|
27
|
-
.absoluteSliderContainer {
|
|
28
|
-
width: 100%;
|
|
29
|
-
@include flex($align: flex-start, $justify: flex-start);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { DropdownList } from "../../../DropdownList/DropdownList"
|
|
2
|
-
import { TematicalFiltersInput } from "../TematicalFiltersInput/TematicalFiltersInput"
|
|
3
|
-
import PropTypes from "prop-types"
|
|
4
|
-
import { useAmbitStore } from "../../useAmbitStore"
|
|
5
|
-
import { useEffect } from "react"
|
|
6
|
-
|
|
7
|
-
//Needs DropdownList component to be used
|
|
8
|
-
export const TematicalFiltersSubcat = ({
|
|
9
|
-
subcategory,
|
|
10
|
-
fontColor,
|
|
11
|
-
//onChangeBothType,
|
|
12
|
-
}) => {
|
|
13
|
-
const { activeSubcategory } = useAmbitStore((s) => s)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const { name, indicators } = subcategory || {}
|
|
17
|
-
return (
|
|
18
|
-
<DropdownList
|
|
19
|
-
title={name}
|
|
20
|
-
isOpen={activeSubcategory == `id${name}`}
|
|
21
|
-
onClick={() => {
|
|
22
|
-
useAmbitStore.setState((s) => {
|
|
23
|
-
return {
|
|
24
|
-
activeSubcategory:
|
|
25
|
-
s.activeSubcategory === `id${name}` ? "" : `id${name}`,
|
|
26
|
-
}
|
|
27
|
-
})
|
|
28
|
-
}}
|
|
29
|
-
titleFontStyles={{ fontSize: 16, fontWeight: 400 }}
|
|
30
|
-
showBottomBar={false}
|
|
31
|
-
titleMarginChildren={20}
|
|
32
|
-
height={49}
|
|
33
|
-
color={fontColor}
|
|
34
|
-
>
|
|
35
|
-
{indicators?.map((indicator, key) => (
|
|
36
|
-
<TematicalFiltersInput
|
|
37
|
-
indicator={indicator}
|
|
38
|
-
key={`indicatorSub-${key}`}
|
|
39
|
-
fontColor={fontColor}
|
|
40
|
-
//onChangeBothType={onChangeBothType}
|
|
41
|
-
/>
|
|
42
|
-
))}
|
|
43
|
-
</DropdownList>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
TematicalFiltersSubcat.propTypes = {
|
|
48
|
-
subcategory: PropTypes.shape({
|
|
49
|
-
name: PropTypes.string,
|
|
50
|
-
indicators: PropTypes.arrayOf(
|
|
51
|
-
PropTypes.shape({
|
|
52
|
-
name: PropTypes.string,
|
|
53
|
-
value: PropTypes.string,
|
|
54
|
-
})
|
|
55
|
-
),
|
|
56
|
-
}),
|
|
57
|
-
//onChangeBothType: PropTypes.func,
|
|
58
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react"
|
|
2
|
-
import * as d3 from "d3"
|
|
3
|
-
import style from "./BarChart.module.scss"
|
|
4
|
-
import PropTypes from "prop-types"
|
|
5
|
-
import { useTranslation } from "react-i18next"
|
|
6
|
-
export const BarChart = ({
|
|
7
|
-
data,
|
|
8
|
-
width = 700,
|
|
9
|
-
barHeight = 25,
|
|
10
|
-
gap = 23,
|
|
11
|
-
fontColor = "#605B56",
|
|
12
|
-
verticalPaddign = 10,
|
|
13
|
-
horizontalPaddign = 20,
|
|
14
|
-
leftPadding = 200,
|
|
15
|
-
numberOfDivisions = 7,
|
|
16
|
-
|
|
17
|
-
maxValue = null,
|
|
18
|
-
}) => {
|
|
19
|
-
const { t } = useTranslation()
|
|
20
|
-
const { xScale, ticks, height } = useMemo(() => {
|
|
21
|
-
if (data && data.length > 0) {
|
|
22
|
-
const height = data?.length * (barHeight + gap) + verticalPaddign * 2
|
|
23
|
-
const dataMaxValue = d3.max(data, (d) => d.value) || 1
|
|
24
|
-
const xScale = d3
|
|
25
|
-
.scaleLinear()
|
|
26
|
-
.domain([0, maxValue ? maxValue : dataMaxValue])
|
|
27
|
-
.range([0, width - leftPadding])
|
|
28
|
-
|
|
29
|
-
const ticks = Array.from({ length: numberOfDivisions + 1 }, (_, i) => {
|
|
30
|
-
if (maxValue) return (maxValue / numberOfDivisions) * i
|
|
31
|
-
else return (dataMaxValue / numberOfDivisions) * i
|
|
32
|
-
})
|
|
33
|
-
return {
|
|
34
|
-
xScale,
|
|
35
|
-
ticks,
|
|
36
|
-
height,
|
|
37
|
-
width,
|
|
38
|
-
verticalPaddign,
|
|
39
|
-
horizontalPaddign,
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
return { xScale: null, ticks: [], height: 0 }
|
|
43
|
-
}
|
|
44
|
-
}, [
|
|
45
|
-
data,
|
|
46
|
-
width,
|
|
47
|
-
numberOfDivisions,
|
|
48
|
-
barHeight,
|
|
49
|
-
gap,
|
|
50
|
-
horizontalPaddign,
|
|
51
|
-
verticalPaddign,
|
|
52
|
-
maxValue,
|
|
53
|
-
])
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div className={style.barChartContainer}>
|
|
57
|
-
<svg width={width + horizontalPaddign * 2} height={height}>
|
|
58
|
-
<g transform={`translate(0,${gap})`}>
|
|
59
|
-
{/*Ejes verticales*/}
|
|
60
|
-
<g transform={`translate(${leftPadding + horizontalPaddign}, 0)`}>
|
|
61
|
-
{ticks.map((tick, i) => {
|
|
62
|
-
const x = xScale(tick)
|
|
63
|
-
return (
|
|
64
|
-
<g key={i} transform={`translate(${x}, 0)`}>
|
|
65
|
-
<line
|
|
66
|
-
y1={0}
|
|
67
|
-
y2={height - gap * 2}
|
|
68
|
-
stroke="#ccc"
|
|
69
|
-
// strokeDasharray="2,2"
|
|
70
|
-
/>
|
|
71
|
-
<text
|
|
72
|
-
y={height - gap}
|
|
73
|
-
textAnchor="middle"
|
|
74
|
-
fontSize={10}
|
|
75
|
-
fill={fontColor}
|
|
76
|
-
>
|
|
77
|
-
{parseInt(tick)}
|
|
78
|
-
</text>
|
|
79
|
-
</g>
|
|
80
|
-
)
|
|
81
|
-
})}
|
|
82
|
-
</g>
|
|
83
|
-
{/*Barras*/}
|
|
84
|
-
{data &&
|
|
85
|
-
data.length > 0 &&
|
|
86
|
-
data?.map((d, i) => {
|
|
87
|
-
const barWidth = xScale(d.value)
|
|
88
|
-
const y = i * (barHeight + gap)
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<g
|
|
92
|
-
key={i}
|
|
93
|
-
transform={`translate(${
|
|
94
|
-
leftPadding + horizontalPaddign
|
|
95
|
-
}, ${y})`}
|
|
96
|
-
>
|
|
97
|
-
<text
|
|
98
|
-
x={-24}
|
|
99
|
-
y={barHeight / 2 + 5}
|
|
100
|
-
textAnchor="end"
|
|
101
|
-
fill={fontColor}
|
|
102
|
-
// fontSize={12}
|
|
103
|
-
// fontFamily="sans-serif"
|
|
104
|
-
>
|
|
105
|
-
{t(d.title)}
|
|
106
|
-
</text>
|
|
107
|
-
<rect
|
|
108
|
-
width={barWidth}
|
|
109
|
-
height={barHeight}
|
|
110
|
-
fill={d.color}
|
|
111
|
-
rx={0}
|
|
112
|
-
/>
|
|
113
|
-
{/* <text
|
|
114
|
-
x={barWidth - 8}
|
|
115
|
-
y={barHeight / 2 + 5}
|
|
116
|
-
textAnchor="end"
|
|
117
|
-
fill="white"
|
|
118
|
-
fontSize={12}
|
|
119
|
-
fontFamily="sans-serif"
|
|
120
|
-
>
|
|
121
|
-
{d.value} */}
|
|
122
|
-
{/* </text> */}
|
|
123
|
-
</g>
|
|
124
|
-
)
|
|
125
|
-
})}
|
|
126
|
-
</g>
|
|
127
|
-
</svg>
|
|
128
|
-
</div>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
BarChart.propTypes = {
|
|
132
|
-
data: PropTypes.arrayOf(
|
|
133
|
-
PropTypes.shape({
|
|
134
|
-
title: PropTypes.string,
|
|
135
|
-
value: PropTypes.number,
|
|
136
|
-
color: PropTypes.string,
|
|
137
|
-
})
|
|
138
|
-
),
|
|
139
|
-
width: PropTypes.number,
|
|
140
|
-
barHeight: PropTypes.number,
|
|
141
|
-
gap: PropTypes.number,
|
|
142
|
-
verticalPaddign: PropTypes.number,
|
|
143
|
-
horizontalPaddign: PropTypes.number,
|
|
144
|
-
numberOfDivisions: PropTypes.number,
|
|
145
|
-
fontColor: PropTypes.string,
|
|
146
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BarChart } from "./BarChart"
|
|
2
|
-
export default {
|
|
3
|
-
title: "Components/BarChart",
|
|
4
|
-
component: BarChart,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const Default = {
|
|
8
|
-
args: {
|
|
9
|
-
data: [
|
|
10
|
-
{ color: "red", value: 100, title: "Title 1" },
|
|
11
|
-
{ color: "blue", value: 200, title: "Title 2" },
|
|
12
|
-
{ color: "green", value: 300, title: "Title 3" },
|
|
13
|
-
],
|
|
14
|
-
fontColor: "#605B56",
|
|
15
|
-
width: 700,
|
|
16
|
-
barHeight: 45,
|
|
17
|
-
},
|
|
18
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import PropTypes from "prop-types"
|
|
2
|
-
import { BarChart } from "./BarChart/BarChart"
|
|
3
|
-
import styles from "./Graphic.module.scss"
|
|
4
|
-
import { useTranslation } from "react-i18next"
|
|
5
|
-
export const Graphic = ({
|
|
6
|
-
data,
|
|
7
|
-
graphWidth = 700,
|
|
8
|
-
containerStyle,
|
|
9
|
-
borderColor = "#605B56",
|
|
10
|
-
title = "Graphic Title",
|
|
11
|
-
fontColor = "#605B56",
|
|
12
|
-
maxValue = null,
|
|
13
|
-
numberOfDivisions = 7,
|
|
14
|
-
leftPadding = 200,
|
|
15
|
-
}) => {
|
|
16
|
-
const { t } = useTranslation()
|
|
17
|
-
return (
|
|
18
|
-
<div
|
|
19
|
-
className={styles.graphicContainer}
|
|
20
|
-
style={{
|
|
21
|
-
...(containerStyle || {}),
|
|
22
|
-
border: `1.5px solid ${borderColor}`,
|
|
23
|
-
}}
|
|
24
|
-
>
|
|
25
|
-
<div className={styles.titleContainer}>
|
|
26
|
-
<h2>{t(title)}</h2>
|
|
27
|
-
</div>
|
|
28
|
-
<BarChart
|
|
29
|
-
data={data}
|
|
30
|
-
width={graphWidth}
|
|
31
|
-
fontColor={fontColor}
|
|
32
|
-
maxValue={maxValue}
|
|
33
|
-
numberOfDivisions={numberOfDivisions}
|
|
34
|
-
leftPadding={leftPadding}
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
Graphic.propTypes = {
|
|
40
|
-
data: PropTypes.arrayOf(
|
|
41
|
-
PropTypes.shape({
|
|
42
|
-
color: PropTypes.string.isRequired,
|
|
43
|
-
value: PropTypes.number.isRequired,
|
|
44
|
-
title: PropTypes.string.isRequired,
|
|
45
|
-
})
|
|
46
|
-
),
|
|
47
|
-
borderColor: PropTypes.string,
|
|
48
|
-
title: PropTypes.string,
|
|
49
|
-
graphWidth: PropTypes.number,
|
|
50
|
-
containerStyle: PropTypes.object,
|
|
51
|
-
fontColor: PropTypes.string,
|
|
52
|
-
maxValue: PropTypes.number,
|
|
53
|
-
numberOfDivisions: PropTypes.number,
|
|
54
|
-
leftPadding: PropTypes.number,
|
|
55
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { color } from "d3"
|
|
2
|
-
import { Graphic } from "./Graphic"
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/Graphic",
|
|
5
|
-
component: Graphic,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const Default = {
|
|
9
|
-
args: {
|
|
10
|
-
data: [
|
|
11
|
-
{ color: "#FEB641", value: 100, title: "Residential" },
|
|
12
|
-
{ color: "#013365", value: 200, title: "Administration" },
|
|
13
|
-
{ color: "#508BC7", value: 300, title: "Educational" },
|
|
14
|
-
],
|
|
15
|
-
title: "Main use: Number of dwelling",
|
|
16
|
-
containerStyle: {
|
|
17
|
-
color: "#605B56",
|
|
18
|
-
},
|
|
19
|
-
graphWidth: 900,
|
|
20
|
-
fontColor: "#605B56",
|
|
21
|
-
maxValue: 500,
|
|
22
|
-
numberOfDivisions: 7,
|
|
23
|
-
leftPadding: 200,
|
|
24
|
-
},
|
|
25
|
-
}
|