From a9f7024b7a6c5b887c9031ddbbf88b4c65dabb03 Mon Sep 17 00:00:00 2001 From: graphieros Date: Thu, 7 Mar 2024 08:35:02 +0100 Subject: [PATCH] Added customFormat config option for customizable tooltip contents --- README.md | 11 + package-lock.json | 4 +- package.json | 2 +- src/App.vue | 337 +++++++++++++------------ src/components/vue-ui-age-pyramid.vue | 57 +++-- src/components/vue-ui-candlestick.vue | 69 +++-- src/components/vue-ui-donut.vue | 49 ++-- src/components/vue-ui-heatmap.vue | 31 ++- src/components/vue-ui-molecule.vue | 30 ++- src/components/vue-ui-quadrant.vue | 48 +++- src/components/vue-ui-radar.vue | 43 +++- src/components/vue-ui-rings.vue | 66 +++-- src/components/vue-ui-scatter.vue | 51 ++-- src/components/vue-ui-vertical-bar.vue | 49 ++-- src/components/vue-ui-waffle.vue | 39 ++- src/components/vue-ui-xy.vue | 153 ++++++----- src/default_configs.json | 38 ++- src/lib.js | 2 +- types/vue-data-ui.d.ts | 311 +++++++++++++++++++++++ 19 files changed, 974 insertions(+), 416 deletions(-) diff --git a/README.md b/README.md index 98543382..19a30579 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,17 @@ Types are available in the 'vue-data-ui.d.ts' file under the types directory of ## Nuxt [This repo contains a boilerplate implementation of the vue-data-ui package in Nuxt](https://github.com/graphieros/vue-data-ui-nuxt) +# Customizable tooltips +Charts with tooltips have a config option to customize tooltip contents: + +``` + +customFormat: ({ seriesIndex, datapoint, series, config }) => { + return `
${ ... }
`; +} + +``` + # Slots Most Vue Data UI chart components include a #svg slot you can use to introduce customized svg elements (shapes, text, etc). diff --git a/package-lock.json b/package-lock.json index e891a5f7..fd23b245 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vue-data-ui", - "version": "2.0.3", + "version": "2.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vue-data-ui", - "version": "2.0.3", + "version": "2.0.5", "license": "MIT", "devDependencies": { "@vitejs/plugin-vue": "^4.2.3", diff --git a/package.json b/package.json index f11089bc..ad287b61 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue-data-ui", "private": false, - "version": "2.0.4", + "version": "2.0.5", "type": "module", "description": "A user-empowering data visualization Vue components library", "keywords": [ diff --git a/src/App.vue b/src/App.vue index c80cb98a..72f1d7c0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -396,8 +396,6 @@ const radarDataset = ref({ ], }); -const radarConfig = ref(getVueDataUiConfig('vue_ui_radar')) - const quadrantDataset = ref([ { name: "category 1", @@ -921,63 +919,6 @@ const weeks = computed(() => { return arr; }); -const heatmapConfig = ref({ - style: { - layout: { - useDiv: true, - padding: { - bottom: 48, - }, - cells: { - value: { - show: true, - fontSize: 10 - }, - spacing: 2 - }, - dataLabels: { - prefix: "$", - suffix: "£", - yAxis: { - fontSize: 24, - }, - xAxis: { - fontSize: 24, - values: weeks.value, - }, - }, - }, - title: { - text: "Title", - subtitle: { - text: "Subtitle", - }, - }, - }, -}); - -const scatterConfig = ref({ - style: { - layout: { - useDiv: true, - dataLabels: { - xAxis: { - name: "xAxis", - }, - yAxis: { - name: "yAxis", - }, - }, - }, - title: { - text: "Title", - subtitle: { - text: "Subtitle", - }, - }, - }, -}); - const scat1 = computed(() => { const arr = []; for (let i = -50; i < 50; i += 1) { @@ -1016,20 +957,6 @@ const scatterDataset = computed(() => { ]; }); -const candlestickConfig = ref({ - style: { - layout: { - useDiv: true, - }, - title: { - text: "Title", - subtitle: { - text: "Subtitle", - }, - }, - }, -}); - // date | open | high | low | last | volume const candlestickDataset = ref([ ["2024-01-01", 56, 120, 40, 110, 1250], @@ -1059,20 +986,6 @@ const barset = ref([ }, ]); -const pyramidConfig = ref({ - style: { - layout: { - useDiv: true, - }, - title: { - text: "France", - subtitle: { - text: "2022", - }, - }, - }, -}); - const pyramidDataset = ref([ ["2022", 0, 330929, 345538], ["2021", 1, 343026, 357351], @@ -1315,15 +1228,6 @@ const dashboardConfig = ref({ }); const comps = ref([ - { - id: 1, - width: 40, - height: 30, - left: 2, - top: 4, - component: "VueUiCandlestick", - props: { config: candlestickConfig, dataset: candlestickDataset }, - }, { id: 2, width: 20, @@ -2007,26 +1911,6 @@ const histoDataset = ref([ }, ]); -const ringsConfig = ref({ - style: { - chart: { - layout: { - labels: { - dataLabels: { - prefix: "$", - suffix: "£" - } - } - }, - title: { - text: "Title", - subtitle: { - text: "Subtitle" - } - } - } - } -}); const ringsDataset = ref([ { name: "Serie 1", @@ -2418,6 +2302,157 @@ const moodRadarConfig = ref({ } }) +const donutConfig = ref({ + style: { + chart: { + tooltip: { + customFormat: ({ datapoint, seriesIndex, series , config}) => { + console.log({datapoint, seriesIndex, series, config}); + return `
+ ${datapoint.name} +
` + } + } + } + } +}) + +const xyConfig = ref({ + chart: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, bars, lines, plots, config }) => { + console.log({seriesIndex, datapoint, series, bars, lines, plots, config}); + return 'TEST' + } + } + } +}) + +const waffleConfig = ref({ + style: { + chart: { + tooltip: { + customFormat: ({seriesIndex, datapoint, series, config}) => { + console.log({seriesIndex, datapoint, series, config}) + return "TEST" + } + } + } + } +}) + +const radarConfig = ref({ + style: { + chart: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({seriesIndex, datapoint, series, config}) + return "TEST" + } + } + } + } +}) + +const quadrantConfig = ref({ + style: { + chart: { + tooltip: { + showShape: false, + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({seriesIndex, datapoint, series, config}) + return datapoint.name + } + } + } + } +}) + +const verticalBarConfig = ref({ + style: { + chart: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({seriesIndex, datapoint, series, config}); + return datapoint.name + } + } + } + } +}) + +const heatmapConfig = ref({ + style: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({seriesIndex, datapoint, series, config}); + return "TEST" + } + } + } +}) + +const scatterConfig = ref({ + style: { + tooltip: { + showShape: false, + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({ seriesIndex, datapoint, series, config }); + return "TEST" + } + } + } +}) + +const candlestickConfig = ref({ + style: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({ seriesIndex, datapoint, series, config }); + return "TEST" + } + } + } +}) + +const pyramidConfig = ref({ + style: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({ seriesIndex, datapoint, series, config }); + return "TEST" + } + } + } +}) + +const ringsConfig = ref({ + style: { + chart: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + console.log({ seriesIndex, datapoint, series, config }); + return "TEST" + } + } + } + } +}) + +const moleculeConfig = ref({ + style: { + chart: { + tooltip: { + customFormat: ({ seriesIndex, datapoint, series, config }) => { + // seriesIndex will always be -1: hide in docs + console.log({ seriesIndex, datapoint, series, config }) + return "TEST" + } + } + } + } +}) +