{"id":13702006,"url":"https://github.com/everestate/chartjs-plugin-waterfall","last_synced_at":"2025-05-05T04:30:39.868Z","repository":{"id":57197193,"uuid":"336325037","full_name":"everestate/chartjs-plugin-waterfall","owner":"everestate","description":"Makes waterfall charts easy with chartjs-2","archived":false,"fork":false,"pushed_at":"2021-02-05T17:50:32.000Z","size":65,"stargazers_count":17,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-13T09:40:25.630Z","etag":null,"topics":[],"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/everestate.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}},"created_at":"2021-02-05T16:23:37.000Z","updated_at":"2024-09-29T11:59:34.000Z","dependencies_parsed_at":"2022-09-16T13:11:43.728Z","dependency_job_id":null,"html_url":"https://github.com/everestate/chartjs-plugin-waterfall","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everestate%2Fchartjs-plugin-waterfall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everestate%2Fchartjs-plugin-waterfall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everestate%2Fchartjs-plugin-waterfall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/everestate%2Fchartjs-plugin-waterfall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/everestate","download_url":"https://codeload.github.com/everestate/chartjs-plugin-waterfall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252439365,"owners_count":21747993,"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-08-02T21:00:29.519Z","updated_at":"2025-05-05T04:30:39.542Z","avatar_url":"https://github.com/everestate.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Features"],"readme":"### Installation\n`npm install --save chartjs-plugin-waterfall`\n\nHere's what it looks like:\n![WaterFall Chart Example](https://user-images.githubusercontent.com/15030491/32444814-28cd3f9c-c304-11e7-9e26-c52e5ec0d25e.png)\n\n### Usage\nJust import the plugin and add it to any chart that you want to be a waterfall chart like so:\n\n`import waterFallPlugin from 'chartjs-plugin-waterfall';`\n\n```js\nvar chart = new Chart(ctx, {\n    plugins: [waterFallPlugin]\n});\n```\n\nExample gist by @EdwinChua: https://gist.github.com/EdwinChua/0a5d66dc561fe7d3866021b18a320585\n\nSee the [plugins](http://www.chartjs.org/docs/latest/developers/plugins.html) documentation for more info.\n\n### How it works\nThis plugin works by checking if any of your datasets contain a property called `dummyStack` that is set to true.\nThe `stack` property must be used in conjunction with `dummyStack` for this plugin to work properly.\nIf `dummyStack` is true then it hides the label, tooltip and sets the color invisible. When you use stacking with this it creates the affect\nof a floating bar as shown in the image above that we can use for waterfall charts as chartjs-2 doesn't support waterfall charts\nby default.\n\nE.g:\n\n```js\nconst data = {\n  datasets: [\n    {\n      label: 'Closing Costs',\n      data: [50],\n      backgroundColor: '#e8cdd7',\n      stack: 'stack 1',\n    },\n    {\n      label: 'Purchase Price',\n      data: [700],\n      backgroundColor: '#d29baf',\n      stack: 'stack 1',\n    },\n    {\n      data: [200],\n      waterfall: {\n        dummyStack: true,\n      },\n      stack: 'stack 2',\n    },\n    {\n      label: 'Opening Loan Balance',\n      data: [550],\n      backgroundColor: '#bb6987',\n      stack: 'stack 2',\n    },\n    {\n      label: 'Initial Cash Investment',\n      data: [200],\n      backgroundColor: '#a53860',\n      stack: 'stack 3',\n    },\n  ],\n};\n```\n\nThis dataset will give us the look in the image above.\n\n### Options\nThe plugin options can be changed at 3 different levels:\n\nglobally: Chart.defaults.global.plugins.waterfall.*\n\nper chart: options.plugins.waterfall.*\n\nper dataset: dataset.waterfall.* (not all options)\n\nThe default chart options are:\n\n```js\noptions: {\n  plugins: {\n    waterFallPlugin: {\n      stepLines: {\n        enabled: true,\n        startColorStop: 0,\n        endColorStop: 0.6,\n        startColor: 'rgba(0, 0, 0, 0.55)',\n        endColor: 'rgba(0, 0, 0, 0)',\n        diagonalStepLines: true,\n      },\n    },\n  },\n}\n```\n\nDataset options:\n`dummyStack`: (boolean) If true then hides the tooltip, legend and sets the color to transparent.\n\nGlobal/Chart options:\n\n`stepLines.enabled`: (boolean) If true then it shows the step-lines going from one bar to another.\n\nGlobal/Chart/Dataset options:\n\n`stepLines.startColorStop`: (number) Used as the offset value in the first [`addColorStop`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient/addColorStop) method call.\n\n`stepLines.startColor`: (string) Used as the color value in the first [`addColorStop`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient/addColorStop) method call.\n\n`stepLines.endColorStop`: (number) Used as the offset value in the second [`addColorStop`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient/addColorStop) method call.\n\n`stepLines.endColor`: (string) Used as the color value in the second [`addColorStop`](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient/addColorStop) method call.\n\nFor lines going from bar to bar that you need maximum customization over, see [chartjs-plugin-custom-lines](https://github.com/everestate/chartjs-plugin-custom-lines).\n\n### Caveats\n- Multiple values in `data` currently are not supported by this plugin.\n- The invisible dummy stacks are removed from the [tooltip](http://www.chartjs.org/docs/latest/configuration/tooltip.html#filter-callback) \nand [legend](http://www.chartjs.org/docs/latest/configuration/legend.html#legend-label-configuration) by default using the `filter` method. \nIf you are providing your own filter method, using a custom tooltip or legend of your own then you will have to manually hide them because it will overwrite this plugins.\n\nE.g. This is how this plugin hides them, so you could do it this way:\n\n```js\n  filter: function(legendItem, chartData) {\n    var currentDataset = chartData.datasets[legendItem.datasetIndex];\n\n    return !currentDataset.dummyStack;\n  }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverestate%2Fchartjs-plugin-waterfall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feverestate%2Fchartjs-plugin-waterfall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feverestate%2Fchartjs-plugin-waterfall/lists"}