99 downloadCsv ,
1010 error ,
1111 functionReturnsString ,
12+ hasDeepProperty ,
1213 isFunction ,
1314 objectIsEmpty ,
1415 setOpacity ,
@@ -83,16 +84,37 @@ function prepareConfig() {
8384 userConfig: props .config ,
8485 defaultConfig: DEFAULT_CONFIG
8586 });
87+
88+ let finalConfig = {};
89+
8690 if (mergedConfig .theme ) {
87- return {
91+ finalConfig = {
8892 ... useNestedProp ({
8993 userConfig: themes .vue_ui_candlestick [mergedConfig .theme ] || props .config ,
9094 defaultConfig: mergedConfig
9195 }),
9296 }
9397 } else {
94- return mergedConfig;
98+ finalConfig = mergedConfig;
99+ }
100+
101+ // ------------------------------ OVERRIDES -----------------------------------
102+
103+ if (props .config && hasDeepProperty (props .config , ' style.zoom.startIndex' )) {
104+ finalConfig .style .zoom .startIndex = props .config .style .zoom .startIndex ;
105+ } else {
106+ finalConfig .style .zoom .startIndex = null ;
95107 }
108+
109+ if (props .config && hasDeepProperty (props .config , ' style.zoom.endIndex' )) {
110+ finalConfig .style .zoom .endIndex = props .config .style .zoom .endIndex ;
111+ } else {
112+ finalConfig .style .zoom .endIndex = null ;
113+ }
114+
115+ // ----------------------------------------------------------------------------
116+
117+ return finalConfig;
96118}
97119
98120watch (() => props .config , (_newCfg ) => {
@@ -161,6 +183,7 @@ function prepareChart() {
161183 resizeObserver .value = new ResizeObserver (handleResize);
162184 resizeObserver .value .observe (candlestickChart .value .parentNode );
163185 }
186+ setupSlicer ();
164187}
165188
166189onBeforeUnmount (() => {
@@ -384,11 +407,45 @@ function useTooltip(index, datapoint) {
384407}
385408
386409function refreshSlicer () {
387- slicer .value = {
388- start: 0 ,
389- end: len .value
390- };
391- slicerStep .value += 1 ;
410+ setupSlicer ();
411+ }
412+
413+ const slicerComponent = ref (null );
414+
415+ async function setupSlicer () {
416+ if ((FINAL_CONFIG .value .style .zoom .startIndex !== null || FINAL_CONFIG .value .style .zoom .endIndex !== null ) && slicerComponent .value ) {
417+ if (FINAL_CONFIG .value .style .zoom .startIndex !== null ) {
418+ await nextTick ();
419+ await nextTick ();
420+ slicerComponent .value && slicerComponent .value .setStartValue (FINAL_CONFIG .value .style .zoom .startIndex );
421+ }
422+ if (FINAL_CONFIG .value .style .zoom .endIndex !== null ) {
423+ await nextTick ();
424+ await nextTick ();
425+ slicerComponent .value && slicerComponent .value .setEndValue (validSlicerEnd (FINAL_CONFIG .value .style .zoom .endIndex + 1 ));
426+ }
427+ } else {
428+ slicer .value = {
429+ start: 0 ,
430+ end: len .value
431+ };
432+ slicerStep .value += 1 ;
433+ }
434+ }
435+
436+ function validSlicerEnd (v ) {
437+ const max = len .value ;
438+ if (v > max) {
439+ return max;
440+ }
441+ if (v < 0 || (FINAL_CONFIG .value .style .zoom .startIndex !== null && v < FINAL_CONFIG .value .style .zoom .startIndex )) {
442+ if (FINAL_CONFIG .value .style .zoom .startIndex !== null ) {
443+ return FINAL_CONFIG .value .style .zoom .startIndex + 1 ;
444+ } else {
445+ return 1 ;
446+ }
447+ }
448+ return v;
392449}
393450
394451function generateCsv () {
@@ -776,7 +833,8 @@ defineExpose({
776833 />
777834
778835 <div ref =" chartSlicer" v-if =" FINAL_CONFIG.style.zoom.show && isDataset" >
779- <Slicer
836+ <Slicer
837+ ref =" slicerComponent"
780838 :key =" `slicer_${slicerStep}`"
781839 :background =" FINAL_CONFIG.style.zoom.color"
782840 :borderColor =" FINAL_CONFIG.style.backgroundColor"
@@ -793,6 +851,8 @@ defineExpose({
793851 :valueEnd =" slicer.end"
794852 v-model:start =" slicer.start"
795853 v-model:end =" slicer.end"
854+ :refreshStartPoint =" FINAL_CONFIG.style.zoom.startIndex !== null ? FINAL_CONFIG.style.zoom.startIndex : 0"
855+ :refreshEndPoint =" FINAL_CONFIG.style.zoom.endIndex !== null ? FINAL_CONFIG.style.zoom.endIndex + 1 : len"
796856 @reset =" refreshSlicer"
797857 >
798858 <template #reset-action =" { reset } " >
@@ -823,6 +883,7 @@ defineExpose({
823883 :offsetY =" FINAL_CONFIG.style.tooltip.offsetY"
824884 :parent =" candlestickChart"
825885 :content =" tooltipContent"
886+ :isFullscreen =" isFullscreen"
826887 :isCustom =" FINAL_CONFIG.style.tooltip.customFormat && typeof FINAL_CONFIG.style.tooltip.customFormat === 'function'"
827888 >
828889 <template #tooltip-before >
0 commit comments