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
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
126 changes: 123 additions & 3 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,6 +265,24 @@ 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(newValue) {
if (newValue === true) {
Expand All @@ -263,6 +291,95 @@ export default {
},
immediate: true,
},

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

scales: {
handler(newValue) {
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,
},
},

mounted() {
Expand Down Expand Up @@ -373,7 +490,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
28 changes: 25 additions & 3 deletions src/components/PolarAreaChart.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) {
if (newValue === 'gray' || newValue === 'dark') {
if (newValue === 'gray' || newValue === 'dark') {
this.deleteFirstTwoColors = true;
} else {
this.deleteFirstTwoColors = false;
}

this.mergeChartDataNoSelect(this.data);
},
immediate: true,
},
Expand All @@ -147,6 +150,25 @@ export default {
},
immediate: true,
},

isVisiblePointNames: {
handler(newValue) {
this.chartOptions = {
...this.chartOptions,
scales: {
...this.chartOptions.scales,
r: {
...this.chartOptions.scales?.r,
pointLabels: {
...this.chartOptions.scales?.r?.pointLabels,
display: newValue,
},
},
},
};
},
immediate: true,
},
},

methods: {
Expand Down Expand Up @@ -187,7 +209,7 @@ export default {
data.forEach(obj => {
obj.datasets.forEach(state => {
const dataset = {
label: this.showLabelName ? state.name :state.label,
label: state.label,
data: state.data,
name: state.name,
borderRadius: 6,
Expand Down
Loading