1.confine:true
2.tooltip: {
             position: function (pos, params, el, elRect, size) {
                 var obj = {top: 10};
                 obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 30;
                 return obj;
             }
         },

https://www.echartsjs.com/gallery/editor.html?c=doc-example/candlestick-axisPointer