@@ -2500,6 +2500,42 @@ useTimeLabelCollision({
25002500 rotation: FINAL_CONFIG .value .chart .grid .labels .xAxisLabels .autoRotate .angle
25012501});
25022502
2503+ const useCustomFormatTimeTag = ref (false );
2504+
2505+ const timeTagContent = computed (() => {
2506+ if ([null , undefined ].includes (selectedSerieIndex .value ) && [null , undefined ].includes (selectedMinimapIndex .value )) return ' '
2507+
2508+ const index = (selectedSerieIndex .value != null ? selectedSerieIndex .value : 0 ) || (selectedMinimapIndex .value != null ? selectedMinimapIndex .value : 0 );
2509+
2510+ const customFormat = FINAL_CONFIG .value .chart .timeTag .customFormat ;
2511+ useCustomFormatTimeTag .value = false ;
2512+
2513+ if (isFunction (customFormat)) {
2514+ try {
2515+ const customFormatString = customFormat ({
2516+ absoluteIndex: index + slicer .value .start ,
2517+ seriesIndex: index,
2518+ datapoint: selectedSeries .value ,
2519+ bars: barSet .value ,
2520+ lines: lineSet .value ,
2521+ plots: plotSet .value ,
2522+ config: FINAL_CONFIG .value
2523+ });
2524+ if (typeof customFormatString === ' string' ) {
2525+ useCustomFormatTimeTag .value = true ;
2526+ return customFormatString
2527+ }
2528+ } catch (err) {
2529+ console .warn (' Custom format cannot be applied on timeTag.' );
2530+ useCustomFormatTimeTag .value = false ;
2531+ }
2532+ }
2533+
2534+ if (! useCustomFormatTimeTag .value ) {
2535+ return ! [null , undefined ].includes (timeLabels .value [index] ) ? timeLabels .value [index].text : ' '
2536+ }
2537+ });
2538+
25032539// Force reflow when component is mounted in a hidden div
25042540
25052541watch (() => props .dataset , (_ ) => {
@@ -2539,24 +2575,24 @@ watch(() => props.config, (_) => {
25392575const isActuallyVisible = ref (false )
25402576
25412577function recomputeVisibility () {
2542- const el = chart .value ? .parentNode
2543- if (! el) { isActuallyVisible .value = false ; return }
2544- const r = el .getBoundingClientRect ()
2545- isActuallyVisible .value = r .width > 2 && r .height > 2
2578+ const el = chart .value ? .parentNode
2579+ if (! el) { isActuallyVisible .value = false ; return }
2580+ const r = el .getBoundingClientRect ()
2581+ isActuallyVisible .value = r .width > 2 && r .height > 2
25462582}
25472583
25482584onMounted (() => {
2549- recomputeVisibility ()
2550- const ro = new ResizeObserver (() => {
25512585 recomputeVisibility ()
2552- if (isActuallyVisible .value ) {
2553- // re-measure and re-init once we have size
2554- prepareChart ()
2555- normalizeSlicerWindow ()
2556- setupSlicer ()
2557- }
2558- })
2559- if (chart .value ? .parentNode ) ro .observe (chart .value .parentNode )
2586+ const ro = new ResizeObserver (() => {
2587+ recomputeVisibility ()
2588+ if (isActuallyVisible .value ) {
2589+ // re-measure and re-init once we have size
2590+ prepareChart ()
2591+ normalizeSlicerWindow ()
2592+ setupSlicer ()
2593+ }
2594+ })
2595+ if (chart .value ? .parentNode ) ro .observe (chart .value .parentNode )
25602596})
25612597
25622598// v3 - Essential to make shifting between loading config and final config work
@@ -3584,15 +3620,9 @@ defineExpose({
35843620 : x= " drawingArea.left + (drawingArea.width / maxSeries) * ((selectedSerieIndex !== null ? selectedSerieIndex : 0) || (selectedMinimapIndex !== null ? selectedMinimapIndex : 0)) - 100 + (drawingArea.width / maxSeries / 2)"
35853621 : y= " drawingArea.bottom" width= " 200" height= " 40" style= " overflow: visible !important;" >
35863622 < div class = " vue-ui-xy-time-tag"
3587- : style= " `width: fit-content;margin: 0 auto;text-align:center;padding:3px 12px;background:${FINAL_CONFIG.chart.timeTag.backgroundColor};color:${FINAL_CONFIG.chart.timeTag.color};font-size:${FINAL_CONFIG.chart.timeTag.fontSize}px`" >
3588- {{ (timeLabels[(selectedSerieIndex !== null ? selectedSerieIndex : 0 ) ||
3589- (selectedMinimapIndex !== null ?
3590- selectedMinimapIndex : 0 )] ? timeLabels[(selectedSerieIndex !== null ? selectedSerieIndex : 0 ) ||
3591- (selectedMinimapIndex !== null ?
3592- selectedMinimapIndex : 0 )].text : ' ' ) || ((selectedSerieIndex !== null ? selectedSerieIndex :
3593- 0 ) ||
3594- (selectedMinimapIndex !== null ? selectedMinimapIndex : 0 )) }}
3595- < / div>
3623+ : style= " `width: fit-content;margin: 0 auto;text-align:center;padding:3px 12px;background:${FINAL_CONFIG.chart.timeTag.backgroundColor};color:${FINAL_CONFIG.chart.timeTag.color};font-size:${FINAL_CONFIG.chart.timeTag.fontSize}px`"
3624+ v- html= " timeTagContent"
3625+ / >
35963626 < / foreignObject>
35973627 < circle
35983628 : cx= " drawingArea.left + (drawingArea.width / maxSeries) * ((selectedSerieIndex !== null ? selectedSerieIndex : 0) || (selectedMinimapIndex !== null ? selectedMinimapIndex : 0)) + (drawingArea.width / maxSeries / 2)"
0 commit comments