fix: SQL Explorer chart parses string values as floats
The pg-query API returns all values as strings. The chart builder was using Number() which returns NaN for non-numeric strings. Now uses parseFloat with NaN fallback to 0.
This commit is contained in:
@@ -86,11 +86,15 @@ export function SqlExplorerPage() {
|
||||
|
||||
// Build chart data from result
|
||||
const chartData = result && result.columns.length >= 2
|
||||
? result.rows.map((row) => ({
|
||||
x: row[xCol],
|
||||
y: Number(row[yCol]) || 0,
|
||||
label: String(row[xCol]),
|
||||
}))
|
||||
? result.rows.map((row) => {
|
||||
const yRaw = row[yCol];
|
||||
const yNum = yRaw != null ? parseFloat(String(yRaw)) : NaN;
|
||||
return {
|
||||
x: row[xCol],
|
||||
y: isNaN(yNum) ? 0 : yNum,
|
||||
label: String(row[xCol] ?? ''),
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
// Split saved queries into pre-built (no id-based delete) and user-saved
|
||||
|
||||
Reference in New Issue
Block a user