{"id":16032855,"url":"https://github.com/silverwind/sparkz","last_synced_at":"2025-06-19T02:04:57.005Z","repository":{"id":57366977,"uuid":"251398407","full_name":"silverwind/sparkz","owner":"silverwind","description":"Generate SVG sparklines","archived":false,"fork":false,"pushed_at":"2020-03-31T07:14:07.000Z","size":670,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T07:19:40.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silverwind.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}},"created_at":"2020-03-30T18:48:02.000Z","updated_at":"2020-03-31T07:14:09.000Z","dependencies_parsed_at":"2022-08-23T20:11:05.428Z","dependency_job_id":null,"html_url":"https://github.com/silverwind/sparkz","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/silverwind/sparkz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fsparkz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fsparkz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fsparkz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fsparkz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silverwind","download_url":"https://codeload.github.com/silverwind/sparkz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silverwind%2Fsparkz/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260669556,"owners_count":23044298,"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-10-08T21:40:53.074Z","updated_at":"2025-06-19T02:04:51.977Z","avatar_url":"https://github.com/silverwind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sparkz [![](https://img.shields.io/npm/v/sparkz.svg?style=flat)](https://www.npmjs.org/package/sparkz) [![](https://img.shields.io/npm/dm/sparkz.svg)](https://www.npmjs.org/package/sparkz)\n\u003e Generate SVG sparklines\n\n## Install\n```\nnpm i sparkz\n```\n\n```js\nimport sparkz from \"sparkz\";\n```\n\n## API\n### `sparkz(svg, values, options = {})`\n\n- `svg`: This is a `\u003csvg\u003e` reference that must contain three required attributes (`width`, `height`, and `stroke-width`). These attributes are used to calculate the drawing area.\n- `values`: You can either provide an array of numbers or an array of objects that respond to `.value`. If you have a different data structure, see `options.fetch`.\n- `options`: This optional argument allows you to further customize the sparkline. The available options are:\n    - `fetch`: Use this function to return the value if you have a different data structure that's not natively supported by sparkz.\n    - `onmousemove`: By setting this callback function, you'll enable the interactive mode (unless you set `options.interactive` to `false`). The callback signature is `callback(event, datapoint)`, where `datapoint` is an object containing the value, x/y coordinates, and the item index.\n    - `onmouseout`: This callback function is called every time the mouse leaves the SVG area. You can use it to hide things like tooltips.\n    - `spotRadius`: Set the spot radius. The default is `2`.\n    - `cursorWidth`: Set the cursor width. The default is `2`.\n    - `interactive`: When `true`, this enables the interactive mode. You don't have to set this option if you're providing a `onmousemove` callback.\n    - `fill`: Value to use for the `fill` attribute on the `\u003cpath\u003e` area and spot `circle`.\n\n## Usage\nThis is the minimum working example:\n\n```html\n\u003c!-- width, height and stroke-width attributes must be defined on the target SVG --\u003e\n\u003csvg class=\"sparkz\" width=\"100\" height=\"30\" stroke-width=\"3\"\u003e\u003c/svg\u003e\n\n\u003cscript\u003e\n  sparkz(document.querySelector(\".sparkz\"), [1, 5, 2, 4, 8, 3, 7]);\n\u003c/script\u003e\n```\n\nYou can change the colors by either setting the attributes directly to the SVG element or using CSS, like the following:\n\n```css\n/* just the line */\n.sparkz {\n  stroke: red;\n  fill: none;\n}\n\n/* line with highlight area */\n.sparkz {\n  stroke: red;\n  fill: rgba(255, 0, 0, .3);\n}\n\n/* change the spot color */\n.sparkz--spot {\n  stroke: blue;\n  fill: blue;\n}\n\n/* change the cursor color */\n.sparkz--cursor {\n  stroke: orange;\n}\n\n/* style fill area and line colors using specific class name */\n.sparkz--fill {\n  fill: rgba(255, 0, 0, .3);\n}\n\n.sparkz--line {\n  stroke: red;\n}\n```\n\n## License\n\nCopyright (c) silverwind\nCopyright (c) 2018 Nando Vieira\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Fsparkz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilverwind%2Fsparkz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilverwind%2Fsparkz/lists"}