Skip to content

Commit 1861243

Browse files
authored
Merge pull request #1037 from Sysvale/bugfix/charts-scale
Bugfix/charts scale
2 parents 4675078 + 4cf033d commit 1861243

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sysvale/cuida",
3-
"version": "3.151.1",
3+
"version": "3.151.2",
44
"description": "A design system built by Sysvale, using storybook and Vue components",
55
"repository": {
66
"type": "git",

src/components/BarChart.vue

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<!-- eslint-disable vue/multi-word-component-names -->
21
<template>
32
<span>
43
<div
54
class="responsive-container"
65
>
76
<Bar
8-
:is="'bar'"
7+
is="bar"
98
:data="localChartData"
109
:options="chartOptions"
1110
/>
@@ -64,15 +63,15 @@ export default {
6463
*/
6564
barWidth: {
6665
type: Number,
67-
default: 1,
66+
default: 5,
6867
},
6968
7069
/**
7170
* Prop para exibir as barras na direção do eixo x
7271
*/
7372
horizontalBar: {
7473
type: Boolean,
75-
default: false,
74+
default: true,
7675
},
7776
},
7877
@@ -87,6 +86,22 @@ export default {
8786
responsive: true,
8887
maintainAspectRatio: false, // NOTE: Caso true manterá aspecto de proporção original, caso false, será dimensionado para preencher completamente o contêiner (Isso pode fazer com que o gráfico pareça distorcido se o container tiver proporção de aspecto diferente do gráfico original)
8988
categoryPercentage: null, //NOTE: Configura a porcentagem ocupada pela barra do gráfico. (0-1)
89+
indexAxis: this.horizontalBar ? 'y' : 'x',
90+
scales: this.horizontalBar
91+
? {
92+
x: { beginAtZero: true },
93+
}
94+
: {
95+
y: {
96+
beginAtZero: true,
97+
grace: '5%',
98+
ticks: {
99+
precision: 0
100+
},
101+
categoryPercentage: 0.6,
102+
barPercentage: 0.8
103+
},
104+
},
90105
plugins: {
91106
tooltip: {
92107
callbacks: {
@@ -116,7 +131,7 @@ export default {
116131
},
117132
118133
variant: {
119-
handler(newValue) {
134+
handler(newValue, oldValue) {
120135
if (newValue === 'gray' || newValue === 'dark') {
121136
this.deleteFirstTwoColors = true;
122137
} else {
@@ -144,20 +159,6 @@ export default {
144159
immediate: true,
145160
},
146161
},
147-
148-
mounted() {
149-
if(this.horizontalBar) {
150-
this.chartOptions = {
151-
...this.chartOptions,
152-
indexAxis: 'y',
153-
scales: {
154-
y: {
155-
beginAtZero: true
156-
}
157-
},
158-
};
159-
}
160-
},
161162
162163
methods: {
163164
paleteBuilder,

src/components/LineChart.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ export default {
185185
y: {
186186
suggestedMin: this.yAxisRange[0],
187187
suggestedMax: this.yAxisRange[1],
188+
beginAtZero: true,
189+
grace: '10%',
190+
ticks: {
191+
precision: 0
192+
},
188193
display: true,
189194
title: {
190195
display: true,

src/components/StackedBarChart.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class="responsive-container"
66
>
77
<Bar
8-
:is="'bar'"
8+
is="bar"
99
:data="localChartData"
1010
:options="chartOptions"
1111
:plugins="plugins"
@@ -107,6 +107,11 @@ export default {
107107
},
108108
y: {
109109
stacked: true,
110+
beginAtZero: true,
111+
grace: '10%',
112+
ticks: {
113+
precision: 0
114+
},
110115
grid: {
111116
color: '#DFE5EC',
112117
},

0 commit comments

Comments
 (0)