Repo: https://github.com/everestate/chartjs-plugin-waterfall
Remember to replace the script import with a path from your own directory
Repo: https://github.com/everestate/chartjs-plugin-waterfall
Remember to replace the script import with a path from your own directory
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script> | |
| <script src="../node_modules/chartjs-plugin-waterfall/dist/chartjs-plugin-waterfall.min.js"></script> <!--UPDATE THIS--> | |
| </head> | |
| <body style="width:100%; height:100%"> | |
| <div style="position: relative; width: 50%; height:30%"> | |
| <canvas id="myChart" width="400px" height="400px"></canvas> | |
| </div> | |
| <script> | |
| var ctx = document.getElementById("myChart").getContext('2d'); | |
| const dat = { | |
| datasets: [ | |
| { | |
| label: 'Closing Costs', | |
| data: [50], | |
| backgroundColor: '#e8cdd7', | |
| stack: 'stack 1', | |
| }, | |
| { | |
| label: 'Purchase Price', | |
| data: [700], | |
| backgroundColor: '#d29baf', | |
| stack: 'stack 1', | |
| }, | |
| { | |
| data: [200], | |
| waterfall: { | |
| dummyStack: true, | |
| }, | |
| stack: 'stack 2', | |
| }, | |
| { | |
| label: 'Opening Loan Balance', | |
| data: [550], | |
| backgroundColor: '#bb6987', | |
| stack: 'stack 2', | |
| }, | |
| { | |
| label: 'Initial Cash Investment', | |
| data: [200], | |
| backgroundColor: '#a53860', | |
| stack: 'stack 3', | |
| }, | |
| ], | |
| }; | |
| var chart = new Chart(ctx, { | |
| type:'bar', | |
| plugins: [chartjsPluginWaterfall], | |
| data: dat | |
| }); | |
| </script> | |
| </body> | |
| </html> |
here solution: