Skip to content

Commit b3c0553

Browse files
committed
Fix - VueUiXy - Avoid annotation error when config.chart is not set
1 parent 0819d55 commit b3c0553

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/components/vue-ui-xy.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function prepareConfig() {
242242
mergedConfig.chart.grid.labels.yAxis.groupColor = null;
243243
}
244244
245-
if (props.config && props.config.chart.annotations && Array.isArray(props.config.chart.annotations) && props.config.chart.annotations.length) {
245+
if (props.config && hasDeepProperty(props.config, 'chart.annotations') && Array.isArray(props.config.chart.annotations) && props.config.chart.annotations.length) {
246246
mergedConfig.chart.annotations = props.config.chart.annotations.map(annotation => {
247247
return useNestedProp({
248248
defaultConfig: DEFAULT_CONFIG.chart.annotations[0],
@@ -2936,7 +2936,6 @@ defineExpose({
29362936
<div ref="noTitle" v-if="hasOptionsNoTitle" class="vue-data-ui-no-title-space"
29372937
:style="`height:36px; width: 100%; background:transparent`" />
29382938
2939-
<!-- TITLE AS OUTSIDE DIV -->
29402939
<div ref="chartTitle" class="vue-ui-xy-title" v-if="FINAL_CONFIG.chart.title.show"
29412940
:style="`font-family:${FINAL_CONFIG.chart.fontFamily}`">
29422941
<Title :key="`title_${titleStep}`" :config="{
@@ -4216,19 +4215,26 @@ defineExpose({
42164215
42174216
<!-- LEGEND -->
42184217
<Teleport v-if="readyTeleport" :to="FINAL_CONFIG.chart.legend.position === 'top' ? `#legend-top-${uniqueId}` : `#legend-bottom-${uniqueId}`">
4219-
<div ref="chartLegend" data-cy="xy-div-legend" v-if="FINAL_CONFIG.chart.legend.show" class="vue-ui-xy-legend"
4220-
:style="`font-size:${FINAL_CONFIG.chart.legend.fontSize}px`">
4218+
<div
4219+
ref="chartLegend"
4220+
data-cy="xy-div-legend"
4221+
v-if="FINAL_CONFIG.chart.legend.show"
4222+
class="vue-ui-xy-legend"
4223+
:style="{
4224+
fontSize: `var(--legend-font-size, ${(FINAL_CONFIG.chart.legend.fontSize ?? 14)}px)`
4225+
}"
4226+
>
42214227
<div v-for="(legendItem, i) in absoluteDataset" :data-cy="`xy-div-legend-item-${i}`"
42224228
:key="`div_legend_item_${i}`" @click="segregate(legendItem)"
42234229
:class="{ 'vue-ui-xy-legend-item-alone': absoluteDataset.length === 1 , 'vue-ui-xy-legend-item': true, 'vue-ui-xy-legend-item-segregated': segregatedSeries.includes(legendItem.id) }">
4224-
<svg v-if="icons[legendItem.type] === 'line'" viewBox="0 0 20 12" height="14" width="20">
4230+
<svg v-if="icons[legendItem.type] === 'line'" viewBox="0 0 20 12" height="1em" width="1.43em">
42254231
<rect x="0" y="7.5" rx="1.5" :stroke="FINAL_CONFIG.chart.backgroundColor" :stroke-width="0.5"
42264232
height="3" width="20" :fill="legendItem.color" />
42274233
<Shape :plot="{ x: 10, y: 9 }" :radius="4" :color="legendItem.color"
42284234
:shape="['triangle', 'square', 'diamond', 'pentagon', 'hexagon', 'star'].includes(legendItem.shape) ? legendItem.shape : 'circle'"
42294235
:stroke="FINAL_CONFIG.chart.backgroundColor" :strokeWidth="0.5" />
42304236
</svg>
4231-
<svg v-else-if="icons[legendItem.type] === 'bar'" viewBox="0 0 40 40" height="14" width="14">
4237+
<svg v-else-if="icons[legendItem.type] === 'bar'" viewBox="0 0 40 40" height="1em" width="1em">
42324238
<rect
42334239
v-if="icons[legendItem.type] === 'bar' && $slots.pattern"
42344240
x="4"
@@ -4250,7 +4256,7 @@ defineExpose({
42504256
:fill="$slots.pattern ? `url(#pattern_${uniqueId}_${legendItem.slotAbsoluteIndex})` : legendItem.color"
42514257
/>
42524258
</svg>
4253-
<svg v-else viewBox="0 0 12 12" height="14" width="14">
4259+
<svg v-else viewBox="0 0 12 12" height="1em" width="1em">
42544260
<Shape :plot="{ x: 6, y: 6 }" :radius="5" :color="legendItem.color"
42554261
:shape="['triangle', 'square', 'diamond', 'pentagon', 'hexagon', 'star'].includes(legendItem.shape) ? legendItem.shape : 'circle'" />
42564262
</svg>

0 commit comments

Comments
 (0)