{"id":15406749,"url":"https://github.com/dannyben/minichart","last_synced_at":"2025-04-13T07:55:06.869Z","repository":{"id":10549778,"uuid":"66137681","full_name":"DannyBen/minichart","owner":"DannyBen","description":"Create SVG mini charts with Ruby","archived":false,"fork":false,"pushed_at":"2024-08-25T10:38:44.000Z","size":154,"stargazers_count":33,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T07:55:03.776Z","etag":null,"topics":["chart","charts","ruby","sparkline","sparklines","svg"],"latest_commit_sha":null,"homepage":"","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/DannyBen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-08-20T08:53:52.000Z","updated_at":"2024-09-19T21:23:32.000Z","dependencies_parsed_at":"2024-01-29T09:10:28.051Z","dependency_job_id":"5c8fbba0-cc81-4c28-8be6-055113755cf1","html_url":"https://github.com/DannyBen/minichart","commit_stats":{"total_commits":87,"total_committers":2,"mean_commits":43.5,"dds":0.09195402298850575,"last_synced_commit":"71041f771b45f24fff946f2b7910d27e0664ddd9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fminichart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fminichart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fminichart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DannyBen%2Fminichart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DannyBen","download_url":"https://codeload.github.com/DannyBen/minichart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681491,"owners_count":21144700,"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":["chart","charts","ruby","sparkline","sparklines","svg"],"created_at":"2024-10-01T16:25:11.684Z","updated_at":"2025-04-13T07:55:06.840Z","avatar_url":"https://github.com/DannyBen.png","language":"Ruby","readme":"# Minichart - SVG Chart Generator\n\n---\n\nCreate SVG mini charts with Ruby\n\n![demo](examples/multiple.svg)\n\n---\n\n## Install\n\n```shell\n$ gem install minichart\n```\n\nOr with bundler:\n\n```ruby\ngem 'minichart'\n```\n\n## Usage\n\nRequire and optionally include the library:\n\n```ruby\nrequire 'minichart'\ninclude Minichart\n```\n\nInitialize a chart with data, and optional options:\n\n```ruby\ndata = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]\nchart = AreaChart.new data, color: 'blue'\n```\n\nGet the full SVG output by calling `#render`:\n\n```ruby\nputs chart.render\n#=\u003e \u003c?xml version=\"1.0\" standalone=\"no\"?\u003e\n#   \u003csvg\u003e ... \u003c/svg\u003e\n```\n\nSave it to file, by calling `#save`:\n\n```ruby\nchart.save \"my-chart.svg\"\n```\n\nGet its inner SVG string by calling `#to_s`:\n\n```ruby\nputs chart.to_s\n#=\u003e \u003cpolyline fill=\"blue\" stroke=\"blue\" stroke-width=\"2\" points=\"...\"/\u003e\n```\n\n\nThe objects returned from all the mini chart classes are [Victor::SVG][2] objects, so they support all methods supported by it as well.\n\n## Chart Types\n\n### Line Chart\n\n\u003cimg src='examples/line_chart.svg' align='right' width=180\u003e\n\n```ruby\nLineChart.new [10, 30, 20, 40, 30], background: '#eee',\n  height: 50, width: 250, color: 'green'\n```\n\n### Bar Chart\n\n\u003cimg src='examples/bar_chart.svg' align='right' width=180\u003e\n\n```ruby\nBarChart.new [10, 30, 20, 40, 30], background: '#eee',\n  height: 50, width: 250, color: 'green'\n```\n\n### Area Chart\n\n\u003cimg src='examples/area_chart.svg' align='right' width=180\u003e\n\n```ruby\nAreaChart.new [10, 30, 20, 40, 30], background: '#eee',\n  height: 50, width: 250, color: 'green'\n```\n\n### Horizontal Bar Meter\n\n\u003cimg src='examples/multiple_horizontal_bars.svg' align='right'\u003e\n\n```ruby\npositive = HorizontalBarMeter.new 70,\n  height: 20, width: 250, background: '#9f9',\n  color: 'green'\n\nnegative = HorizontalBarMeter.new -80,\n  height: 20, width: 250, background: '#f99',\n  color: 'red'\n\ndual = HorizontalBarMeter.new 80,\n  height: 20, width: 250, background: '#99f',\n  color: 'blue', mode: :dual, notches: [0]\n```\n\nMeter charts support [additional options](#meter-options).\n\n### Vertical Bar Meter\n\n\u003cimg src='examples/multiple_vertical_bars.svg' align='right'\u003e\n\n```ruby\npositive = VerticalBarMeter.new 70,\n  width: 20, height: 250, background: '#9f9', color: 'green'\n\nnegative = VerticalBarMeter.new -80,\n  width: 20, height: 250, background: '#f99', color: 'red'\n\ndual = VerticalBarMeter.new 80,\n  width: 20, height: 250, background: '#99f', color: 'blue',\n  mode: :dual, notches: [0]\n```\n\nMeter charts support [additional options](#meter-options).\n\n### Horizontal Status Leds\n\n\u003cimg src='examples/horizontal_status_leds.svg' align='right' width=150\u003e\n\n```ruby\nHorizontalStatusLeds.new [1,1,-1,0,1,1,1,1,1,-1,-1,1],\n  background: '#ccc'\n```\n\nLed charts support [additional options](#leds-options).\n\n### Vertical Status Leds\n\n\u003cimg src='examples/vertical_status_leds.svg' align='right' width=25\u003e\n\n```ruby\nVerticalStatusLeds.new [1,1,1,1,-1,1,-1,1,0,1],\n  background: '#ccc'\n```\n\nLed charts support [additional options](#leds-options).\n\n\n## Configuration\n\nChart options can be set in one of three ways.\n\n### Class-level default options\n\nSee or set default options for any chart class by calling its `::options` method:\n\n```ruby\n# See all options\np AreaChart.options\n#=\u003e {:background=\u003e\"white\", :height=\u003e100, :width=\u003e300, :stroke=\u003e2,\n     :style=\u003e{}, :color=\u003e\"#66f\"}\n\n# Set a single default option\nAreaChart.options[:color] = '#333'\n\n# Set multiple options at once\nAreaChart.options background: 'black', color: 'green'\n```\n\n### Instance initialization options\n\nSet options by providing a hash as the second argument on initialization:\n\n```ruby\nchart = AreaChart.new data, height: 120, width: 500\n```\n\n### Instance-level options\n\nAfter initialization, you can still update individual options:\n\n```ruby\nchart = AreaChart.new data\nchart.options[:background] = 'yellow'\n```\n\n## Options Reference\n\n### Basic Options\n\n- **background**: Chart background color.\n- **color**: Chart color.\n- **height**: Chart height in pixels.\n- **width**: Chart width in pixels.\n- **stroke**: Line stroke width. This has a different effect in different chart types.\n- **style**: CSS Style hash to apply to the entire SVG.\n- **padding**: Chart padding in pixels.\n\n### Meter Options\n\nMeter charts support these options in addition to the basic options:\n\n- **mode**: Display mode. Can be `:positive`, `:negative`, `:dual` or `:auto` (default).\n  The `:auto` mode will switch between `:positive` and `:negative` based on the\n  value.\n- **max**: The absolute maximum value. This number should be positive even for negative\n  charts.\n- **notches**: An array of one or more levels to place a notch marker. Use positive values\n  only.\n- **notch_thickness**: Thickness of the notch markers.\n- **notch_color**: Color of the notch markers.\n- **clipping_indicator**: If true, show a marker when the value exceeds the range.\n- **clipping_indicator_thickness**: Thickness of the clipping indicator.\n- **clipping_indicator_color**: Color of the clipping indicator.\n\n### Leds Options\n\nLed charts support these options in addition to the basic options (excluding\nthe `color` option):\n\n- **positive_color**: Color to use when the value is greater than 0.\n- **negative_color**: Color to use when the value is less than 0.\n- **neutral_color**: Color to use when the value is 0 or nil.\n- **min_opacity**: A value between 0 and 1 representing the minimum opacity that will be applied to values when they are lower than the maximum range.\n\n## Examples\n\nSee more examples (code and SVG output) in the [examples folder][1].\n\n## Contributing / Support\n\nIf you experience any issue, have a question or a suggestion, or if you wish\nto contribute, feel free to [open an issue][issues].\n\n---\n\n[1]: https://github.com/DannyBen/minichart/tree/master/examples#examples\n[2]: https://github.com/DannyBen/victor\n[issues]: https://github.com/DannyBen/minichart/issues","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fminichart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdannyben%2Fminichart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdannyben%2Fminichart/lists"}