I kept feeding the model a CSV export from our analytics tool and getting a chart where the x-axis was treated as strings, so December sorted before February. The naive prompt ("plot this CSV as a line chart") never looked at the actual column shapes.
The fix was to make the model run an explicit type-inference pass and print its column plan before writing any D3, so I could catch a misread date column before it wasted 80 lines of code. Now it reliably picks a scaleTime for the date and scaleLinear for the value.
Anyone have a cleaner way to make it commit to a parse format instead of guessing per row?
You are generating a single-file D3 v7 line chart from a CSV I will paste. Do NOT write any chart code until you finish a type-inference pass.
Step 1 - Column plan: for each column, sample the first 20 non-empty values and classify it as one of {date, number, category, id}. State the exact d3.timeParse format string you will use for any date column (e.g. "%Y-%m-%d"), and the reason. Reject the column as x-axis if more than 5% of samples fail to parse.
Step 2 - Chart spec: pick the single date column as x (scaleTime), the numeric column with the widest range as y (scaleLinear, domain nice()'d, never starting at an arbitrary non-zero baseline unless the data is clearly a ratio). Print the final spec as a small table.
Step 3 - Render: emit one HTML file, D3 from a CDN, a responsive viewBox (no fixed pixel width), gridlines at 1px #e5e7eb, axis labels in 12px system-ui #6b7280, a single 2px accent line (var --accent default #2563eb), and hover dots with a tooltip that shows the parsed date and value.
Constraints: no moment.js, no chart libraries, degrade to a visible "no numeric column found" message instead of throwing. Show the column plan first, wait for nothing, then the code.