Skip to content

Commit 86f87c7

Browse files
committed
VueUiRelationCircle reset on click outside
1 parent 177330f commit 86f87c7

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010

1111
# vue-data-ui
12+
![npm](https://img.shields.io/npm/v/vue-data-ui)
1213
[![MadeWithVueJs.com shield](https://madewithvuejs.com/storage/repo-shields/4526-shield.svg)](https://madewithvuejs.com/p/vue-data-ui/shield-link)
13-
[![Socket Badge](https://socket.dev/api/badge/npm/package/vue-data-ui)](https://socket.dev/npm/package/vue-data-ui)
1414
![GitHub issues](https://img.shields.io/github/issues/graphieros/vue-data-ui)
15+
![NPM](https://img.shields.io/npm/l/vue-data-ui)
16+
![npm](https://img.shields.io/npm/dt/vue-data-ui)
1517
![Static Badge](https://img.shields.io/badge/components-26-green)
1618

1719
[Interactive documentation](https://vue-data-ui.graphieros.com/)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-data-ui",
33
"private": false,
4-
"version": "1.9.1",
4+
"version": "1.9.2",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3532,6 +3532,16 @@ const showLocalTest = ref(false);
35323532
<button @click="printRelation">PRINT RELATION CIRCLE</button>
35333533
<button @click="printThermo">PRINT THERMO</button>
35343534

3535+
<div style="max-width: 1000px; margin: 0 auto">
3536+
<RelationTest
3537+
ref="relation"
3538+
:dataset="relationDataset"
3539+
:config="relationConfig"
3540+
v-if="showLocalTest"
3541+
/>
3542+
<VueUiRelationCircle ref="relation" v-if="!showLocalTest" :dataset="relationDataset" :config="relationConfig"/>
3543+
</div>
3544+
35353545
<div style="max-width: 1000px; margin: 0 auto; margin-bottom: 48px">
35363546
<VueUiSparkline
35373547
v-if="!showLocalTest"
@@ -3678,15 +3688,7 @@ const showLocalTest = ref(false);
36783688
<ThermoTest ref="thermo" v-if="showLocalTest" :dataset="thermoDataset" :config="thermoConfig" />
36793689
<VueUiThermometer ref="thermo" v-if="!showLocalTest" :dataset="thermoDataset" :config="thermoConfig" />
36803690
</div>
3681-
<div style="max-width: 1000px; margin: 0 auto">
3682-
<RelationTest
3683-
ref="relation"
3684-
:dataset="relationDataset"
3685-
:config="relationConfig"
3686-
v-if="showLocalTest"
3687-
/>
3688-
<VueUiRelationCircle ref="relation" v-if="!showLocalTest" :dataset="relationDataset" :config="relationConfig"/>
3689-
</div>
3691+
36903692
<div style="max-width: 1000px; margin: 0 auto; margin-bottom: 48px">
36913693
<VueUiSkeleton
36923694
v-if="!showLocalTest"

src/components/vue-ui-relation-circle.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup>
2-
import { ref, computed, onMounted } from "vue";
2+
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
33
import { convertConfigColors, treeShake, palette } from "../lib.js";
44
import pdf from "../pdf";
55
import mainConfig from "../default_configs.json";
@@ -75,8 +75,25 @@ const radiusOffset = computed(() => {
7575
onMounted(() => {
7676
createPlots();
7777
createRelations();
78+
const chart = document.getElementById(`relation_circle_${uid.value}`);
79+
chart.addEventListener("click", clickOutside);
7880
});
7981
82+
onBeforeUnmount(() => {
83+
const chart = document.getElementById(`relation_circle_${uid.value}`);
84+
chart.removeEventListener("click", clickOutside);
85+
})
86+
87+
function clickOutside(e) {
88+
const target = e.target;
89+
if(target && Array.from(target.classList).includes("vue-ui-relation-circle-legend")) {
90+
return;
91+
} else {
92+
selectedPlot.value = {};
93+
selectedRelations.value = [];
94+
}
95+
}
96+
8097
function createPlots() {
8198
const angleGap = 6.28319 / limitedDataset.value.length;
8299
const regAngleGap = 360 / limitedDataset.value.length;

0 commit comments

Comments
 (0)