Custom label position Candlestick

by core972

HTML

<script src="https://code.highcharts.com/stock/highstock.js"></script>

<div id="container" style="height: 400px; min-width: 310px"></div>

JavaScript

Highcharts.stockChart('container', {
			chart: {
				events: {
					render: function() {
						try {
							this.series[0].data.forEach(point => {
								if (point.Entry_type === "B") {
									point.dataLabel.attr({y: point.plotLow});
								} else if (point.Entry_type === "S") {
									point.dataLabel.attr({y: point.plotHigh - 20});
								}
							});
						} catch (error) {
							
						}
					}
				}
			},
			series: [{
				type: 'candlestick',
				name: 'AAPL Stock Price',
				dataLabels: {
					enabled: true,
          backgroundColor: "#fdfc59",
          shape: "circle",
					formatter: function () {
						return this.point.Entry_type;
					}
				},
				data: [
				{
					x: 1606314600000,
					open: 115.55,
					close: 116.75,
					low: 115.17,
					high: 116.03,
					Entry_type: "B"
				},
				{
					x: 1606487400000,
					open: 116.57,
					close: 117.49,
					low: 116.22,
					high: 116.59,
					Entry_type: "B"
				},
				{
					x: 1606746600000,
					open: 116.97,
					close: 120.97,
					low: 116.81,
					high: 119.05,
					Entry_type: "B"
				},
				{
					x: 1606833000000,
					open: 121.01,
					close: 118.47,
					low: 118.01,
					high: 122.72,
					Entry_type: "S"
				},
				{
					x: 1606919400000,
					open: 118.47,
					close: 115.37,
					low: 115.18,
					high: 118.47,
					Entry_type: "S"
				},
				{
					x: 1607005800000,
					open: 115.37,
					close: 119.78,
					low: 115.37,
					high: 119.78,
					Entry_type: "B"
				}
				]
			}],
			xAxis: {
				type: "datetime",
			}
		});