{"id":17463421,"url":"https://github.com/pixeledcode/echarts-satori","last_synced_at":"2025-08-02T16:35:25.786Z","repository":{"id":228004711,"uuid":"772907589","full_name":"PixeledCode/echarts-satori","owner":"PixeledCode","description":"A demo app implementing custom charts using ECharts, Satori and Next.js route handler","archived":false,"fork":false,"pushed_at":"2024-04-06T04:22:05.000Z","size":882,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T07:11:31.868Z","etag":null,"topics":["echarts","nextjs","route-handlers","satori"],"latest_commit_sha":null,"homepage":"https://echarts-satori.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PixeledCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-16T07:48:43.000Z","updated_at":"2024-05-06T01:16:39.000Z","dependencies_parsed_at":"2024-04-06T04:29:41.347Z","dependency_job_id":null,"html_url":"https://github.com/PixeledCode/echarts-satori","commit_stats":null,"previous_names":["pixeledcode/echarts-satori"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PixeledCode/echarts-satori","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixeledCode%2Fecharts-satori","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixeledCode%2Fecharts-satori/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixeledCode%2Fecharts-satori/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixeledCode%2Fecharts-satori/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PixeledCode","download_url":"https://codeload.github.com/PixeledCode/echarts-satori/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixeledCode%2Fecharts-satori/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264113581,"owners_count":23559380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["echarts","nextjs","route-handlers","satori"],"created_at":"2024-10-18T10:09:40.210Z","updated_at":"2025-07-07T16:38:49.787Z","avatar_url":"https://github.com/PixeledCode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Echarts Satori\n\nA demo app implementing custom charts using ECharts, Satori and Next.js route handler\n\n## 1st Part - Setup Project\n\n1. Setup Next.js.\n2. Install packages `echarts` and `echarts-for-react`.\n3. Create a component for Echarts that accepts an [chartOptions](./components/data.ts) prop.\n4. Setup the Echart in the [page](./app/page.tsx) route.\n\n## 2nd Part - Download Chart\n\n1. Create a route handler at `api/chart/route.ts` that returns an SVG string of the chart.\n2. Implement a Download component that performs a POST request using the `chartOptions`.\n3. Convert the SVG string to either an SVG URI or PNG URI based on the use case.\n\n## 3rd Part - Download Custom Chart\n\n1. Setup Satori:\n\n- Install package `satori` and `intl-segmenter-polyfill`.\n- Extend the global `window` interface with `__resource` [typings.d.ts](./typings.d.ts).\n- Add the font file using by satori to the `public` directory.\n\n2. Creaye a `reactToSVG` function that converts a React component to an SVG string [satori](./lib/satori.ts)\n3. Add a React Template to customize the chart [ChartTemplate](./components/ChartTemplate.tsx).\n4. Pass the template to Satori using `reactToSVG` to generate an SVG string of the customized chart.\n5. Convert the SVG string to a data URI and download it.\n\n## 4th Part - Improvement\n\n1. Instead of returning an SVG string from route handler, you can return a data URI directly so that we can skip one function call.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixeledcode%2Fecharts-satori","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixeledcode%2Fecharts-satori","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixeledcode%2Fecharts-satori/lists"}