{"id":21879216,"url":"https://github.com/typpo/quickchart-ruby","last_synced_at":"2025-04-15T03:07:23.599Z","repository":{"id":46199983,"uuid":"297798523","full_name":"typpo/quickchart-ruby","owner":"typpo","description":"Ruby client for quickchart.io chart API","archived":false,"fork":false,"pushed_at":"2023-04-27T16:18:12.000Z","size":22,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T03:07:19.246Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/typpo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-09-22T23:37:43.000Z","updated_at":"2024-05-22T12:30:00.000Z","dependencies_parsed_at":"2024-11-28T08:15:40.421Z","dependency_job_id":null,"html_url":"https://github.com/typpo/quickchart-ruby","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"f971de9e41c9d6286b4cf9f5e08adc8808dce6b4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fquickchart-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fquickchart-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fquickchart-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fquickchart-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typpo","download_url":"https://codeload.github.com/typpo/quickchart-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997080,"owners_count":21195799,"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":[],"created_at":"2024-11-28T08:15:37.293Z","updated_at":"2025-04-15T03:07:23.585Z","avatar_url":"https://github.com/typpo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quickchart-ruby\n\u003ca href=\"https://rubygems.org/gems/quickchart\"\u003e\u003cimg alt=\"QuickChart Gem\" src=\"https://img.shields.io/gem/v/quickchart\"\u003e\u003c/a\u003e\n\nA Ruby client for the [quickchart.io](https://quickchart.io/) chart image API.\n\n# Installation\n\nUse the `lib/quickchart.rb` library in this project, or install as a [Ruby gem](https://rubygems.org/gems/quickchart):\n\n```\ngem install quickchart\n```\n\n# Usage\n\nThis library provides a `QuickChart` class.  Import and instantiate it.  Then set properties on it and specify a [Chart.js](https://chartjs.org) config:\n\n```ruby\nrequire 'quickchart'\n\nqc = QuickChart.new(\n  {\n    type: \"bar\",\n    data: {\n      labels: [\"Hello world\", \"Test\"],\n      datasets: [{\n        label: \"Foo\",\n        data: [1, 2]\n      }]\n    }\n  },\n  width: 600,\n  height: 300,\n  device_pixel_ratio: 2.0,\n)\n```\n\nUse `get_url()` on your quickchart object to get the encoded URL that renders your chart:\n\n```ruby\nputs qc.get_url\n# https://quickchart.io/chart?c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22Hello+world%22%2C%22Test%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Foo%22%2C%22data%22%3A%5B1%2C2%5D%7D%5D%7D%7D\u0026w=600\u0026h=300\u0026bkg=%23ffffff\u0026devicePixelRatio=2.0\u0026f=png\n```\n\nIf you have a long or complicated chart, use `get_short_url()` to get a fixed-length URL using the quickchart.io web service (note that these URLs only persist for a short time unless you have a subscription):\n\n```ruby\nputs qc.get_short_url\n# https://quickchart.io/chart/render/f-a1d3e804-dfea-442c-88b0-9801b9808401\n```\n\nThe URLs will render an image of a chart:\n\n\u003cimg src=\"https://quickchart.io/chart?c=%7B%22type%22%3A+%22bar%22%2C+%22data%22%3A+%7B%22labels%22%3A+%5B%22Hello+world%22%2C+%22Test%22%5D%2C+%22datasets%22%3A+%5B%7B%22label%22%3A+%22Foo%22%2C+%22data%22%3A+%5B1%2C+2%5D%7D%5D%7D%7D\u0026w=600\u0026h=300\u0026bkg=%23ffffff\u0026devicePixelRatio=2.0\u0026f=png\" width=\"500\" /\u003e\n\n## Creating the chart object\n\nThe `QuickChart` class constructor accepts the following parameters.  `config` is the only required parameter, the rest are optional:\n\n### config: hash or string (required)\nThe actual Chart.js chart configuration.\n\n### width: int\nWidth of the chart image in pixels.  Defaults to 500\n\n### height: int\nHeight of the chart image  in pixels.  Defaults to 300\n\n### format: string\nFormat of the chart. Defaults to png. svg is also valid.\n\n### background_color: string\nThe background color of the chart. Any valid HTML color works. Defaults to #ffffff (white). Also takes rgb, rgba, and hsl values.\n\n### device_pixel_ratio: float\nThe device pixel ratio of the chart. This will multiply the number of pixels by the value. This is usually used for retina displays. Defaults to 1.0.\n\n### key: string\nQuickChart API key (not required)\n\n### version: string\nSets the Chart.js version to use (e.g. 2.9.4 or 3.8.0). Valid options are described in the [documentation](https://quickchart.io/documentation/usage/parameters/#version).\n\n## Getting URLs\n\nThere are two ways to get a URL for your chart object.\n\n### get_url: string\n\nReturns a URL that will display the chart image when loaded.\n\n### get_short_url: string\n\nUses the quickchart.io web service to create a fixed-length chart URL that displays the chart image.  Returns a URL such as `https://quickchart.io/chart/render/f-a1d3e804-dfea-442c-88b0-9801b9808401`.\n\nNote that short URLs expire after a few days for users of the free service.  You can [subscribe](https://quickchart.io/pricing/) to keep them around longer.\n\n## Other outputs\n\n### to_blob: binary string\n\nReturns a binary string representing the chart image\n\n### to_file(path: string)\n\nWrite the image to a file\n\nFor example:\n```ruby\nqc.to_file(\"/tmp/myfile.png\")\n```\n\n## More examples\n\nCheckout the `examples` directory to see other usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyppo%2Fquickchart-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyppo%2Fquickchart-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyppo%2Fquickchart-ruby/lists"}