Skip to content

Commit

Permalink
VueUiRelationCircle reset on click outside
Browse files Browse the repository at this point in the history
  • Loading branch information
graphieros committed Nov 13, 2023
1 parent 177330f commit 86f87c7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@


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

[Interactive documentation](https://vue-data-ui.graphieros.com/)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-data-ui",
"private": false,
"version": "1.9.1",
"version": "1.9.2",
"type": "module",
"description": "A user-empowering data visualization Vue components library",
"keywords": [
Expand Down
20 changes: 11 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,16 @@ const showLocalTest = ref(false);
<button @click="printRelation">PRINT RELATION CIRCLE</button>
<button @click="printThermo">PRINT THERMO</button>

<div style="max-width: 1000px; margin: 0 auto">
<RelationTest
ref="relation"
:dataset="relationDataset"
:config="relationConfig"
v-if="showLocalTest"
/>
<VueUiRelationCircle ref="relation" v-if="!showLocalTest" :dataset="relationDataset" :config="relationConfig"/>
</div>

<div style="max-width: 1000px; margin: 0 auto; margin-bottom: 48px">
<VueUiSparkline
v-if="!showLocalTest"
Expand Down Expand Up @@ -3678,15 +3688,7 @@ const showLocalTest = ref(false);
<ThermoTest ref="thermo" v-if="showLocalTest" :dataset="thermoDataset" :config="thermoConfig" />
<VueUiThermometer ref="thermo" v-if="!showLocalTest" :dataset="thermoDataset" :config="thermoConfig" />
</div>
<div style="max-width: 1000px; margin: 0 auto">
<RelationTest
ref="relation"
:dataset="relationDataset"
:config="relationConfig"
v-if="showLocalTest"
/>
<VueUiRelationCircle ref="relation" v-if="!showLocalTest" :dataset="relationDataset" :config="relationConfig"/>
</div>

<div style="max-width: 1000px; margin: 0 auto; margin-bottom: 48px">
<VueUiSkeleton
v-if="!showLocalTest"
Expand Down
19 changes: 18 additions & 1 deletion src/components/vue-ui-relation-circle.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, onMounted } from "vue";
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
import { convertConfigColors, treeShake, palette } from "../lib.js";
import pdf from "../pdf";
import mainConfig from "../default_configs.json";
Expand Down Expand Up @@ -75,8 +75,25 @@ const radiusOffset = computed(() => {
onMounted(() => {
createPlots();
createRelations();
const chart = document.getElementById(`relation_circle_${uid.value}`);
chart.addEventListener("click", clickOutside);
});
onBeforeUnmount(() => {
const chart = document.getElementById(`relation_circle_${uid.value}`);
chart.removeEventListener("click", clickOutside);
})
function clickOutside(e) {
const target = e.target;
if(target && Array.from(target.classList).includes("vue-ui-relation-circle-legend")) {
return;
} else {
selectedPlot.value = {};
selectedRelations.value = [];
}
}
function createPlots() {
const angleGap = 6.28319 / limitedDataset.value.length;
const regAngleGap = 360 / limitedDataset.value.length;
Expand Down

0 comments on commit 86f87c7

Please sign in to comment.