add annotations properly now

This commit is contained in:
2025-02-12 18:06:49 +11:00
parent 65ed02812a
commit ce38b3d1f0
2 changed files with 31 additions and 29 deletions

View File

@@ -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', {