mirror of
https://github.com/aljazceru/satshkd-vercel.git
synced 2025-12-17 05:04:24 +01:00
Merge pull request #8 from aljazceru/claude/fix-chart-data-alignment-014KT219GTiiFP2RhigKtK1z
Fix chart Y-axis alignment to start with actual data range
This commit is contained in:
@@ -170,6 +170,16 @@
|
|||||||
date: new Date(d.date)
|
date: new Date(d.date)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Calculate min and max values from data for proper axis scaling
|
||||||
|
const rateField = '{{ rate_field }}';
|
||||||
|
const values = data.map(d => d[rateField]).filter(v => v != null && v > 0);
|
||||||
|
const minValue = Math.min(...values);
|
||||||
|
const maxValue = Math.max(...values);
|
||||||
|
|
||||||
|
// Add padding for logarithmic scale (multiply/divide by factor)
|
||||||
|
const yAxisMin = Math.floor(minValue / 2);
|
||||||
|
const yAxisMax = Math.ceil(maxValue * 2);
|
||||||
|
|
||||||
// Calculate responsive height
|
// Calculate responsive height
|
||||||
const windowWidth = window.innerWidth;
|
const windowWidth = window.innerWidth;
|
||||||
let graphHeight;
|
let graphHeight;
|
||||||
@@ -315,7 +325,8 @@
|
|||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
type: 'logarithmic',
|
type: 'logarithmic',
|
||||||
max: 1000000000,
|
min: yAxisMin,
|
||||||
|
max: yAxisMax,
|
||||||
ticks: {
|
ticks: {
|
||||||
callback: function(value) {
|
callback: function(value) {
|
||||||
return value.toLocaleString() + ' sats';
|
return value.toLocaleString() + ' sats';
|
||||||
|
|||||||
Reference in New Issue
Block a user