@weni/unnnic-system 1.10.31 → 1.11.0
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
CHANGED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['unnnic-chart-line', { condensed }]">
|
|
3
|
+
<div v-if="title" class="header">
|
|
4
|
+
<div class="title unnnic-font secondary body-lg color-neutral-dark">{{ title }}</div>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<div class="main">
|
|
8
|
+
<div class="reference">
|
|
9
|
+
<div class="values">
|
|
10
|
+
<div
|
|
11
|
+
v-for="(value, index) in [value(maxValue), value(maxValue / 2), value(0)]"
|
|
12
|
+
:key="index"
|
|
13
|
+
class="value unnnic-font secondary body-md color-neutral-cleanest"
|
|
14
|
+
>
|
|
15
|
+
{{ value }}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div class="unnnic-font secondary body-md color-neutral-cleanest"> </div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class="groups">
|
|
23
|
+
<div class="chart" :style="{ backgroundImage: svgChart }" ref="chart">
|
|
24
|
+
<div v-for="({ value }, index) in data" :key="index" class="group">
|
|
25
|
+
<unnnic-tool-tip
|
|
26
|
+
enabled
|
|
27
|
+
:text="String(value)"
|
|
28
|
+
side="top"
|
|
29
|
+
:style="{ height: `${(value / maxValue) * 100}%`, width: '100%' }"
|
|
30
|
+
>
|
|
31
|
+
<div class="bar"></div>
|
|
32
|
+
</unnnic-tool-tip>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div class="titles">
|
|
37
|
+
<div
|
|
38
|
+
v-for="({ title }, index) in data"
|
|
39
|
+
:key="index"
|
|
40
|
+
class="title unnnic-font secondary body-md color-neutral-cleanest"
|
|
41
|
+
>
|
|
42
|
+
{{ title }}
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
import UnnnicToolTip from '../ToolTip/ToolTip.vue';
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
components: {
|
|
55
|
+
UnnnicToolTip,
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
props: {
|
|
59
|
+
condensed: Boolean,
|
|
60
|
+
fixedMaxValue: Number,
|
|
61
|
+
data: Array,
|
|
62
|
+
title: String,
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
data() {
|
|
66
|
+
return {
|
|
67
|
+
chartContainerWidthInterval: null,
|
|
68
|
+
chartContainerWidth: 0,
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
mounted() {
|
|
73
|
+
this.chartContainerWidth = this.$refs.chart.offsetWidth;
|
|
74
|
+
|
|
75
|
+
this.chartContainerWidthInterval = setInterval(() => {
|
|
76
|
+
this.chartContainerWidth = this.$refs.chart.offsetWidth;
|
|
77
|
+
}, 100);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
beforeDestroy() {
|
|
81
|
+
if (this.chartContainerWidthInterval) {
|
|
82
|
+
clearInterval(this.chartContainerWidthInterval);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
computed: {
|
|
87
|
+
maxValue() {
|
|
88
|
+
return this.fixedMaxValue || Math.max(
|
|
89
|
+
...this.data
|
|
90
|
+
.map(({ value }) => value)
|
|
91
|
+
.flat(),
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
svgChart() {
|
|
96
|
+
const bars = this.data
|
|
97
|
+
.map(
|
|
98
|
+
({ value }) => 50
|
|
99
|
+
- (122 / 200)
|
|
100
|
+
- ((value / this.maxValue) * (50 - (122 / 100)) + Math.random() * 0.01),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const barWidth = 100 / bars.length;
|
|
104
|
+
const halfBar = barWidth / 2;
|
|
105
|
+
|
|
106
|
+
let path = '';
|
|
107
|
+
|
|
108
|
+
path += `L ${barWidth / 2} ${bars[0]}`;
|
|
109
|
+
|
|
110
|
+
let x = 0;
|
|
111
|
+
|
|
112
|
+
for (let i = 1; i < bars.length; i += 1) {
|
|
113
|
+
if (i === 1) {
|
|
114
|
+
x = barWidth * 1.5;
|
|
115
|
+
} else {
|
|
116
|
+
x += barWidth;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
path += `C ${x - halfBar} ${bars[i - 1]} ${x - halfBar} ${bars[i]} ${x} ${bars[i]}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (bars.length <= 1) {
|
|
123
|
+
x += barWidth / 2;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
path += `L ${x + halfBar} ${bars[bars.length - 1]}`;
|
|
127
|
+
|
|
128
|
+
const svg = `
|
|
129
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox="0 0 100 50" width="100%" height="100%">
|
|
130
|
+
<defs>
|
|
131
|
+
<linearGradient id="linear" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
132
|
+
<stop offset="0%" stop-color="#DE16BA" stop-opacity="1" />
|
|
133
|
+
<stop offset="50%" stop-color="#DE16BA" stop-opacity="0.4" />
|
|
134
|
+
<stop offset="100%" stop-color="#2856FC" stop-opacity="1.0" />
|
|
135
|
+
</linearGradient>
|
|
136
|
+
|
|
137
|
+
<linearGradient id="linear1" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
138
|
+
<stop offset="0%" stop-color="#DE16BA" stop-opacity="0.16" />
|
|
139
|
+
<stop offset="50%" stop-color="#2856FC" stop-opacity="0.16" />
|
|
140
|
+
</linearGradient>
|
|
141
|
+
</defs>
|
|
142
|
+
|
|
143
|
+
<g style="transform: scaleX(${this.chartContainerWidth / ((122 / 50) * 100)}); transform-origin: center;">
|
|
144
|
+
<path fill="url(#linear1)" d="M0 50 L0 ${String(bars[0]) + path} L100 50Z" />
|
|
145
|
+
<path fill="none" stroke-width="2" stroke-linecap="round" vector-effect="non-scaling-stroke" stroke="url(#linear)" d="M0 ${String(bars[0]) + path}" />
|
|
146
|
+
</g>
|
|
147
|
+
</svg>
|
|
148
|
+
`;
|
|
149
|
+
|
|
150
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
methods: {
|
|
155
|
+
value(value) {
|
|
156
|
+
if (this.maxValue <= 1) {
|
|
157
|
+
return value.toFixed(1);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return String(Math.ceil(value));
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
</script>
|
|
165
|
+
|
|
166
|
+
<style lang="scss" scoped>
|
|
167
|
+
@import "../../assets/scss/unnnic.scss";
|
|
168
|
+
|
|
169
|
+
.unnnic-chart-line {
|
|
170
|
+
background-color: $unnnic-color-background-snow;
|
|
171
|
+
border-radius: $unnnic-border-radius-md;
|
|
172
|
+
padding: $unnnic-spacing-inset-md;
|
|
173
|
+
box-sizing: border-box;
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
row-gap: $unnnic-spacing-stack-nano;
|
|
177
|
+
outline-style: solid;
|
|
178
|
+
outline-color: $unnnic-color-neutral-soft;
|
|
179
|
+
outline-width: $unnnic-border-width-thinner;
|
|
180
|
+
outline-offset: -$unnnic-border-width-thinner;
|
|
181
|
+
|
|
182
|
+
&.condensed {
|
|
183
|
+
padding: $unnnic-spacing-inset-sm;
|
|
184
|
+
|
|
185
|
+
.main .reference {
|
|
186
|
+
margin-right: $unnnic-spacing-inline-sm;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.main {
|
|
191
|
+
height: 9.125rem;
|
|
192
|
+
display: flex;
|
|
193
|
+
justify-content: center;
|
|
194
|
+
|
|
195
|
+
.reference {
|
|
196
|
+
display: flex;
|
|
197
|
+
flex-direction: column;
|
|
198
|
+
row-gap: $unnnic-spacing-stack-nano;
|
|
199
|
+
margin-right: $unnnic-spacing-inline-md;
|
|
200
|
+
|
|
201
|
+
.values {
|
|
202
|
+
flex: 1;
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
justify-content: space-between;
|
|
206
|
+
text-align: right;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.groups {
|
|
211
|
+
display: flex;
|
|
212
|
+
flex: 1;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
row-gap: $unnnic-spacing-stack-nano;
|
|
215
|
+
|
|
216
|
+
.chart {
|
|
217
|
+
background-size: 100% 100%;
|
|
218
|
+
flex: 1;
|
|
219
|
+
display: flex;
|
|
220
|
+
|
|
221
|
+
.group {
|
|
222
|
+
flex: 1;
|
|
223
|
+
display: flex;
|
|
224
|
+
flex-direction: column;
|
|
225
|
+
row-gap: $unnnic-spacing-stack-nano;
|
|
226
|
+
justify-content: flex-end;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.unnnic-tooltip:hover .bar {
|
|
230
|
+
width: 0;
|
|
231
|
+
height: 100%;
|
|
232
|
+
border-left: 1px dashed $unnnic-color-neutral-dark;
|
|
233
|
+
margin: 0 auto;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.titles {
|
|
238
|
+
display: flex;
|
|
239
|
+
|
|
240
|
+
.title {
|
|
241
|
+
flex: 1;
|
|
242
|
+
text-align: center;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@each $name, $color in $scheme-colors {
|
|
250
|
+
.color-#{$name} {
|
|
251
|
+
color: $color;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.bg-#{$name} {
|
|
255
|
+
background-color: $color;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.unnnic-font {
|
|
260
|
+
font-weight: $unnnic-font-weight-regular;
|
|
261
|
+
font-family: $unnnic-font-family-primary;
|
|
262
|
+
|
|
263
|
+
$font-sizes:
|
|
264
|
+
"body-sm" $unnnic-font-size-body-sm,
|
|
265
|
+
"body-md" $unnnic-font-size-body-md,
|
|
266
|
+
"body-gt" $unnnic-font-size-body-gt,
|
|
267
|
+
"body-lg" $unnnic-font-size-body-lg,
|
|
268
|
+
|
|
269
|
+
"title-sm" $unnnic-font-size-title-sm,
|
|
270
|
+
"title-md" $unnnic-font-size-title-md,
|
|
271
|
+
"title-lg" $unnnic-font-size-title-lg,
|
|
272
|
+
|
|
273
|
+
"h4" $unnnic-font-size-h4,
|
|
274
|
+
"h3" $unnnic-font-size-h3,
|
|
275
|
+
"h2" $unnnic-font-size-h2,
|
|
276
|
+
"h1" $unnnic-font-size-h1;
|
|
277
|
+
|
|
278
|
+
$font-weights:
|
|
279
|
+
"black" $unnnic-font-weight-black,
|
|
280
|
+
"bold" $unnnic-font-weight-bold,
|
|
281
|
+
"light" $unnnic-font-weight-light;
|
|
282
|
+
|
|
283
|
+
&.secondary {
|
|
284
|
+
font-family: $unnnic-font-family-secondary;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@each $name, $size in $font-sizes {
|
|
288
|
+
&.#{$name} {
|
|
289
|
+
font-size: $size;
|
|
290
|
+
line-height: $size + $unnnic-line-height-md;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@each $name, $weight in $font-weights {
|
|
295
|
+
&.#{$name} {
|
|
296
|
+
font-weight: $weight;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import unnnicChartLine from '../components/ChartLine/ChartLine.vue';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'charts/ChartLine',
|
|
5
|
+
component: unnnicChartLine,
|
|
6
|
+
argTypes: {},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template = (args, { argTypes }) => ({
|
|
10
|
+
components: {
|
|
11
|
+
unnnicChartLine,
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
props: Object.keys(argTypes),
|
|
15
|
+
|
|
16
|
+
template: '<unnnic-chart-line v-bind="$props" />',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const Default = Template.bind({});
|
|
20
|
+
|
|
21
|
+
Default.args = {
|
|
22
|
+
title: 'Histórico de análises',
|
|
23
|
+
fixedMaxValue: 1,
|
|
24
|
+
data: [{
|
|
25
|
+
title: 'Jan',
|
|
26
|
+
value: 0.5,
|
|
27
|
+
}, {
|
|
28
|
+
title: 'Fev',
|
|
29
|
+
value: 1,
|
|
30
|
+
}, {
|
|
31
|
+
title: 'Mar',
|
|
32
|
+
value: 1,
|
|
33
|
+
}],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Condensed = Template.bind({});
|
|
37
|
+
|
|
38
|
+
Condensed.args = {
|
|
39
|
+
title: 'Histórico de análises',
|
|
40
|
+
condensed: true,
|
|
41
|
+
fixedMaxValue: 1,
|
|
42
|
+
data: [{
|
|
43
|
+
title: 'Jan',
|
|
44
|
+
value: 0,
|
|
45
|
+
}, {
|
|
46
|
+
title: 'Fev',
|
|
47
|
+
value: 1,
|
|
48
|
+
}, {
|
|
49
|
+
title: 'Mar',
|
|
50
|
+
value: 0.5,
|
|
51
|
+
}, {
|
|
52
|
+
title: 'Abr',
|
|
53
|
+
value: 1,
|
|
54
|
+
}],
|
|
55
|
+
};
|