Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/components/charts/pie-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Um componente de gráfico reutilizável para exibir dados visualmente.
## Props

<APITable
name="CdsBarChart"
name="CdsPieChart"
section="props"
/>
<br>
Expand Down
2 changes: 1 addition & 1 deletion docs/components/charts/polar-area-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Um componente de gráfico reutilizável para exibir dados visualmente.
## Props

<APITable
name="CdsBarChart"
name="CdsPolarAreaChart"
section="props"
/>
<br>
Expand Down
10 changes: 5 additions & 5 deletions docs/docgen/PlaygroundBuilder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<CdsText class="prop-name">
{{ capitalize(data.name) }}
</CdsText>

<CdsSwitch
v-if="Object.keys(normalizedPropsData).length > 0"
v-model="normalizedPropsData[index][data.name]"
Expand Down Expand Up @@ -144,7 +144,7 @@ function formatOptions(val: string[]) {
})
}

watch(model, () => {
watch(propsData, () => {
nextTick(() => {
if (!propsData.value || !Array.isArray(propsData.value)) {
normalizedPropsData.value = [];
Expand Down Expand Up @@ -195,7 +195,7 @@ watch(model, () => {
}
});

}, { immediate: true, deep: true})
}, { immediate: true, deep: true })

function capitalize(str: string) {
return str ? str[0].toUpperCase() + str.slice(1) : '';
Expand All @@ -205,12 +205,12 @@ watch(normalizedPropsData, () => {
if (normalizedPropsData.value && Array.isArray(normalizedPropsData.value)) {
normalizedPropsData.value.forEach((item) => {
const [key, value] = Object.entries(item)[0];
if (model.value) {
if (model.value && model.value !== value) {
(model.value as any)[key] = value;
}
});
}
}, { deep: true})
}, { deep: true })


export type PlaygroundBuilderType = typeof import('./PlaygroundBuilder.vue')['default'];
Expand Down
46 changes: 38 additions & 8 deletions src/components/BarChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,21 @@ export default {
watch: {
labels: {
handler(newValue) {
this.localLabels = newValue
this.localLabels = newValue;
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

variant: {
handler(newValue, oldValue) {
if (newValue === 'gray' || newValue === 'dark') {
handler(newValue) {
if (newValue === 'gray' || newValue === 'dark') {
this.deleteFirstTwoColors = true;
} else {
this.deleteFirstTwoColors = false;
}

this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},
Expand All @@ -150,11 +153,38 @@ export default {

barWidth: {
handler(newValue) {
if (newValue >= 0.1 && newValue <= 1) {
this.chartOptions.categoryPercentage = newValue;
} else {
this.chartOptions.categoryPercentage = 1;
}
const categoryPercentage = (newValue >= 0.1 && newValue <= 1) ? newValue : 1;
this.chartOptions = {
...this.chartOptions,
categoryPercentage,
};
},
immediate: true,
},

horizontalBar: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
indexAxis: newValue ? 'y' : 'x',
scales: {
...this.chartOptions.scales,
x: newValue
? { beginAtZero: true }
: { ...this.chartOptions.scales?.x },
y: !newValue
? {
beginAtZero: true,
grace: '5%',
ticks: {
precision: 0
},
categoryPercentage: 0.6,
barPercentage: 0.8
}
: { ...this.chartOptions.scales?.y },
},
};
},
immediate: true,
},
Expand Down
19 changes: 18 additions & 1 deletion src/components/DonutChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,34 @@ export default {
labels: {
handler(newValue) {
this.localLabels = newValue;
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

variant: {
handler(newValue) {
if (newValue === 'gray' || newValue === 'dark') {
if (newValue === 'gray' || newValue === 'dark') {
this.deleteFirstTwoColors = true;
} else {
this.deleteFirstTwoColors = false;
}

this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

theme: {
handler() {
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

colors: {
handler() {
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},
Expand Down
130 changes: 124 additions & 6 deletions src/components/LineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,28 @@ export default {
watch: {
labels: {
handler(newValue) {
this.localLabels = newValue
this.localLabels = newValue;
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

variant: {
handler(newValue) {
if (newValue === 'gray' || newValue === 'dark') {
if (newValue === 'gray' || newValue === 'dark') {
this.deleteFirstTwoColors = true;
} else {
this.deleteFirstTwoColors = false;
}

this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

theme: {
handler() {
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},
Expand All @@ -255,11 +265,116 @@ export default {
immediate: true,
},

showLabelName: {
handler() {
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

fill: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
fill: newValue,
};
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

isDashed: {
handler() {
this.checkDashed();
},
immediate: true,
},

borderDash: {
handler() {
this.checkDashed();
},
immediate: true,
},

scales: {
handler(newValue) {
if (newValue === true) {
this.checkDashed();
}
this.chartOptions = {
...this.chartOptions,
scales: {
...this.chartOptions.scales,
...newValue,
},
};
},
immediate: true,
},

animation: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
animation: {
...newValue,
},
};
},
immediate: true,
},

plugins: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
plugins: {
...this.chartOptions.plugins,
...newValue,
},
};
},
immediate: true,
},

xAxisRange: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
scales: {
...this.chartOptions.scales,
x: {
...this.chartOptions.scales?.x,
suggestedMin: newValue[0],
suggestedMax: newValue[1],
},
},
};
},
immediate: true,
},

yAxisRange: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
scales: {
...this.chartOptions.scales,
y: {
...this.chartOptions.scales?.y,
suggestedMin: newValue[0],
suggestedMax: newValue[1],
},
},
};
},
immediate: true,
},

smoothing: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
tension: newValue,
};
},
immediate: true,
},
Expand Down Expand Up @@ -373,7 +488,10 @@ export default {
},

checkDashed() {
this.chartOptions.borderDash = [this.borderDash[0], this.borderDash[1]];
this.chartOptions = {
...this.chartOptions,
borderDash: this.isDashed ? [this.borderDash[0], this.borderDash[1]] : [],
};
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/components/PieChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,27 @@ export default {
labels: {
handler(newValue) {
this.localLabels = newValue;
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

variant: {
handler(newValue) {
if (newValue === 'gray' || newValue === 'dark') {
if (newValue === 'gray' || newValue === 'dark') {
this.deleteFirstTwoColors = true;
} else {
this.deleteFirstTwoColors = false;
}

this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},

colors: {
handler() {
this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},
Expand Down
Loading