diff --git a/package-lock.json b/package-lock.json index ce3e3f5a..96e0aad4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vue-data-ui", - "version": "1.9.11", + "version": "1.9.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vue-data-ui", - "version": "1.9.11", + "version": "1.9.12", "license": "MIT", "devDependencies": { "@vitejs/plugin-vue": "^4.2.3", diff --git a/package.json b/package.json index aa5bdcf2..0018f2c1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-data-ui", "private": false, - "version": "1.9.12", + "version": "1.9.13", "type": "module", "description": "A user-empowering data visualization Vue components library", "keywords": [ diff --git a/src/App.vue b/src/App.vue index 331da128..aea66961 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,6 +10,7 @@ * */ import { ref, computed, onMounted } from "vue"; +import PROD_CONFIG from "./default_configs.json"; import Box from "./Box.vue"; import TableTest from "./components/vue-ui-table.vue"; import DonutTest from "./components/vue-ui-donut.vue"; @@ -190,12 +191,6 @@ const config = ref({ show: true, }, }, - table: { - rounding: 1, - th: { - backgroundColor: "#FF0000", - }, - }, }); const head = ref([ @@ -3433,43 +3428,32 @@ const histoDataset = ref([ ]); const showLocalTest = ref(false); + +function copyConfig(c) { + let selBox = document.createElement('textarea'); + selBox.style.position = 'fixed'; + selBox.style.left = '0'; + selBox.style.top = '0'; + selBox.style.opacity = '0'; + selBox.value = JSON.stringify(c); + document.body.appendChild(selBox); + selBox.focus(); + selBox.select(); + document.execCommand('copy'); + document.body.removeChild(selBox); +} + + + \ No newline at end of file diff --git a/src/atoms/DataTable.vue b/src/atoms/DataTable.vue new file mode 100644 index 00000000..f5e47dec --- /dev/null +++ b/src/atoms/DataTable.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/src/atoms/UserOptions.vue b/src/atoms/UserOptions.vue index 205208d9..38df7ae7 100644 --- a/src/atoms/UserOptions.vue +++ b/src/atoms/UserOptions.vue @@ -11,6 +11,10 @@ const props = defineProps({ type: Boolean, default: true, }, + hasImg: { + type: Boolean, + default: false, + }, color: { type: String, }, @@ -21,6 +25,10 @@ const props = defineProps({ type: Boolean, default: false, }, + isImaging: { + type: Boolean, + default: false, + }, title: { type: String, }, @@ -29,7 +37,7 @@ const props = defineProps({ } }); -const emit = defineEmits(['generatePdf', 'generateXls']); +const emit = defineEmits(['generatePdf', 'generateXls', 'generateImage']); function generatePdf() { emit('generatePdf'); @@ -39,9 +47,14 @@ function generateXls() { emit('generateXls'); } +function generateImage() { + emit('generateImage'); +} + const details = ref(null); function close() { + if(props.isPrinting || props.isImaging) return; if(details.value) { details.value.removeAttribute('open') } @@ -70,6 +83,17 @@ function close() { + diff --git a/src/components/vue-ui-age-pyramid.vue b/src/components/vue-ui-age-pyramid.vue index fdb1f70a..635b52b2 100644 --- a/src/components/vue-ui-age-pyramid.vue +++ b/src/components/vue-ui-age-pyramid.vue @@ -2,6 +2,7 @@ import { ref, computed, nextTick } from "vue"; import { opacity, makeXls, shiftHue } from '../lib'; import pdf from "../pdf"; +import img from "../img"; import mainConfig from "../default_configs.json"; import { useMouse } from "../useMouse"; import { calcTooltipPosition } from "../calcTooltipPosition"; @@ -28,6 +29,7 @@ const uid = ref(`vue-ui-age-pyramid-${Math.random()}`); const defaultConfig = ref(mainConfig.vue_ui_age_pyramid); +const isImaging = ref(false); const isPrinting = ref(false); const agePyramid = ref(null); const tooltip = ref(null); @@ -206,16 +208,41 @@ function hoverIndex(index) { isTooltip.value = true; } -function generatePdf(){ +const __to__ = ref(null); + +function showSpinnerPdf() { isPrinting.value = true; - nextTick(() => { +} + +function generatePdf(){ + showSpinnerPdf(); + clearTimeout(__to__.value); + __to__.value = setTimeout(() => { pdf({ domElement: document.getElementById(`vue-ui-age-pyramid_${uid.value}`), fileName: agePyramidConfig.value.style.title.text || 'vue-ui-age-pyramid' }).finally(() => { isPrinting.value = false; }); - }) + }, 100) +} + +function showSpinnerImage() { + isImaging.value = true; +} + +function generateImage() { + showSpinnerImage(); + clearTimeout(__to__.value); + __to__.value = setTimeout(() => { + img({ + domElement: document.getElementById(`vue-ui-age-pyramid_${uid.value}`), + fileName: agePyramidConfig.value.style.title.text || 'vue-ui-age-pyramid', + format: 'png' + }).finally(() => { + isImaging.value = false; + }) + }, 100) } function generateXls() { @@ -240,7 +267,8 @@ function generateXls() { defineExpose({ generatePdf, - generateXls + generateXls, + generateImage }); @@ -275,11 +303,14 @@ defineExpose({ v-if="agePyramidConfig.userOptions.show" :backgroundColor="agePyramidConfig.style.backgroundColor" :color="agePyramidConfig.style.color" + :isImaging="isImaging" :isPrinting="isPrinting" :title="agePyramidConfig.userOptions.title" :uid="uid" + :hasImg="true" @generatePdf="generatePdf" @generateXls="generateXls" + @generateImage="generateImage" >