ice_7 , question 3
This visualization displays the average price of cars by year using a line chart rendered with D3.js v7. The data is loaded from a CSV file containing car listings with attributes such as price, year, and fuel type. After loading, the script aggregates and sorts the data by year, then maps the year to the x-axis and the average price to the y-axis using a monotone X-curve for smoothing. SVG elements draw the line, axes with labels, and gridlines for readability. Hovering over the line reveals an interactive tooltip displaying the exact year and average price. The chart is styled with CSS, and the D3 library is loaded via CDN. The visualization provides a clear, interactive trend of average car prices over time.
AI-generated descriptionD3.js Line Chart
This project presents a line chart visualization using D3.js library to depict the average price of cars over the years.
Features:
Data Loading: Data is loaded from a CSV file (
car_dataset.csv) using D3'sd3.csvmethod.Line Chart: A line chart is rendered using SVG elements to illustrate the trend of average car prices over the years.
Data Transformation: The data is processed to convert necessary fields to numeric values and sorted by year for proper visualization.
Scalable Vector Graphics (SVG): The visualization is implemented using SVG, providing scalability and responsiveness.
Axes: Both X and Y axes are drawn to provide context to the data, with appropriate labels denoting the year and average price.
Gridlines: Gridlines are added to enhance readability and aid in interpreting the chart accurately.
Smoothing Curve: The line chart uses a monotone X-curve to smoothen the visual representation of data points.
Interactive Tooltip: Hovering over data points displays a tooltip showing the year and corresponding average price of cars.
External Library: D3.js library is included via CDN (
https://d3js.org/d3.v7.min.js).Styling: CSS styling is applied to elements, including the line, gridlines, and tooltip, for improved aesthetics and clarity.