I am to write indexLabel dynamically above or below the line graph (logic is if the value is less than pervious month then it will be below the graph). But what is my code render is not similar. I think indexLabelPlacement is not working for line graph.
my code:
for (var i = 0; i < salesData.length; i++) {
var currentValue = salesData[i].MachinesSold;
var previousValue = i > 0 ? salesData[i – 1].MachinesSold : currentValue; // Get the previous value or default to the first
// Determine whether to place the label above or below based on comparison with the previous month
var labelPlacement = currentValue < previousValue ? “inside” : “outside”;
// Push data with the correct label placement
dataPoints.push({
y: currentValue,
label: salesData[i].Month,
indexLabel: currentValue.toString(),
indexLabelPlacement: labelPlacement, // Dynamic label placement
indexLabelFontSize: 14,
indexLabelFontColor: “black”
});
}