This project is a Next.js application that includes a Chart component with a REST API endpoint using the openapi-typescript-codegen library. The chart visualizes a value on a seesaw-like graph, and the application fetches data from the REST API to populate the chart dynamically.
Change in lib/utils.ts
line 15:
const oneWeekAgo = format(startOfDay(subDays(new Date(), 7)), "yyyy-MM-dd");
to:
const oneWeekAgo = format(startOfDay(subDays(new Date(), 1)), "yyyy-MM-dd");
and you will get a more varied cough percentage.
- Clone the repository and navigate to the project directory.
- Install the dependencies by running the following command:
yarn install
- (optional) Generate the API client using the openapi-typescript-codegen library:
yarn generate
- Start the development server
yarn dev
- Open your browser and visit http://localhost:3000 to see the page in action.
The project includes an api/openapi.yaml
file that represents the OpenAPI specification for your REST API.
Modify this file to match the endpoint and data structure of your API.
The generated API client is located in the src/generated/openapi-client
directory. Use this client to make
requests to your REST API from within the Next.js application.
The Chart component is built using the Recharts library. You can find more information and documentation about Recharts at https://recharts.org.
The openapi-typescript-codegen library is used for generating the API client based on the OpenAPI specification. You can find more information and documentation about openapi-typescript-codegen at https://github.com/ferdikoomen/openapi-typescript-codegen.