{"id":13702823,"url":"https://github.com/denoland/fresh_charts","last_synced_at":"2025-10-19T21:32:19.883Z","repository":{"id":61353160,"uuid":"550691825","full_name":"denoland/fresh_charts","owner":"denoland","description":"A server-side-rendered charting library for Fresh","archived":false,"fork":false,"pushed_at":"2024-04-17T10:47:29.000Z","size":37,"stargazers_count":143,"open_issues_count":7,"forks_count":11,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-01-30T06:11:15.310Z","etag":null,"topics":["charting-library","chartjs","charts","deno","fresh"],"latest_commit_sha":null,"homepage":"https://fresh-charts.deno.dev/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/denoland.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-10-13T07:08:01.000Z","updated_at":"2025-01-16T09:24:25.000Z","dependencies_parsed_at":"2024-04-17T11:48:16.441Z","dependency_job_id":null,"html_url":"https://github.com/denoland/fresh_charts","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.5,"last_synced_commit":"7a2f5d74c4b2c9b8d8e0ec77298d2ef5ff9fd734"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Ffresh_charts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Ffresh_charts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Ffresh_charts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/denoland%2Ffresh_charts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/denoland","download_url":"https://codeload.github.com/denoland/fresh_charts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237221176,"owners_count":19274447,"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":["charting-library","chartjs","charts","deno","fresh"],"created_at":"2024-08-02T21:00:43.483Z","updated_at":"2025-10-19T21:32:14.612Z","avatar_url":"https://github.com/denoland.png","language":"TypeScript","funding_links":[],"categories":["Modules","Integrations"],"sub_categories":["JavaScript","Web utils"],"readme":"# fresh_charts\n\nA charting library for Fresh based on [Chart.js](https://www.chartjs.org/),\nwhich supports server and client side rendering.\n\n## Usage\n\nThere are several ways to render a chart.\n\nFor server side rendering there is the JSX/TSX component `Chart` which can be\nused to inline a chart on a page, and the `renderChart()` function which can be\nused to respond in a handler with an SVG image.\n\nFor client side rendering there is also a JSX/TSX island component `Chart`.\n\n### [SSR] Inline chart example\n\nThis provides a chart rendered within the router page itself.\n\n```tsx\nimport { Head } from \"$fresh/runtime.ts\";\nimport { Chart } from \"$fresh_charts/mod.ts\";\nimport { ChartColors, transparentize } from \"$fresh_charts/utils.ts\";\n\nexport default function Home() {\n  return (\n    \u003c\u003e\n      \u003cHead\u003e\n        \u003ctitle\u003eExample Chart\u003c/title\u003e\n      \u003c/Head\u003e\n      \u003cdiv class=\"p-4 mx-auto max-w-screen-md\"\u003e\n        \u003cChart\n          type=\"line\"\n          options={{\n            devicePixelRatio: 1,\n            scales: { y: { beginAtZero: true } },\n          }}\n          data={{\n            labels: [\"1\", \"2\", \"3\"],\n            datasets: [\n              {\n                label: \"Sessions\",\n                data: [123, 234, 234],\n                borderColor: ChartColors.Red,\n                backgroundColor: transparentize(ChartColors.Red, 0.5),\n                borderWidth: 1,\n              },\n              {\n                label: \"Users\",\n                data: [346, 233, 123],\n                borderColor: ChartColors.Blue,\n                backgroundColor: transparentize(ChartColors.Blue, 0.5),\n                borderWidth: 1,\n              },\n            ],\n          }}\n        /\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n### [SSR] Responding as an image\n\nThis route will provide the landing page of the site, which has an image link to\na route, which will send a request to `/routes/chart.ts` to render the chart.\n\n**/routes/index.tsx**\n\n```tsx\nimport { Head } from \"$fresh/runtime.ts\";\nimport { Chart } from \"$fresh_charts/mod.ts\";\nimport { ChartColors, transparentize } from \"$fresh_charts/utils.ts\";\n\nexport default function Home() {\n  return (\n    \u003c\u003e\n      \u003cHead\u003e\n        \u003ctitle\u003eExample Chart\u003c/title\u003e\n      \u003c/Head\u003e\n      \u003cdiv class=\"p-4 mx-auto max-w-screen-md\"\u003e\n        \u003cimg\n          src=\"/chart\"\n          class=\"mx-auto my-4 h-96\"\n          alt=\"an example chart provided as an image\"\n        /\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n**/routes/chart.ts**\n\n```ts\nimport { type Handlers } from \"$fresh/server.ts\";\nimport { renderChart } from \"$fresh_charts/mod.ts\";\nimport { ChartColors, transparentize } from \"$fresh_charts/utils.ts\";\n\nexport const handler: Handlers = {\n  GET() {\n    return renderChart({\n      type: \"line\",\n      data: {\n        labels: [\"1\", \"2\", \"3\"],\n        datasets: [\n          {\n            label: \"Sessions\",\n            data: [123, 234, 234],\n            borderColor: ChartColors.Red,\n            backgroundColor: transparentize(ChartColors.Red, 0.5),\n            borderWidth: 1,\n          },\n          {\n            label: \"Users\",\n            data: [346, 233, 123],\n            borderColor: ChartColors.Blue,\n            backgroundColor: transparentize(ChartColors.Blue, 0.5),\n            borderWidth: 1,\n          },\n        ],\n      },\n      options: {\n        devicePixelRatio: 1,\n        scales: { y: { beginAtZero: true } },\n      },\n    });\n  },\n};\n```\n\n### [CSR] Inline chart example\n\nThis provides a client side rendered and interactive chart island within the\nrouter page itself.\n\n**/islands/chart.tsx**\n\n```tsx\nimport { Chart } from \"$fresh_charts/island.tsx\";\nexport default Chart;\n```\n\n**/routes/index.tsx**\n\n```tsx\nimport { Head } from \"$fresh/runtime.ts\";\nimport { ChartColors } from \"$fresh_charts/utils.ts\";\nimport Chart from \"../islands/chart.tsx\";\n\nexport default function Home() {\n  return (\n    \u003c\u003e\n      \u003cHead\u003e\n        \u003ctitle\u003eExample Chart\u003c/title\u003e\n      \u003c/Head\u003e\n      \u003cdiv class=\"p-4 mx-auto max-w-screen-md\"\u003e\n        \u003cChart\n          type=\"line\"\n          options={{\n            scales: { y: { beginAtZero: true } },\n          }}\n          data={{\n            labels: [\"1\", \"2\", \"3\"],\n            datasets: [\n              {\n                label: \"Sessions\",\n                data: [123, 234, 234],\n                borderColor: ChartColors.Red,\n                borderWidth: 1,\n              },\n              {\n                label: \"Users\",\n                data: [346, 233, 123],\n                borderColor: ChartColors.Blue,\n                borderWidth: 1,\n              },\n            ],\n          }}\n        /\u003e\n      \u003c/div\u003e\n    \u003c/\u003e\n  );\n}\n```\n\n---\n\nCopyright 2018-2023 the Deno authors. All rights reserved. MIT Licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Ffresh_charts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdenoland%2Ffresh_charts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdenoland%2Ffresh_charts/lists"}