{"id":25132895,"url":"https://github.com/tbaeg/calendar-heatmap-mini","last_synced_at":"2025-04-23T22:20:51.981Z","repository":{"id":57192885,"uuid":"91467598","full_name":"tbaeg/calendar-heatmap-mini","owner":"tbaeg","description":"A d3.js heatmap representing time series data","archived":false,"fork":false,"pushed_at":"2018-11-13T01:43:44.000Z","size":25,"stargazers_count":24,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T20:16:09.683Z","etag":null,"topics":["calendar","d3","heatmap","mini"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/tbaeg.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":"2017-05-16T14:25:28.000Z","updated_at":"2024-08-02T13:08:59.000Z","dependencies_parsed_at":"2022-09-01T06:01:08.581Z","dependency_job_id":null,"html_url":"https://github.com/tbaeg/calendar-heatmap-mini","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaeg%2Fcalendar-heatmap-mini","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaeg%2Fcalendar-heatmap-mini/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaeg%2Fcalendar-heatmap-mini/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbaeg%2Fcalendar-heatmap-mini/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbaeg","download_url":"https://codeload.github.com/tbaeg/calendar-heatmap-mini/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522906,"owners_count":21444621,"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":["calendar","d3","heatmap","mini"],"created_at":"2025-02-08T15:18:51.952Z","updated_at":"2025-04-23T22:20:51.961Z","avatar_url":"https://github.com/tbaeg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# D3 Calendar Heatmap Mini\n\nThis code was originally forked from `https://github.com/DKirwan/calendar-heatmap` and modified. This\nserves to publish the package to `npm` as `calendar-heatmap-mini` along with a few key differences.\n\nKey Differences\n* Option for `singleSelection` thanks to @remyvhw.\n* `npm` installable as well as importable as a module.\n* Update to the latest `d3@4.8.0`\n  * Trim down to specific `d3` packages.\n* Data is auto initialized if none is presented.\n* When updating the same instance of a heatmap, previous `max` size is not used.\n* Use SVG `text` for tooltips.\n* Move into a non-forked version of the repository.\n  * Rework project structure into the appropriate name (`calendar-heatmap-mini`).\n\nA [d3.js](https://d3js.org/) heatmap representing time series data. Inspired by Github's contribution chart.\n\n![Reusable D3.js Calendar Heatmap chart](https://raw.githubusercontent.com/DKirwan/calendar-heatmap/develop/example/thumbnail.png)\n\n## Configuration\n\n|Property        | Usage           | Default  | Required |\n|:------------- |:-------------|:-----:|:-----:|\n| data | Chart data | none | no |\n| selector | DOM selector to attach the chart to | body | no |\n| max | Maximum count | max found in data | no |\n| startDate | Date to start heatmap at | 1 year ago | no |\n| colorRange | Minimum and maximum chart gradient colors | ['#D8E6E7', '#218380'] | no |\n| tooltipEnabled | Option to render a tooltip | true | no |\n| tooltipUnit | Unit to render on the tooltip, can be object for pluralization control | 'contributions' | no |\n| legendEnabled | Option to render a legend | true | no |\n| onClick | callback function on day click events (see example below) | null | no |\n| singleSelection | Option to only be able to select a single date | false | no |\n| locale | Object to translate every word used, except for tooltipUnit | see below | no |\n\n### Default locale object\n\n```javascript\n{\n    months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n    days: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n    No: 'No',\n    on: 'on',\n    Less: 'Less',\n    More: 'More'\n}\n```\n\n## Dependencies\n\n* [d3.js](https://d3js.org/)\n* [moment.js](http://momentjs.com/)\n\n## Usage\n\n### Without npm\n1: Add `d3.js` and `moment.js`\n\n2: Include `calendar-heatmap-mini.js` and `calendar-heatmap-mini.css`.\n```\n\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"path/tocalendar-heatmap-mini.css\"\u003e\n\u003cscript src=\"path/to/calendar-heatmap-mini.js\"\u003e\u003c/script\u003e\n```\n\n3: Format the data so each array item has a `date` and `count` property.\nAs long as `new Date()` can parse the date string it's ok. Note - there all data should be rolled up into daily bucket granularity.\n\n4: Configure the chart and render it\n```javascript\n// chart data example\nvar chartData = [{\n  date: new Date(),\n  count: 100\n}];\n\nvar chart1 = calendarHeatmap()\n              .data(chartData)\n              .selector('#chart-one')\n              .colorRange(['#D8E6E7', '#218380'])\n              .tooltipEnabled(true)\n              .onClick(function (data) {\n                console.log('onClick callback. Data:', data);\n              });\n\n// render the chart\nchart1();\n```\n\n### With npm\n1: Add package dependency.\n```\nnpm install calendar-heatmap-mini --save\n```\n\n2. Import however desired.\n```\nimport CalendarHeatMap from 'calendar-heatmap-mini'\n```\n\n3. Configure and render the chart.\n```javascript\nimport CalendarHeatMap from 'calendar-heatmap-mini'\n\n// chart data example\nvar chartData = [{\n  date: new Date(),\n  count: 100\n}];\n\nconst chart1 = new CalendarHeatMap()\n              .data(chartData)\n              .selector('#chart-one')\n              .colorRange(['#D8E6E7', '#218380'])\n              .tooltipEnabled(true)\n              .onClick(function (data) {\n                console.log('onClick callback. Data:', data);\n              });\n\n// render the chart\nchart1();\n```\n\n### Control Unit Pluralization\n\n```javascript\nvar chart1 = calendarHeatmap()\n              .data(chartData)\n              .tooltipUnit(\n                [\n                  {min: 0, unit: 'contribution'},\n                  {min: 1, max: 1, unit: 'contribution'},\n                  {min: 2, max: 'Infinity', unit: 'contributions'}\n                ]\n              );\nchart1();  // render the chart\n```\n\n## Pull Requests and Issues\n\n...are very welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbaeg%2Fcalendar-heatmap-mini","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbaeg%2Fcalendar-heatmap-mini","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbaeg%2Fcalendar-heatmap-mini/lists"}