Migrate chart.js <script> functions to django views while maintaining dynamic interactivity on all charts

I have a django app that has a significant amount of user interaction with the user. The User uses sliders and text boxes to move data points, and the chart automatically changes and recalculates all inputs and outputs based on functions within the chart.js ,script> in my HTML.

Looking at my script, there are 10 or so functions that are better fit in django views. So I built them in Django.

Examples of functions:

  • projectDetails <-- cost, bidding, scheduling, etc. calculations, user can move with a slider, months, costs, etc. and it recalculates the updates.
  • projectRisks <-- user moves riskToleranceSlider and puts info in some text boxes and up/downs, and chart.js script calculates a return that gets dynamically plotted.
  • financialCalcs <-- return monthly / monthly project data with npv, fv, interest, gain_and_loss, etc.

All these functions are defined right now in <script>, they're also defined in my Django view but i'm not using them. there are about 10 of such functions.

How can I decouple from Chart.js <script> and migrate to my app.views while maintaining the speed, snappiness, and dynamic interactivity in the app?

Back to Top