add annotations properly now
This commit is contained in:
@@ -190,24 +190,22 @@
|
||||
|
||||
// Add annotations for changes greater than 5000
|
||||
const annotations = [];
|
||||
for (let i = 1; i < chartData.length; i++) {
|
||||
const previousAmount = chartData[i - 1][1];
|
||||
const currentAmount = chartData[i][1];
|
||||
const difference = Math.abs(currentAmount - previousAmount);
|
||||
if (difference > 5000) {
|
||||
annotations.push({
|
||||
labels: [{
|
||||
point: {
|
||||
x: chartData[i][0], // Time of the data point
|
||||
y: chartData[i][1], // Amount at that point
|
||||
xAxis: 0,
|
||||
yAxis: 0
|
||||
},
|
||||
text: `Change: ${difference.toFixed(2)}` // Annotation text
|
||||
}]
|
||||
});
|
||||
}
|
||||
}
|
||||
{% for a in finance['annotations'] %}
|
||||
console.log( "{{a['x']}}" )
|
||||
console.log( "{{a['y']}}" )
|
||||
console.log( "{{a['label']}}" )
|
||||
annotations.push({
|
||||
labels: [{
|
||||
point: {
|
||||
x: {{a['x']}},
|
||||
y: {{a['y']}},
|
||||
xAxis: 0,
|
||||
yAxis: 0
|
||||
},
|
||||
text: '{{a['label']}}'
|
||||
}]
|
||||
});
|
||||
{% endfor %}
|
||||
|
||||
// Highcharts configuration
|
||||
Highcharts.chart('container', {
|
||||
|
||||
Reference in New Issue
Block a user