Skip to content

Commit 9b589eb

Browse files
committed
Improvement - VueUiDonut & VueUiNestedDonuts - Expose chart dimensions to config
1 parent 82d5e59 commit 9b589eb

File tree

6 files changed

+29
-9
lines changed

6 files changed

+29
-9
lines changed

TestingArena/ArenaVueUiDonut.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ function alterDataset() {
6666
}
6767
6868
const model = ref([
69-
{ key: 'type', def: 'polar', type: 'select', options: ['classic', 'polar']},
69+
{ key: 'type', def: 'classic', type: 'select', options: ['classic', 'polar']},
70+
{ key: 'style.chart.width', def: 512, type: 'number', min: 0, max: 512 },
71+
{ key: 'style.chart.height', def: 512, type: 'number', min: 0, max: 512 },
72+
7073
{ key: 'serieToggleAnimation.show', def: true, type: 'checkbox'},
7174
{ key: 'serieToggleAnimation.durationMs', def: 500, type: 'number', min: 0, max: 5000, step: 100},
7275
{ key: 'loadAnimation.show', def: true, type: 'checkbox'},

TestingArena/ArenaVueUiNestedDonuts.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ const model = ref([
7878
{ key: 'style.chart.backgroundColor', def: '#FFFFFF20', type: 'color'},
7979
{ key: 'style.chart.color', def: '#1A1A1A', type: 'color'},
8080
81+
{ key: 'style.chart.width', def: 512, type: 'number', min: 0, max: 512 },
82+
{ key: 'style.chart.height', def: 512, type: 'number', min: 0, max: 512 },
83+
8184
{ key: 'style.chart.padding.top', def: 0, type: 'number', min: 0, max: 100},
8285
{ key: 'style.chart.padding.right', def: 48, type: 'number', min: 0, max: 100},
8386
{ key: 'style.chart.padding.bottom', def: 0, type: 'number', min: 0, max: 100},

src/components/vue-ui-donut.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ watch(() => props.config, (_newCfg) => {
251251
mutableConfig.value.dataLabels.show = FINAL_CONFIG.value.style.chart.layout.labels.dataLabels.show;
252252
mutableConfig.value.showTable = FINAL_CONFIG.value.table.show;
253253
mutableConfig.value.showTooltip = FINAL_CONFIG.value.style.chart.tooltip.show;
254+
255+
// Other ref resets
256+
svg.value.height = FINAL_CONFIG.value.style.chart.height;
257+
svg.value.width = FINAL_CONFIG.value.style.chart.width;
254258
}, { deep: true });
255259
256260
const padding = computed(() => {
@@ -287,8 +291,8 @@ const mutableConfig = ref({
287291
});
288292
289293
const svg = ref({
290-
height: 360,
291-
width: 512
294+
height: FINAL_CONFIG.value.style.chart.height,
295+
width: FINAL_CONFIG.value.style.chart.width
292296
});
293297
294298
const donutThickness = computed(() => {

src/components/vue-ui-nested-donuts.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ watch(
139139
tableStep.value += 1;
140140
legendStep.value += 1;
141141
142-
mutableConfig.value.dataLabels.show =
143-
FINAL_CONFIG.value.style.chart.layout.labels.dataLabels.show;
142+
mutableConfig.value.dataLabels.show = FINAL_CONFIG.value.style.chart.layout.labels.dataLabels.show;
144143
mutableConfig.value.showTable = FINAL_CONFIG.value.table.show;
145-
mutableConfig.value.showTooltip =
146-
FINAL_CONFIG.value.style.chart.tooltip.show;
144+
mutableConfig.value.showTooltip = FINAL_CONFIG.value.style.chart.tooltip.show;
145+
146+
// Other ref resets
147+
svg.value.width = FINAL_CONFIG.value.style.chart.width;
148+
svg.value.height = FINAL_CONFIG.value.style.chart.height;
147149
},
148150
{ deep: true }
149151
);
@@ -357,8 +359,8 @@ const mutableConfig = ref({
357359
});
358360
359361
const svg = ref({
360-
height: 512,
361-
width: 512,
362+
width: FINAL_CONFIG.value.style.chart.width,
363+
height: FINAL_CONFIG.value.style.chart.height,
362364
});
363365
364366
const emit = defineEmits(["selectLegend", "selectDatapoint"]);

src/useConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ export function useConfig() {
740740
backgroundColor: COLOR_WHITE,
741741
color: COLOR_BLACK,
742742
padding: PADDING([0,0,0,0]),
743+
width: 512,
744+
height: 360,
743745
layout: {
744746
curvedMarkers: false,
745747
labels: {
@@ -3225,6 +3227,8 @@ export function useConfig() {
32253227
useGradient: true,
32263228
gradientIntensity: 40,
32273229
padding: PADDING([0,0,0,0]),
3230+
width: 512,
3231+
height: 512,
32283232
layout: {
32293233
labels: {
32303234
dataLabels: {

types/vue-data-ui.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,6 +3033,8 @@ declare module "vue-data-ui" {
30333033
backgroundColor?: string;
30343034
color?: string;
30353035
padding?: ChartPadding;
3036+
width?: number;
3037+
height?: number;
30363038
layout?: {
30373039
curvedMarkers?: boolean;
30383040
labels?: {
@@ -3221,6 +3223,8 @@ declare module "vue-data-ui" {
32213223
backgroundColor?: string;
32223224
color?: string;
32233225
padding?: ChartPadding;
3226+
width?: number;
3227+
height?: number;
32243228
layout?: {
32253229
labels?: {
32263230
dataLabels?: {

0 commit comments

Comments
 (0)